From d97b8cde70ac984c3876f327af3fef6811c41956 Mon Sep 17 00:00:00 2001 From: lucas-manuel Date: Wed, 3 Jul 2024 14:34:55 -0400 Subject: [PATCH] feat: add ge assertions --- test/invariant/handlers/SwapperHandler.sol | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/invariant/handlers/SwapperHandler.sol b/test/invariant/handlers/SwapperHandler.sol index 848e2da..ca0b5e4 100644 --- a/test/invariant/handlers/SwapperHandler.sol +++ b/test/invariant/handlers/SwapperHandler.sol @@ -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)), @@ -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( @@ -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++; }