From ea71606ccc938b9709f3f7351ef906b569485de9 Mon Sep 17 00:00:00 2001 From: Hayden Shively <17186559+haydenshively@users.noreply.github.com> Date: Fri, 29 Dec 2023 23:05:11 -0600 Subject: [PATCH] Update addresses.md (#232) --- addresses.md | 27 ++++++++++--------- core/test/Liquidator.t.sol | 12 ++++++++- core/test/invariants/LenderHarness.sol | 3 ++- periphery/deploy.sh | 1 + periphery/foundry.toml | 2 ++ periphery/script/Deploy.s.sol | 4 +++ ...anager.sol => BorrowerNFTMultiManager.sol} | 4 +-- 7 files changed, 36 insertions(+), 17 deletions(-) rename periphery/src/managers/{MultiManager.sol => BorrowerNFTMultiManager.sol} (81%) diff --git a/addresses.md b/addresses.md index 822c8647..513318e6 100644 --- a/addresses.md +++ b/addresses.md @@ -1,15 +1,16 @@ | Contract Name | Commit Hash | Salt | Address | | -------------------------------- | ---------------------------------------- | ------------------------------------------------------------------ | -------------------------------------------- | -| **VolatilityOracle** | a4b9786d79e2e16fcf6612e8ce699bfb599e0c8d | bytes32(uint256(0xA10EBE1A)) | `0xcA91bb5e6F98BD99b9Ca8aED1B9c5d12e139DB3d` | -| **RateModel** | a4b9786d79e2e16fcf6612e8ce699bfb599e0c8d | bytes32(uint256(0xA10EBE1A)) | `0xBD477956Ad74329664f45978A3876B024E3da73d` | -| **Factory** | a4b9786d79e2e16fcf6612e8ce699bfb599e0c8d | bytes32(uint256(0xA10EBE1A)) | `0x95110C9806833d3D3C250112fac73c5A6f631E80` | -| **Lender** | a4b9786d79e2e16fcf6612e8ce699bfb599e0c8d | created by factory | `0x62eAa8b180faebfBb0627dBd07E23f27379c147e` | -| BorrowerLens | fad036d4a34b95441beca1ed7ea36738111b6045 | bytes32(uint256(0xA10EBE1A2)) | `0x8A15bfEBff7BF9ffaBBeAe49112Dc2E6C4E73Eaf` | -| LenderLens | fad036d4a34b95441beca1ed7ea36738111b6045 | bytes32(uint256(0xA10EBE1A2)) | `0x0d41292FCdF2569816a3b20d81765F1300f477E4` | -| LenderAccrualHelper | ec45040adf10da901aaf9e6394d6ece2d8095e3b | bytes32(uint256(0xA10EBE1A2)) | `0x49b7C197468b5E8Eb345768280B554B39Dc9F64b` | -| OracleUpdateHelper | b3864fc9c8b3299920fc2d73bedd7f906d64f999 | bytes32(uint256(0xA10EBE1A2)) | `0xB93d750Cc6CA3d1F494DC25e7375860feef74870` | -| Router | 50d81b55600d30ec2d18ffa4c83aad579b20a96a | bytes32(uint256(0xA10EBE1A2)) | `0x1E395864B96c3C04467153c1666d2AaA03a86fa8` | -| FrontendManager | 3b6e3329654fcb809b597a3cc9518fd3a8874d1c | bytes32(uint256(0xA10EBE1A2)) | `0x2d3A430Bd0F36cdb3911431a5e487a59c349Ca4d` | -| SimpleManager | 40863c0562cdfeee0a38e7eb5eb68bb7d33525cc | bytes32(uint256(0xA10EBE1A2)) | `0x760a9356dE7dfF4387a7f87A7563Be72b7F34Bb6` | -| UniswapNFTManager | 203442e3b3f825523f41542132057de962a5886e | bytes32(uint256(0xA10EBE1A2)) | `0xd6D4277bCCEEE3d9825D503dC23f0976992540e6` | -| WithdrawManager | e67ebdf3fb0507232370c5b0daa2d68b7c4d4813 | bytes32(uint256(0xA10EBE1A2)) | `0xEEAFdacc266900107155298Da34e9b8264f2eCbA` | +| **VolatilityOracle** | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x000000000000000000000000000000000000000072d2b1e41bc2400020241d9b | `0x0000000030d51e39a2dDDb5Db50F9d74a289DFc3` | +| **RateModel** | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x000000000000000000000000000000000000000029a4b92da42120001626d608 | `0x000000006b66E36407c709aD4808370d963F2aAB` | +| **BorrowerDeployer** | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x000000000000000000000000000000000000000091b1b6c2b3d408003c519fc1 | `0x0000000033CB32b42feD5df3555293fB299365bA` | +| **Factory** | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000cb94eb7800f858003d6aca1f | `0x000000009efdB26b970bCc0085E126C9dfc16ee8` | +| BorrowerLens | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0x46AeD741F9a329c0721519D6E66fA47Bb17B0986` | +| LenderLens | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0x2a1591e54315766e943382beF5E5C8e55c1b9C6C` | +| Router | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000f789d06098b1a000019efd68 | `0x672605730D8F75006C37582189999637Dc16fE7C` | +| BorrowerNFT | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000122d0a2ff5b481009316e38f | `0x00000000000078b629B7C06f5339060648468AA6` | +| BorrowerNFTSimpleManager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0xA07FD687882FfE7380A044e7542bDAc6F8672Bf7` | +| BoostManager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | eth/opt/arb: `0xB6B7521cd3bd116432FeD94c2262Dd02BA616Db4` base: `0x8E287b280671700EBE66A908A56C648f930b73b4` | +| Permit2Manager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0x6BDa468b1d473028938585a04eC3c62dcFF5309B` | +| FrontendManager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0x3Bb9F64b0e6b15dD5792A008c06E5c4Dc9d23D8f` | +| SimpleManager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | `0xBb5A35B80b15A8E5933fDC11646A20f6159Dd061` | +| UniswapNFTManager | 2c6e694336639d04849beb54cc0642f21e2ded04 | 0x0000000000000000000000000000000000000000A10EA10EA10EA10EA10EA10E | eth/opt/arb: `0x7516735395134BB9EbF75d908103b48eDF238B9f` base: `0xf46e04796185322485314Dd607DA1cb69028d731` | diff --git a/core/test/Liquidator.t.sol b/core/test/Liquidator.t.sol index 77fa1b71..c136b3d3 100644 --- a/core/test/Liquidator.t.sol +++ b/core/test/Liquidator.t.sol @@ -142,6 +142,7 @@ contract LiquidatorTest is Test, IManager, ILiquidator { assertEq(lender0.borrowBalance(address(account)), 0); assertEq(asset0.balanceOf(address(account)), 0.558651792067358746e18); + assertEq(account.slot0(), uint256(0x800000000000f0f0f0f0f0f0f0f0000000000000000000000000000000000000)); } function test_spec_repayETH() public { @@ -170,6 +171,7 @@ contract LiquidatorTest is Test, IManager, ILiquidator { assertEq(lender1.borrowBalance(address(account)), 0); assertEq(asset1.balanceOf(address(account)), 0.055865282831508020e18); + assertEq(account.slot0(), uint256(0x800000000000f0f0f0f0f0f0f0f0000000000000000000000000000000000000)); } function test_spec_repayDAIAndETH() public { @@ -205,6 +207,7 @@ contract LiquidatorTest is Test, IManager, ILiquidator { assertEq(lender1.borrowBalance(address(account)), 0); assertEq(asset0.balanceOf(address(account)), 0.558652822916151063e18); assertEq(asset1.balanceOf(address(account)), 0.055865282291615107e18); + assertEq(account.slot0(), uint256(0x800000000000f0f0f0f0f0f0f0f0000000000000000000000000000000000000)); } function test_spec_repayDAIAndETHWithUniswapPosition() public { @@ -247,6 +250,7 @@ contract LiquidatorTest is Test, IManager, ILiquidator { keccak256(abi.encodePacked(address(account), int24(-75600), int24(-75540))) ); assertEq(liquidity, 0); + assertEq(account.slot0(), uint256(0x800000000000f0f0f0f0f0f0f0f0000000000000000000000000000000000000)); } /// forge-config: default.fuzz.runs = 16 @@ -280,10 +284,11 @@ contract LiquidatorTest is Test, IManager, ILiquidator { assertLe(debt - (1595e18 * 10010) / 10000, 1); // Disable warn() requirement by setting auctionTime + uint256 warnTime = block.timestamp - LIQUIDATION_GRACE_PERIOD - TIME_OF_5_PERCENT; vm.store( address(account), bytes32(uint256(0)), - bytes32(uint256((block.timestamp - LIQUIDATION_GRACE_PERIOD - TIME_OF_5_PERCENT) << 208)) + bytes32(uint256(warnTime << 208)) ); (Prices memory prices, , , ) = account.getPrices(1 << 32); @@ -298,6 +303,9 @@ contract LiquidatorTest is Test, IManager, ILiquidator { assertLe(lender0.borrowBalance(address(account)) - (debt - (debt * closeFactor) / 10000), 1); assertGt(asset1.balanceOf(address(this)), 0); + if (closeFactor <= TERMINATING_CLOSE_FACTOR) { + assertEq(account.slot0(), uint256(0x8000000000000000000000000000000000000000000000000000000000000000) + (warnTime << 208)); + } } /// forge-config: default.fuzz.runs = 16 @@ -552,6 +560,8 @@ contract LiquidatorTest is Test, IManager, ILiquidator { account.uniswapDeposit(-75600, -75540, 200000000000000000); positions = zip([-75600, -75540, 0, 0, 0, 0]); } + + positions |= 0xf0f0f0f0f0f0f0f0 << 144; } // ILiquidator diff --git a/core/test/invariants/LenderHarness.sol b/core/test/invariants/LenderHarness.sol index 90949d0c..69e1cf88 100644 --- a/core/test/invariants/LenderHarness.sol +++ b/core/test/invariants/LenderHarness.sol @@ -338,7 +338,8 @@ contract LenderHarness { uint256 borrowBalanceAfter = LENDER.borrowBalance(msg.sender); uint256 expectedBorrowBalance = borrowBalanceBefore + amount; require( - expectedBorrowBalance <= borrowBalanceAfter && borrowBalanceAfter <= expectedBorrowBalance + 3, + // Almost always <= expectedBorrowBalance + 4. 500 accounts for extreme cases like borrowing 2^112 + expectedBorrowBalance <= borrowBalanceAfter && borrowBalanceAfter <= expectedBorrowBalance + 500, "borrow: debt mismatch" ); if (recipient != address(LENDER)) { diff --git a/periphery/deploy.sh b/periphery/deploy.sh index 1cce5a46..927771af 100755 --- a/periphery/deploy.sh +++ b/periphery/deploy.sh @@ -8,6 +8,7 @@ cp -R ../core/lib lib/core/lib cp ../core/foundry.toml lib/core/ source .env +source .env.deploy # forge clean forge build forge script script/Deploy.s.sol:DeployScript --chain mainnet --rpc-url mainnet --broadcast --verify --slow --delay 10 --etherscan-api-key $ETHERSCAN_API_KEY diff --git a/periphery/foundry.toml b/periphery/foundry.toml index c3d2ce97..a073a127 100644 --- a/periphery/foundry.toml +++ b/periphery/foundry.toml @@ -7,6 +7,8 @@ libs = ['lib'] out = 'build' cache_path = 'cache' +solc_version = '0.8.23' +evm_version = 'paris' via_ir = true optimizer = true optimizer_runs = 65536 diff --git a/periphery/script/Deploy.s.sol b/periphery/script/Deploy.s.sol index ce181526..4eb8c207 100644 --- a/periphery/script/Deploy.s.sol +++ b/periphery/script/Deploy.s.sol @@ -13,6 +13,8 @@ import {BorrowerNFT, IBorrowerURISource} from "src/borrower-nft/BorrowerNFT.sol" import {IUniswapPositionNFT} from "src/interfaces/IUniswapPositionNFT.sol"; import {BoostManager} from "src/managers/BoostManager.sol"; +import {BorrowerNFTMultiManager} from "src/managers/BorrowerNFTMultiManager.sol"; +import {BorrowerNFTSimpleManager} from "src/managers/BorrowerNFTSimpleManager.sol"; import {FrontendManager} from "src/managers/FrontendManager.sol"; import {Permit2Manager} from "src/managers/Permit2Manager.sol"; import {SimpleManager} from "src/managers/SimpleManager.sol"; @@ -55,6 +57,8 @@ contract DeployScript is Script { BorrowerNFT borrowerNft = new BorrowerNFT{salt: saltB}(FACTORY, BORROWER_URI_SOURCE); // BorrowerNFT-style managers + new BorrowerNFTMultiManager{salt: TAG}(); + new BorrowerNFTSimpleManager{salt: TAG}(); new BoostManager{salt: TAG}(FACTORY, address(borrowerNft), uniswapPositionNft); new Permit2Manager{salt: TAG}(PERMIT2, FACTORY, address(borrowerNft)); diff --git a/periphery/src/managers/MultiManager.sol b/periphery/src/managers/BorrowerNFTMultiManager.sol similarity index 81% rename from periphery/src/managers/MultiManager.sol rename to periphery/src/managers/BorrowerNFTMultiManager.sol index 6c9bdeb2..a5e071ac 100644 --- a/periphery/src/managers/MultiManager.sol +++ b/periphery/src/managers/BorrowerNFTMultiManager.sol @@ -3,10 +3,10 @@ pragma solidity 0.8.23; import {IManager} from "aloe-ii-core/Borrower.sol"; -contract MultiManager is IManager { +contract BorrowerNFTMultiManager is IManager { function callback(bytes calldata data, address, uint208) external override returns (uint208) { unchecked { - bytes[] memory calls = abi.decode(data, (bytes[])); + bytes[] memory calls = abi.decode(data[20:], (bytes[])); uint256 count = calls.length; for (uint256 i; i < count; i++) {