Skip to content

Commit

Permalink
feat: add ge assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-manuel committed Jul 3, 2024
1 parent 7cd1c87 commit d97b8cd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/invariant/handlers/SwapperHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ contract SwapperHandler is HandlerBase {
"SwapperHandler/swap/conversion-rate-change-million"
);

// Decrease in value from rounding is capped at 2e12
assertGe(
psm.convertToAssetValue(1_000_000e18) + 2e12,
startingConversionMillion,
"SwapperHandler/swap/conversion-rate-million-decrease"
);

// Position values can fluctuate by up to 0.00000002% on swaps
assertApproxEqRel(
psm.convertToAssetValue(psm.shares(lp0)),
Expand All @@ -131,6 +138,13 @@ contract SwapperHandler is HandlerBase {
"SwapperHandler/swap/conversion-rate-change-lp"
);

// Decrease in value from rounding is capped at 2e12
assertGe(
psm.convertToAssetValue(psm.shares(lp0)) + 2e12,
startingConversionLp0,
"SwapperHandler/swap/conversion-rate-lp-decrease"
);

// PSM value can fluctuate by up to 0.00000001% on swaps because of USDC rounding
// (conversion not performed so 1 instead of 2)
assertApproxEqRel(
Expand All @@ -140,6 +154,13 @@ contract SwapperHandler is HandlerBase {
"SwapperHandler/swap/psm-total-value-change"
);

// Decrease in value from rounding is capped at 2e12
assertGe(
psm.getPsmTotalValue() + 1e12,
startingValue,
"SwapperHandler/swap/psm-total-value-decrease"
);

// 5. Update metrics tracking state
swapCount++;
}
Expand Down

0 comments on commit d97b8cd

Please sign in to comment.