From 4b561741835a49a38dc2de8c06e3ccaf969b17fc Mon Sep 17 00:00:00 2001 From: telome <> Date: Thu, 14 Dec 2023 17:45:12 +0000 Subject: [PATCH] Always rewrite PIP_MKR price in tests --- test/Splitter.t.sol | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/Splitter.t.sol b/test/Splitter.t.sol index f0995de..8aff2b1 100644 --- a/test/Splitter.t.sol +++ b/test/Splitter.t.sol @@ -170,11 +170,14 @@ contract SplitterTest is DssTest { (uint256 reserveDai, ) = UniswapV2Library.getReserves(UNIV2_FACTORY, DAI, MKR); uint256 minimalDaiReserve = 280_000 * WAD; if (reserveDai < minimalDaiReserve) { + changeMedianizerPrice(727 * WAD); changeUniV2Price(medianizer.read(), MKR, UNIV2_DAI_MKR_PAIR); (reserveDai, ) = UniswapV2Library.getReserves(UNIV2_FACTORY, DAI, MKR); if(reserveDai < minimalDaiReserve) { topUpLiquidity(minimalDaiReserve - reserveDai, MKR, UNIV2_DAI_MKR_PAIR); } + } else { + changeMedianizerPrice(uniV2DaiForGem(WAD, MKR)); } // Create additional surplus if needed @@ -218,6 +221,10 @@ contract SplitterTest is DssTest { PairLike(pair).sync(); } + function changeMedianizerPrice(uint256 daiForGem) internal { + vm.store(address(medianizer), bytes32(uint256(1)), bytes32(block.timestamp << 128 | daiForGem)); + } + function topUpLiquidity(uint256 daiAmt, address gem, address pair) internal { (uint256 reserveDai, uint256 reserveGem) = UniswapV2Library.getReserves(UNIV2_FACTORY, DAI, gem); uint256 gemAmt = UniswapV2Library.quote(daiAmt, reserveDai, reserveGem);