Skip to content

Commit

Permalink
remove aave v3-specific stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hexonaut committed Mar 17, 2024
1 parent 686e304 commit c6e9214
Showing 1 changed file with 0 additions and 156 deletions.
156 changes: 0 additions & 156 deletions src/tests/integration/MetaMorpho.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,50 +125,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();
Expand All @@ -192,116 +148,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");
// }
}

0 comments on commit c6e9214

Please sign in to comment.