diff --git a/script/input/1/template-morpho.json b/script/input/1/template-morpho.json index d65445ca..fdc61075 100644 --- a/script/input/1/template-morpho.json +++ b/script/input/1/template-morpho.json @@ -9,6 +9,6 @@ "gap": 10000000, "ttl": 21600, "tau": 604800, - "vault": "0xB8C7F2a4B3bF76CC04bd55Ebc259b33a67b3b36d", + "vault": "0x73e65DBD630f90604062f6E02fAb9138e713edD9", "operator": "0x298b375f24CeDb45e936D7e21d6Eb05e344adFb5" } diff --git a/src/tests/integration/MetaMorpho.t.sol b/src/tests/integration/MetaMorpho.t.sol index eef5d2ba..1e8e9f99 100644 --- a/src/tests/integration/MetaMorpho.t.sol +++ b/src/tests/integration/MetaMorpho.t.sol @@ -124,50 +124,6 @@ contract MetaMorphoTest is IntegrationBaseTest { return art; } - function _divup(uint256 x, uint256 y) internal pure returns (uint256 z) { - unchecked { - z = x != 0 ? ((x - 1) / y) + 1 : 0; - } - } - - // function getInterestRateStrategy(address asset) internal view returns (address) { - // PoolLike.ReserveData memory data = sparkPool.getReserveData(asset); - // return data.interestRateStrategyAddress; - // } - - // function forceUpdateIndicies(address asset) internal { - // // Do the flashloan trick to force update indicies - // sparkPool.flashLoanSimple(address(this), asset, 1, "", 0); - // } - - // function executeOperation( - // address, - // uint256, - // uint256, - // address, - // bytes calldata - // ) external pure returns (bool) { - // // Flashloan callback just immediately returns - // return true; - // } - - // function getTotalAssets(address asset) internal view returns (uint256) { - // // Assets = DAI Liquidity + Total Debt - // PoolLike.ReserveData memory data = sparkPool.getReserveData(asset); - // return dai.balanceOf(address(adai)) + ATokenLike(data.variableDebtTokenAddress).totalSupply() + ATokenLike(data.stableDebtTokenAddress).totalSupply(); - // } - - // function getTotalLiabilities(address asset) internal view returns (uint256) { - // // Liabilities = spDAI Supply + Amount Accrued to Treasury - // PoolLike.ReserveData memory data = sparkPool.getReserveData(asset); - // return _divup((adai.scaledTotalSupply() + uint256(data.accruedToTreasury)) * data.liquidityIndex, RAY); - // } - - // function getAccruedToTreasury(address asset) internal view returns (uint256) { - // PoolLike.ReserveData memory data = sparkPool.getReserveData(asset); - // return data.accruedToTreasury; - // } - // // --- Tests --- // function test_simple_wind_unwind() public { // setLiquidityToZero(); @@ -191,116 +147,4 @@ contract MetaMorphoTest is IntegrationBaseTest { // hub.exec(ilk); // assertEq(getDebt(), buffer + buffer / 2 - buffer / 4, "should be back down to 1.25x the buffer"); // } - - // /** - // * The DAI market is using a new interest model which over-allocates interest to the treasury. - // * This is due to the reserve factor not being flexible enough to account for this. - // * Confirm that we can later correct the discrepancy by donating the excess liabilities back to the DAI pool. (This can be automated later on) - // */ - // function test_asset_liabilities_fix() public { - // uint256 assets = getTotalAssets(address(dai)); - // uint256 liabilities = getTotalLiabilities(address(dai)); - // if (assets >= liabilities) { - // // Force the assets to become less than the liabilities - // uint256 performanceBonus = daiInterestRateStrategy.performanceBonus(); - // vm.prank(admin); plan.file("buffer", performanceBonus * 4); - // hub.exec(ilk); - // sparkPool.borrow(address(dai), performanceBonus * 2, 2, 0, address(this)); // Supply rate should now be above 0% (we are over-allocating) - - // // Warp so we gaurantee there is new interest - // vm.warp(block.timestamp + 365 days); - // forceUpdateIndicies(address(dai)); - - // assets = getTotalAssets(address(dai)); - // liabilities = getTotalLiabilities(address(dai)); - // assertLe(assets, liabilities, "assets should be less than or equal to liabilities"); - // } - - // // Let's fix the accounting - // uint256 delta = liabilities - assets; - - // // First trigger all spDAI owed to the treasury to be accrued - // assertGt(getAccruedToTreasury(address(dai)), 0, "accrued to treasury should be greater than 0"); - // address[] memory toMint = new address[](1); - // toMint[0] = address(dai); - // sparkPool.mintToTreasury(toMint); - // assertEq(getAccruedToTreasury(address(dai)), 0, "accrued to treasury should be 0"); - // assertGe(adai.balanceOf(address(treasury)), delta, "adai treasury should have more than the delta between liabilities and assets"); - - // // Donate the excess liabilities back to the pool - // // This will burn the liabilities while keeping the assets the same - // vm.prank(admin); treasuryAdmin.transfer(address(treasury), address(adai), address(this), delta); - // sparkPool.withdraw(address(dai), delta, address(adai)); - - // assets = getTotalAssets(address(dai)) + 1; // In case of rounding error we +1 - // liabilities = getTotalLiabilities(address(dai)); - // assertGe(assets, liabilities, "assets should be greater than or equal to liabilities"); - // } - - // function test_asset_liabilities_fix_full_utilization_flashloan() public { - // uint256 assets = getTotalAssets(address(dai)); - // uint256 liabilities = getTotalLiabilities(address(dai)); - // if (assets >= liabilities) { - // // Force the assets to become less than the liabilities - // uint256 performanceBonus = daiInterestRateStrategy.performanceBonus(); - // vm.prank(admin); plan.file("buffer", performanceBonus * 4); - // hub.exec(ilk); - // sparkPool.borrow(address(dai), performanceBonus * 2, 2, 0, address(this)); // Supply rate should now be above 0% (we are over-allocating) - - // // Warp so we gaurantee there is new interest - // vm.warp(block.timestamp + 365 days); - // forceUpdateIndicies(address(dai)); - - // assets = getTotalAssets(address(dai)); - // liabilities = getTotalLiabilities(address(dai)); - // assertLe(assets, liabilities, "assets should be less than or equal to liabilities"); - // } - - // // Let's fix the accounting - // uint256 delta = liabilities - assets; - - // // First trigger all spDAI owed to the treasury to be accrued - // assertGt(getAccruedToTreasury(address(dai)), 0, "accrued to treasury should be greater than 0"); - // address[] memory toMint = new address[](1); - // toMint[0] = address(dai); - // sparkPool.mintToTreasury(toMint); - // assertEq(getAccruedToTreasury(address(dai)), 0, "accrued to treasury should be 0"); - // assertGe(adai.balanceOf(address(treasury)), delta, "adai treasury should have more than the delta between liabilities and assets"); - - // // Donate the excess liabilities back to the pool - // // This will burn the liabilities while keeping the assets the same - // vm.prank(admin); treasuryAdmin.transfer(address(treasury), address(adai), address(this), delta); - - // // Remove all DAI liquidity from the pool - // sparkPool.borrow(address(dai), dai.balanceOf(address(adai)), 2, 0, address(this)); - // assertEq(dai.balanceOf(address(adai)), 0); - // dai.setBalance(address(this), 0); // We have no DAI as well - - // // Withdrawing won't work because no available DAI - // vm.expectRevert(); - // sparkPool.withdraw(address(dai), delta, address(adai)); - - // // Flash loan to close out the liabilities - // flashLender.flashLoan(this, address(dai), delta, ""); - - // assets = getTotalAssets(address(dai)) + 1; // In case of rounding error we +1 - // liabilities = getTotalLiabilities(address(dai)); - // assertGe(assets, liabilities, "assets should be greater than or equal to liabilities"); - // } - - // function onFlashLoan( - // address, - // address token, - // uint256 amount, - // uint256 fee, - // bytes calldata - // ) external returns (bytes32) { - // sparkPool.supply(address(dai), amount, address(this), 0); - // sparkPool.withdraw(address(dai), amount, address(adai)); - // sparkPool.withdraw(address(dai), amount, address(this)); - - // ATokenLike(token).approve(address(msg.sender), amount + fee); - - // return keccak256("ERC3156FlashBorrower.onFlashLoan"); - // } }