From 09c95b23f820b6da2fef13c4067aebabb21d42b0 Mon Sep 17 00:00:00 2001 From: lucas-manuel Date: Thu, 4 Jul 2024 15:18:47 -0400 Subject: [PATCH] feat: invariant tests passing --- test/invariant/Invariants.t.sol | 6 +++--- test/invariant/handlers/TimeBasedRateHandler.sol | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/invariant/Invariants.t.sol b/test/invariant/Invariants.t.sol index f0ff9ee..1dcddc8 100644 --- a/test/invariant/Invariants.t.sol +++ b/test/invariant/Invariants.t.sol @@ -511,7 +511,7 @@ contract PSMInvariants_TimeBasedRateSetting_NoTransfer is PSMInvariantTestBase { rateProvider = IRateProviderLike(address(dsrOracle)); // Manually set initial values for the oracle through the handler to start - timeBasedRateHandler.setPotData(1e27, block.timestamp); + timeBasedRateHandler.setPotData(1e27); targetContract(address(lpHandler)); targetContract(address(swapperHandler)); @@ -521,7 +521,7 @@ contract PSMInvariants_TimeBasedRateSetting_NoTransfer is PSMInvariantTestBase { assertEq(swapperHandler.lp0(), lpHandler.lps(0)); } - function invariant_A() public view { + function invariant_A_test() public view { _checkInvariant_A(); } @@ -575,7 +575,7 @@ contract PSMInvariants_TimeBasedRateSetting_WithTransfers is PSMInvariantTestBas rateProvider = IRateProviderLike(address(dsrOracle)); // Manually set initial values for the oracle through the handler to start - timeBasedRateHandler.setPotData(1e27, block.timestamp); + timeBasedRateHandler.setPotData(1e27); targetContract(address(lpHandler)); targetContract(address(swapperHandler)); diff --git a/test/invariant/handlers/TimeBasedRateHandler.sol b/test/invariant/handlers/TimeBasedRateHandler.sol index 758bfc0..c6a3f22 100644 --- a/test/invariant/handlers/TimeBasedRateHandler.sol +++ b/test/invariant/handlers/TimeBasedRateHandler.sol @@ -11,7 +11,6 @@ import { IDSROracle } from "lib/xchain-dsr-oracle/src/interfaces/IDSROracle.s contract TimeBasedRateHandler is HandlerBase, StdCheats { uint256 public dsr; - uint256 public rho; uint256 constant ONE_HUNDRED_PCT_APY_DSR = 1.000000021979553151239153027e27; @@ -25,10 +24,13 @@ contract TimeBasedRateHandler is HandlerBase, StdCheats { } // This acts as a receiver on an L2. - function setPotData(uint256 newDsr, uint256 newRho) external { + // TODO: Discuss if rho should be set to a value between last rho and block.timestamp. + // This was the original approach but was causing the conversion rate to decrease. + function setPotData(uint256 newDsr) external { // 1. Setup and bounds dsr = _bound(newDsr, 1e27, ONE_HUNDRED_PCT_APY_DSR); - rho = _bound(newRho, rho, block.timestamp); + + uint256 rho = block.timestamp; // If chi hasn't been set yet, set to 1e27, else recalculate it in the same way it would // happen during a refresh at `rho`