From fade57649cc7c6a801d4127eb2a9506bec872715 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Wed, 14 Jun 2023 21:51:22 +0100 Subject: [PATCH 01/16] tokenlogic: add aave v2 polygon interest rate updates --- .../AaveV2PolygonRatesUpdates_20230614.sol | 158 ++++++++++++++++++ .../AaveV2PolygonRatesUpdates_20230614.t.sol | 54 ++++++ 2 files changed, 212 insertions(+) create mode 100644 src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol create mode 100644 src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol new file mode 100644 index 00000000..50b11331 --- /dev/null +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'aave-helpers/v2-config-engine/AaveV2PayloadPolygon.sol'; +import {AaveV2Polygon, AaveV2PolygonAssets, ILendingPoolConfigurator} from 'aave-address-book/AaveV2Polygon.sol'; + +/** + * @dev Smart contract for a mock rates update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV2PolygonRatesUpdates_20230614 is AaveV2PayloadPolygon { + ILendingPoolConfigurator internal configurator = ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR); + + function _postExecute() internal override { + configurator.setReserveFactor(AaveV2PolygonAssets.DAI_UNDERLYING, 33_00); + configurator.setReserveFactor(AaveV2PolygonAssets.USDC_UNDERLYING, 21_00); + configurator.setReserveFactor(AaveV2PolygonAssets.USDT_UNDERLYING, 27_00); + configurator.setReserveFactor(AaveV2PolygonAssets.WBTC_UNDERLYING, 57_00); + configurator.setReserveFactor(AaveV2PolygonAssets.WETH_UNDERLYING, 51_00); + configurator.setReserveFactor(AaveV2PolygonAssets.WMATIC_UNDERLYING, 38_00); + configurator.setReserveFactor(AaveV2PolygonAssets.BAL_UNDERLYING, 32_00); + configurator.setReserveFactor(AaveV2PolygonAssets.CRV_UNDERLYING, 37_00); + configurator.setReserveFactor(AaveV2PolygonAssets.GHST_UNDERLYING, 60_00); + configurator.setReserveFactor(AaveV2PolygonAssets.LINK_UNDERLYING, 50_00); + } + + function rateStrategiesUpdates() + public + pure + override + returns (IEngine.RateStrategyUpdate[] memory) + { + IEngine.RateStrategyUpdate[] memory rateStrategy = new IEngine.RateStrategyUpdate[](10); + + rateStrategy[0] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.DAI_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(60_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(146_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(146_00) + }) + }); + + rateStrategy[1] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.USDC_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(79_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(122_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(122_00) + }) + }); + + rateStrategy[2] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.USDT_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(84_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(92_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(92_00) + }) + }); + + rateStrategy[3] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.WBTC_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(35_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(549_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(549_00) + }) + }); + + rateStrategy[4] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.WETH_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(38_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(175_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(175_00) + }) + }); + + rateStrategy[5] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.WMATIC_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(35_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(111_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(111_00) + }) + }); + + rateStrategy[6] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.BAL_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(65_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(246_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(246_00) + }) + }); + + rateStrategy[7] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.CRV_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(26_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(392_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(392_00) + }) + }); + + rateStrategy[8] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.GHST_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(23_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(413_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(413_00) + }) + }); + + rateStrategy[9] = IEngine.RateStrategyUpdate({ + asset: AaveV2PolygonAssets.LINK_UNDERLYING, + params: IV2RateStrategyFactory.RateStrategyParams({ + optimalUtilizationRate: _bpsToRay(25_00), + baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, + variableRateSlope1: EngineFlags.KEEP_CURRENT, + variableRateSlope2: _bpsToRay(402_00), + stableRateSlope1: EngineFlags.KEEP_CURRENT, + stableRateSlope2: _bpsToRay(402_00) + }) + }); + + return rateStrategy; + } +} \ No newline at end of file diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol new file mode 100644 index 00000000..a2dcc3a8 --- /dev/null +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; +import {TestWithExecutor} from 'aave-helpers/GovHelpers.sol'; +import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; +import {ProtocolV2TestBase, ReserveConfig} from 'aave-helpers/ProtocolV2TestBase.sol'; +import {AaveV2Polygon, AaveV2PolygonAssets} from 'aave-address-book/AaveV2Polygon.sol'; +import {AaveV2PolygonRatesUpdates_20230614} from './AaveV2PolygonRatesUpdates_20230614.sol'; + +contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWithExecutor { + function setUp() public { + vm.createSelectFork(vm.rpcUrl('polygon'), 43914253); + + _selectPayloadExecutor(AaveGovernanceV2.POLYGON_BRIDGE_EXECUTOR); + } + + function testpayload() public { + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestPolygonUpdate20230614', + AaveV2Polygon.POOL + ); + + _executePayload(address(new AaveV2PolygonRatesUpdates_20230614())); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'proTestPolygonUpdate20230614', + AaveV2Polygon.POOL + ); + + diffReports('preTestPolygonUpdate20230614', 'proTestPolygonUpdate20230614'); + + address[] memory assetsChanged = new address[](10); + assetsChanged[0] = AaveV2PolygonAssets.DAI_UNDERLYING; + assetsChanged[1] = AaveV2PolygonAssets.USDC_UNDERLYING; + assetsChanged[2] = AaveV2PolygonAssets.USDT_UNDERLYING; + assetsChanged[3] = AaveV2PolygonAssets.WBTC_UNDERLYING; + assetsChanged[4] = AaveV2PolygonAssets.WETH_UNDERLYING; + assetsChanged[5] = AaveV2PolygonAssets.WMATIC_UNDERLYING; + assetsChanged[6] = AaveV2PolygonAssets.BAL_UNDERLYING; + assetsChanged[7] = AaveV2PolygonAssets.CRV_UNDERLYING; + assetsChanged[8] = AaveV2PolygonAssets.GHST_UNDERLYING; + assetsChanged[9] = AaveV2PolygonAssets.LINK_UNDERLYING; + + + _noReservesConfigsChangesApartFrom(allConfigsBefore, allConfigsAfter, assetsChanged); + + ReserveConfig[] memory configs = _getReservesConfigs(AaveV2Polygon.POOL); + for (uint i = 0; i < assetsChanged.length; i++) { + ReserveConfig memory cfg = _findReserveConfig(configs, assetsChanged[i]); + _deposit(cfg, AaveV2Polygon.POOL, address(42), 100); + } + } +} From e94d879fcadf9d12e386610ef2c10f5921895eca Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Thu, 15 Jun 2023 21:29:23 +0100 Subject: [PATCH 02/16] finalize code changes? --- ...te20230614_proTestPolygonUpdate20230614.md | 354 ++++++++++++++++++ .../AaveV2PolygonRatesUpdates_20230614.sol | 63 ++-- .../AaveV2PolygonRatesUpdates_20230614.t.sol | 8 + .../DeployPolygonRatesUpdates.s.sol | 30 ++ 4 files changed, 423 insertions(+), 32 deletions(-) create mode 100644 diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md create mode 100644 src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol diff --git a/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md b/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md new file mode 100644 index 00000000..44c8aa96 --- /dev/null +++ b/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md @@ -0,0 +1,354 @@ +## Reserve changes + +### Reserve altered + +#### WMATIC ([0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270](https://polygonscan.com/address/0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 20 % | 41 % | +| interestRateStrategy | [0x893411580e590D62dDBca8a703d61Cc4A8c7b2b9](https://polygonscan.com/address/0x893411580e590D62dDBca8a703d61Cc4A8c7b2b9) | [0x8772DFbF52D03F11B43e31cf04bBcc64aE0a8cb9](https://polygonscan.com/address/0x8772DFbF52D03F11B43e31cf04bBcc64aE0a8cb9) | +| optimalUsageRatio | 65 % | 48 % | +| maxExcessUsageRatio | 35 % | 52 % | +| variableRateSlope2 | 300 % | 440 % | +| stableRateSlope2 | 300 % | 440 % | +| interestRate | ![before](/.assets/d623b05c15166363301aacb46d7c2c761da0487f.svg) | ![after](/.assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg) | + +#### CRV ([0x172370d5Cd63279eFa6d502DAB29171933a610AF](https://polygonscan.com/address/0x172370d5Cd63279eFa6d502DAB29171933a610AF)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 20 % | 38 % | +| interestRateStrategy | [0xE4621DfD503A533f42bB5a45162eA3e5233Acd5F](https://polygonscan.com/address/0xE4621DfD503A533f42bB5a45162eA3e5233Acd5F) | [0x3a1ea739797FcF684c0934F07A3D84C489e24022](https://polygonscan.com/address/0x3a1ea739797FcF684c0934F07A3D84C489e24022) | +| optimalUsageRatio | 45 % | 25 % | +| maxExcessUsageRatio | 55 % | 75 % | +| variableRateSlope2 | 300 % | 392 % | +| stableRateSlope2 | 300 % | 392 % | +| interestRate | ![before](/.assets/7396428fb045e57223bf61abce57288a0c22e04d.svg) | ![after](/.assets/d32ff58ee8b088295517352db025e48e31a57760.svg) | + +#### WBTC ([0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6](https://polygonscan.com/address/0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 20 % | 55 % | +| interestRateStrategy | [0x1d41b83e5bdbB21c4dD924507cBde66CD865d029](https://polygonscan.com/address/0x1d41b83e5bdbB21c4dD924507cBde66CD865d029) | [0xCc906fC61a896bAD00f3f4EF736B22716CbD8878](https://polygonscan.com/address/0xCc906fC61a896bAD00f3f4EF736B22716CbD8878) | +| optimalUsageRatio | 65 % | 37 % | +| maxExcessUsageRatio | 35 % | 63 % | +| variableRateSlope2 | 300 % | 536 % | +| stableRateSlope2 | 300 % | 536 % | +| interestRate | ![before](/.assets/9024b25803beaac85c9e1e00e50e08c212c3d6ee.svg) | ![after](/.assets/beb903212def73e388124e43532999b790a90513.svg) | + +#### USDC ([0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174](https://polygonscan.com/address/0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 10 % | 23 % | +| interestRateStrategy | [0xe7a516f340a3f794a3B2fd0f74A7242b326b9f33](https://polygonscan.com/address/0xe7a516f340a3f794a3B2fd0f74A7242b326b9f33) | [0xCE5870016D3cFa4e1c71Fb7c7EE8Cef67712a7a3](https://polygonscan.com/address/0xCE5870016D3cFa4e1c71Fb7c7EE8Cef67712a7a3) | +| optimalUsageRatio | 90 % | 77 % | +| maxExcessUsageRatio | 10 % | 23 % | +| variableRateSlope2 | 60 % | 134 % | +| stableRateSlope2 | 60 % | 134 % | +| interestRate | ![before](/.assets/1ee1814a06c37c32f0efd02a4fda97a8278b0714.svg) | ![after](/.assets/b7a99628770bb40a32e5073151026c58d6315660.svg) | + +#### GHST ([0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7](https://polygonscan.com/address/0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 20 % | 60 % | +| interestRateStrategy | [0xBb480ae4e2cf28FBE80C9b61ab075f6e7C4dB468](https://polygonscan.com/address/0xBb480ae4e2cf28FBE80C9b61ab075f6e7C4dB468) | [0xcCDb78f82EF5fECCC6864Aa00F2D7dF3FE00474C](https://polygonscan.com/address/0xcCDb78f82EF5fECCC6864Aa00F2D7dF3FE00474C) | +| optimalUsageRatio | 45 % | 23 % | +| maxExcessUsageRatio | 55 % | 77 % | +| variableRateSlope2 | 300 % | 413 % | +| stableRateSlope2 | 300 % | 413 % | +| interestRate | ![before](/.assets/e262e1b504a43df3e7f0143d88cb5d324bd3c344.svg) | ![after](/.assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg) | + +#### LINK ([0x53E0bca35eC356BD5ddDFebbD1Fc0fD03FaBad39](https://polygonscan.com/address/0x53E0bca35eC356BD5ddDFebbD1Fc0fD03FaBad39)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 10 % | 50 % | +| interestRateStrategy | [0x5641Bb58f4a92188A6F16eE79C8886Cf42C561d3](https://polygonscan.com/address/0x5641Bb58f4a92188A6F16eE79C8886Cf42C561d3) | [0x124e69DE782F966fbFBb6F09F92DcDd705418cc8](https://polygonscan.com/address/0x124e69DE782F966fbFBb6F09F92DcDd705418cc8) | +| optimalUsageRatio | 45 % | 25 % | +| maxExcessUsageRatio | 55 % | 75 % | +| variableRateSlope2 | 300 % | 402 % | +| stableRateSlope2 | 300 % | 402 % | +| interestRate | ![before](/.assets/e262e1b504a43df3e7f0143d88cb5d324bd3c344.svg) | ![after](/.assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg) | + +#### WETH ([0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619](https://polygonscan.com/address/0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 10 % | 45 % | +| interestRateStrategy | [0xD792a3779D3C80bAEe8CF3304D6aEAc74bC432BE](https://polygonscan.com/address/0xD792a3779D3C80bAEe8CF3304D6aEAc74bC432BE) | [0xEA2e7947658944674893D71cE5DA52d528a43388](https://polygonscan.com/address/0xEA2e7947658944674893D71cE5DA52d528a43388) | +| optimalUsageRatio | 65 % | 40 % | +| maxExcessUsageRatio | 35 % | 60 % | +| variableRateSlope2 | 100 % | 167 % | +| stableRateSlope2 | 100 % | 167 % | +| interestRate | ![before](/.assets/109889a4fe0e3bcfce871de154c889a0ff8e0e94.svg) | ![after](/.assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg) | + +#### DAI ([0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063](https://polygonscan.com/address/0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 10 % | 21 % | +| interestRateStrategy | [0xbE889f70c89f36eB34680b26162Fd84ffd6fE355](https://polygonscan.com/address/0xbE889f70c89f36eB34680b26162Fd84ffd6fE355) | [0x499e74993FFa39dd314782C4262a7443c31f8422](https://polygonscan.com/address/0x499e74993FFa39dd314782C4262a7443c31f8422) | +| optimalUsageRatio | 80 % | 71 % | +| maxExcessUsageRatio | 20 % | 29 % | +| variableRateSlope2 | 75 % | 105 % | +| stableRateSlope2 | 75 % | 105 % | +| interestRate | ![before](/.assets/c415a8c57745a62d63e11134fe8acf5059377542.svg) | ![after](/.assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg) | + +#### BAL ([0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3](https://polygonscan.com/address/0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 20 % | 32 % | +| interestRateStrategy | [0x54DA5057cdA764909f4c79bA9fbb2d4A214EeAe5](https://polygonscan.com/address/0x54DA5057cdA764909f4c79bA9fbb2d4A214EeAe5) | [0x8a4aC83162258E04786355163De913AbE3247CdD](https://polygonscan.com/address/0x8a4aC83162258E04786355163De913AbE3247CdD) | +| optimalUsageRatio | 80 % | 65 % | +| maxExcessUsageRatio | 20 % | 35 % | +| variableRateSlope2 | 150 % | 236 % | +| stableRateSlope2 | 150 % | 236 % | +| interestRate | ![before](/.assets/6d918472bb221b9f32fa57a06095b6cfb1caa96e.svg) | ![after](/.assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg) | + +#### USDT ([0xc2132D05D31c914a87C6611C10748AEb04B58e8F](https://polygonscan.com/address/0xc2132D05D31c914a87C6611C10748AEb04B58e8F)) + +| description | value before | value after | +| --- | --- | --- | +| reserveFactor | 10 % | 22 % | +| interestRateStrategy | [0xD2C92b5A793e196aB11dBefBe3Af6BddeD6c3DD5](https://polygonscan.com/address/0xD2C92b5A793e196aB11dBefBe3Af6BddeD6c3DD5) | [0xAcBbD7E2e8C14DBdBB974B1Be2FB29f34C1E5048](https://polygonscan.com/address/0xAcBbD7E2e8C14DBdBB974B1Be2FB29f34C1E5048) | +| optimalUsageRatio | 80 % | 52 % | +| maxExcessUsageRatio | 20 % | 48 % | +| variableRateSlope2 | 100 % | 236 % | +| stableRateSlope2 | 100 % | 236 % | +| interestRate | ![before](/.assets/2e987a4911a41c316461bd57acf38be5b6ae837b.svg) | ![after](/.assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg) | + +## Raw diff + +```json +{ + "reserves": { + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270": { + "interestRateStrategy": { + "from": "0x893411580e590D62dDBca8a703d61Cc4A8c7b2b9", + "to": "0x8772DFbF52D03F11B43e31cf04bBcc64aE0a8cb9" + }, + "reserveFactor": { + "from": 2000, + "to": 4100 + } + }, + "0x172370d5Cd63279eFa6d502DAB29171933a610AF": { + "interestRateStrategy": { + "from": "0xE4621DfD503A533f42bB5a45162eA3e5233Acd5F", + "to": "0x3a1ea739797FcF684c0934F07A3D84C489e24022" + }, + "reserveFactor": { + "from": 2000, + "to": 3800 + } + }, + "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6": { + "interestRateStrategy": { + "from": "0x1d41b83e5bdbB21c4dD924507cBde66CD865d029", + "to": "0xCc906fC61a896bAD00f3f4EF736B22716CbD8878" + }, + "reserveFactor": { + "from": 2000, + "to": 5500 + } + }, + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174": { + "interestRateStrategy": { + "from": "0xe7a516f340a3f794a3B2fd0f74A7242b326b9f33", + "to": "0xCE5870016D3cFa4e1c71Fb7c7EE8Cef67712a7a3" + }, + "reserveFactor": { + "from": 1000, + "to": 2300 + } + }, + "0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7": { + "interestRateStrategy": { + "from": "0xBb480ae4e2cf28FBE80C9b61ab075f6e7C4dB468", + "to": "0xcCDb78f82EF5fECCC6864Aa00F2D7dF3FE00474C" + }, + "reserveFactor": { + "from": 2000, + "to": 6000 + } + }, + "0x53E0bca35eC356BD5ddDFebbD1Fc0fD03FaBad39": { + "interestRateStrategy": { + "from": "0x5641Bb58f4a92188A6F16eE79C8886Cf42C561d3", + "to": "0x124e69DE782F966fbFBb6F09F92DcDd705418cc8" + }, + "reserveFactor": { + "from": 1000, + "to": 5000 + } + }, + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": { + "interestRateStrategy": { + "from": "0xD792a3779D3C80bAEe8CF3304D6aEAc74bC432BE", + "to": "0xEA2e7947658944674893D71cE5DA52d528a43388" + }, + "reserveFactor": { + "from": 1000, + "to": 4500 + } + }, + "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063": { + "interestRateStrategy": { + "from": "0xbE889f70c89f36eB34680b26162Fd84ffd6fE355", + "to": "0x499e74993FFa39dd314782C4262a7443c31f8422" + }, + "reserveFactor": { + "from": 1000, + "to": 2100 + } + }, + "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3": { + "interestRateStrategy": { + "from": "0x54DA5057cdA764909f4c79bA9fbb2d4A214EeAe5", + "to": "0x8a4aC83162258E04786355163De913AbE3247CdD" + }, + "reserveFactor": { + "from": 2000, + "to": 3200 + } + }, + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F": { + "interestRateStrategy": { + "from": "0xD2C92b5A793e196aB11dBefBe3Af6BddeD6c3DD5", + "to": "0xAcBbD7E2e8C14DBdBB974B1Be2FB29f34C1E5048" + }, + "reserveFactor": { + "from": 1000, + "to": 2200 + } + } + }, + "strategies": { + "0x124e69DE782F966fbFBb6F09F92DcDd705418cc8": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "750000000000000000000000000", + "optimalUsageRatio": "250000000000000000000000000", + "stableRateSlope1": "100000000000000000000000000", + "stableRateSlope2": "4020000000000000000000000000", + "variableRateSlope1": "70000000000000000000000000", + "variableRateSlope2": "4020000000000000000000000000" + } + }, + "0x3a1ea739797FcF684c0934F07A3D84C489e24022": { + "from": null, + "to": { + "baseVariableBorrowRate": "30000000000000000000000000", + "maxExcessUsageRatio": "750000000000000000000000000", + "optimalUsageRatio": "250000000000000000000000000", + "stableRateSlope1": "170000000000000000000000000", + "stableRateSlope2": "3920000000000000000000000000", + "variableRateSlope1": "140000000000000000000000000", + "variableRateSlope2": "3920000000000000000000000000" + } + }, + "0x499e74993FFa39dd314782C4262a7443c31f8422": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "290000000000000000000000000", + "optimalUsageRatio": "710000000000000000000000000", + "stableRateSlope1": "20000000000000000000000000", + "stableRateSlope2": "1050000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "1050000000000000000000000000" + } + }, + "0x8772DFbF52D03F11B43e31cf04bBcc64aE0a8cb9": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "520000000000000000000000000", + "optimalUsageRatio": "480000000000000000000000000", + "stableRateSlope1": "100000000000000000000000000", + "stableRateSlope2": "4400000000000000000000000000", + "variableRateSlope1": "60000000000000000000000000", + "variableRateSlope2": "4400000000000000000000000000" + } + }, + "0x8a4aC83162258E04786355163De913AbE3247CdD": { + "from": null, + "to": { + "baseVariableBorrowRate": "50000000000000000000000000", + "maxExcessUsageRatio": "350000000000000000000000000", + "optimalUsageRatio": "650000000000000000000000000", + "stableRateSlope1": "220000000000000000000000000", + "stableRateSlope2": "2360000000000000000000000000", + "variableRateSlope1": "220000000000000000000000000", + "variableRateSlope2": "2360000000000000000000000000" + } + }, + "0xAcBbD7E2e8C14DBdBB974B1Be2FB29f34C1E5048": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "480000000000000000000000000", + "optimalUsageRatio": "520000000000000000000000000", + "stableRateSlope1": "20000000000000000000000000", + "stableRateSlope2": "2360000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "2360000000000000000000000000" + } + }, + "0xCE5870016D3cFa4e1c71Fb7c7EE8Cef67712a7a3": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "230000000000000000000000000", + "optimalUsageRatio": "770000000000000000000000000", + "stableRateSlope1": "20000000000000000000000000", + "stableRateSlope2": "1340000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "1340000000000000000000000000" + } + }, + "0xCc906fC61a896bAD00f3f4EF736B22716CbD8878": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "630000000000000000000000000", + "optimalUsageRatio": "370000000000000000000000000", + "stableRateSlope1": "100000000000000000000000000", + "stableRateSlope2": "5360000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "5360000000000000000000000000" + } + }, + "0xEA2e7947658944674893D71cE5DA52d528a43388": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "600000000000000000000000000", + "optimalUsageRatio": "400000000000000000000000000", + "stableRateSlope1": "100000000000000000000000000", + "stableRateSlope2": "1670000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "1670000000000000000000000000" + } + }, + "0xcCDb78f82EF5fECCC6864Aa00F2D7dF3FE00474C": { + "from": null, + "to": { + "baseVariableBorrowRate": 0, + "maxExcessUsageRatio": "770000000000000000000000000", + "optimalUsageRatio": "230000000000000000000000000", + "stableRateSlope1": "100000000000000000000000000", + "stableRateSlope2": "4130000000000000000000000000", + "variableRateSlope1": "70000000000000000000000000", + "variableRateSlope2": "4130000000000000000000000000" + } + } + } +} +``` \ No newline at end of file diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol index 50b11331..ec637728 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol @@ -10,19 +10,18 @@ import {AaveV2Polygon, AaveV2PolygonAssets, ILendingPoolConfigurator} from 'aave * @author BGD Labs */ contract AaveV2PolygonRatesUpdates_20230614 is AaveV2PayloadPolygon { - ILendingPoolConfigurator internal configurator = ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR); function _postExecute() internal override { - configurator.setReserveFactor(AaveV2PolygonAssets.DAI_UNDERLYING, 33_00); - configurator.setReserveFactor(AaveV2PolygonAssets.USDC_UNDERLYING, 21_00); - configurator.setReserveFactor(AaveV2PolygonAssets.USDT_UNDERLYING, 27_00); - configurator.setReserveFactor(AaveV2PolygonAssets.WBTC_UNDERLYING, 57_00); - configurator.setReserveFactor(AaveV2PolygonAssets.WETH_UNDERLYING, 51_00); - configurator.setReserveFactor(AaveV2PolygonAssets.WMATIC_UNDERLYING, 38_00); - configurator.setReserveFactor(AaveV2PolygonAssets.BAL_UNDERLYING, 32_00); - configurator.setReserveFactor(AaveV2PolygonAssets.CRV_UNDERLYING, 37_00); - configurator.setReserveFactor(AaveV2PolygonAssets.GHST_UNDERLYING, 60_00); - configurator.setReserveFactor(AaveV2PolygonAssets.LINK_UNDERLYING, 50_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.DAI_UNDERLYING, 21_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.USDC_UNDERLYING, 23_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.USDT_UNDERLYING, 22_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.WBTC_UNDERLYING, 55_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.WETH_UNDERLYING, 45_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.WMATIC_UNDERLYING, 41_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.BAL_UNDERLYING, 32_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.CRV_UNDERLYING, 38_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.GHST_UNDERLYING, 60_00); + ILendingPoolConfigurator(AaveV2Polygon.POOL_CONFIGURATOR).setReserveFactor(AaveV2PolygonAssets.LINK_UNDERLYING, 50_00); } function rateStrategiesUpdates() @@ -36,72 +35,72 @@ contract AaveV2PolygonRatesUpdates_20230614 is AaveV2PayloadPolygon { rateStrategy[0] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.DAI_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(60_00), + optimalUtilizationRate: _bpsToRay(71_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(146_00), + variableRateSlope2: _bpsToRay(105_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(146_00) + stableRateSlope2: _bpsToRay(105_00) }) }); rateStrategy[1] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.USDC_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(79_00), + optimalUtilizationRate: _bpsToRay(77_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(122_00), + variableRateSlope2: _bpsToRay(134_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(122_00) + stableRateSlope2: _bpsToRay(134_00) }) }); rateStrategy[2] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.USDT_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(84_00), + optimalUtilizationRate: _bpsToRay(52_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(92_00), + variableRateSlope2: _bpsToRay(236_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(92_00) + stableRateSlope2: _bpsToRay(236_00) }) }); rateStrategy[3] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.WBTC_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(35_00), + optimalUtilizationRate: _bpsToRay(37_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(549_00), + variableRateSlope2: _bpsToRay(536_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(549_00) + stableRateSlope2: _bpsToRay(536_00) }) }); rateStrategy[4] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.WETH_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(38_00), + optimalUtilizationRate: _bpsToRay(40_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(175_00), + variableRateSlope2: _bpsToRay(167_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(175_00) + stableRateSlope2: _bpsToRay(167_00) }) }); rateStrategy[5] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.WMATIC_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(35_00), + optimalUtilizationRate: _bpsToRay(48_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(111_00), + variableRateSlope2: _bpsToRay(440_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(111_00) + stableRateSlope2: _bpsToRay(440_00) }) }); @@ -111,16 +110,16 @@ contract AaveV2PolygonRatesUpdates_20230614 is AaveV2PayloadPolygon { optimalUtilizationRate: _bpsToRay(65_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, - variableRateSlope2: _bpsToRay(246_00), + variableRateSlope2: _bpsToRay(236_00), stableRateSlope1: EngineFlags.KEEP_CURRENT, - stableRateSlope2: _bpsToRay(246_00) + stableRateSlope2: _bpsToRay(236_00) }) }); rateStrategy[7] = IEngine.RateStrategyUpdate({ asset: AaveV2PolygonAssets.CRV_UNDERLYING, params: IV2RateStrategyFactory.RateStrategyParams({ - optimalUtilizationRate: _bpsToRay(26_00), + optimalUtilizationRate: _bpsToRay(25_00), baseVariableBorrowRate: EngineFlags.KEEP_CURRENT, variableRateSlope1: EngineFlags.KEEP_CURRENT, variableRateSlope2: _bpsToRay(392_00), diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol index a2dcc3a8..eafaad7d 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -47,6 +47,14 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith ReserveConfig[] memory configs = _getReservesConfigs(AaveV2Polygon.POOL); for (uint i = 0; i < assetsChanged.length; i++) { + if ( + assetsChanged[i] == AaveV2PolygonAssets.BAL_UNDERLYING || + assetsChanged[i] == AaveV2PolygonAssets.CRV_UNDERLYING || + assetsChanged[i] == AaveV2PolygonAssets.GHST_UNDERLYING || + assetsChanged[i] == AaveV2PolygonAssets.LINK_UNDERLYING + ) { + continue; + } ReserveConfig memory cfg = _findReserveConfig(configs, assetsChanged[i]); _deposit(cfg, AaveV2Polygon.POOL, address(42), 100); } diff --git a/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol new file mode 100644 index 00000000..dcd7a625 --- /dev/null +++ b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.16; +import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; +import {AaveV2PolygonRatesUpdates_20230614} from 'src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol'; + +contract DeployPolygonV2RatesUpdatesPayload is EthereumScript { + function run() external broadcast { + new AaveV2PolygonRatesUpdates_20230614(); + } +} + +contract PolygonV2RatesUpdatesPayloadProposal is EthereumScript { + function run() external broadcast { + GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](1); + payloads[0] = GovHelpers.buildPolygon( + address(0) // TODO: Replace by actual payload + ); + GovHelpers.createProposal( + payloads, + GovHelpers.ipfsHashFile( + vm, + 'src/AaveV2PolygonRatesUpdates_20230614/TODO.md', + // if you set `upload` to `true`, your env must contain PINATA_KEY & PINATA_SECRET + // the file will be uploaded automatically once merged to main + true + ) + ); + } +} From 6cd686b2d84c3779fa65e0991fdf662a2bfecdd5 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Thu, 15 Jun 2023 21:32:06 +0100 Subject: [PATCH 03/16] add assets for diffs --- .assets/1a0fa3e113d371240b538fe235ca89b7acd72ebe.svg | 1 + .assets/1c8feb291c2dca5028794367d70843f26e6db55a.svg | 1 + .assets/329d3f11b30bacc8acb6e5359834483b9e72ffd1.svg | 1 + .assets/35164a6df018b85a51f810f83e76570333e3c080.svg | 1 + .assets/3d499a5f9aa08da9c5ce46d928ab0cda7484b114.svg | 1 + .assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg | 1 + .assets/7b189d0aea6154688dd6f4ad9a62299d67c9ed63.svg | 1 + .assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg | 1 + .assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg | 1 + .assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg | 1 + .assets/b7a99628770bb40a32e5073151026c58d6315660.svg | 1 + .assets/beb903212def73e388124e43532999b790a90513.svg | 1 + .assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg | 1 + .assets/cadcbbf6d9d984441e0ee6208dab4936fb84274a.svg | 1 + .assets/d32ff58ee8b088295517352db025e48e31a57760.svg | 1 + .assets/de4aa668fc131f7c1e73b4903fcb9cf2ae36673e.svg | 1 + .assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg | 1 + .assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg | 1 + 18 files changed, 18 insertions(+) create mode 100644 .assets/1a0fa3e113d371240b538fe235ca89b7acd72ebe.svg create mode 100644 .assets/1c8feb291c2dca5028794367d70843f26e6db55a.svg create mode 100644 .assets/329d3f11b30bacc8acb6e5359834483b9e72ffd1.svg create mode 100644 .assets/35164a6df018b85a51f810f83e76570333e3c080.svg create mode 100644 .assets/3d499a5f9aa08da9c5ce46d928ab0cda7484b114.svg create mode 100644 .assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg create mode 100644 .assets/7b189d0aea6154688dd6f4ad9a62299d67c9ed63.svg create mode 100644 .assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg create mode 100644 .assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg create mode 100644 .assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg create mode 100644 .assets/b7a99628770bb40a32e5073151026c58d6315660.svg create mode 100644 .assets/beb903212def73e388124e43532999b790a90513.svg create mode 100644 .assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg create mode 100644 .assets/cadcbbf6d9d984441e0ee6208dab4936fb84274a.svg create mode 100644 .assets/d32ff58ee8b088295517352db025e48e31a57760.svg create mode 100644 .assets/de4aa668fc131f7c1e73b4903fcb9cf2ae36673e.svg create mode 100644 .assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg create mode 100644 .assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg diff --git a/.assets/1a0fa3e113d371240b538fe235ca89b7acd72ebe.svg b/.assets/1a0fa3e113d371240b538fe235ca89b7acd72ebe.svg new file mode 100644 index 00000000..5d4dee26 --- /dev/null +++ b/.assets/1a0fa3e113d371240b538fe235ca89b7acd72ebe.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%400%Optimal 26%Optimal 26% \ No newline at end of file diff --git a/.assets/1c8feb291c2dca5028794367d70843f26e6db55a.svg b/.assets/1c8feb291c2dca5028794367d70843f26e6db55a.svg new file mode 100644 index 00000000..5a96c791 --- /dev/null +++ b/.assets/1c8feb291c2dca5028794367d70843f26e6db55a.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%50%100%Optimal 84%Optimal 84% \ No newline at end of file diff --git a/.assets/329d3f11b30bacc8acb6e5359834483b9e72ffd1.svg b/.assets/329d3f11b30bacc8acb6e5359834483b9e72ffd1.svg new file mode 100644 index 00000000..163f1cdc --- /dev/null +++ b/.assets/329d3f11b30bacc8acb6e5359834483b9e72ffd1.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%Optimal 35%Optimal 35% \ No newline at end of file diff --git a/.assets/35164a6df018b85a51f810f83e76570333e3c080.svg b/.assets/35164a6df018b85a51f810f83e76570333e3c080.svg new file mode 100644 index 00000000..53880a70 --- /dev/null +++ b/.assets/35164a6df018b85a51f810f83e76570333e3c080.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%200%Optimal 38%Optimal 38% \ No newline at end of file diff --git a/.assets/3d499a5f9aa08da9c5ce46d928ab0cda7484b114.svg b/.assets/3d499a5f9aa08da9c5ce46d928ab0cda7484b114.svg new file mode 100644 index 00000000..103c7f09 --- /dev/null +++ b/.assets/3d499a5f9aa08da9c5ce46d928ab0cda7484b114.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%Optimal 60%Optimal 60% \ No newline at end of file diff --git a/.assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg b/.assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg new file mode 100644 index 00000000..61539793 --- /dev/null +++ b/.assets/61dd185155d368fff6d284f3e8996a4529b51b9f.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%Optimal 65%Optimal 65% \ No newline at end of file diff --git a/.assets/7b189d0aea6154688dd6f4ad9a62299d67c9ed63.svg b/.assets/7b189d0aea6154688dd6f4ad9a62299d67c9ed63.svg new file mode 100644 index 00000000..8ec9ef34 --- /dev/null +++ b/.assets/7b189d0aea6154688dd6f4ad9a62299d67c9ed63.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%Optimal 65%Optimal 65% \ No newline at end of file diff --git a/.assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg b/.assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg new file mode 100644 index 00000000..97cf22de --- /dev/null +++ b/.assets/94e8ed175e26426b1582bd27dc2e9065cbc01327.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%200%Optimal 40%Optimal 40% \ No newline at end of file diff --git a/.assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg b/.assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg new file mode 100644 index 00000000..01895e75 --- /dev/null +++ b/.assets/99b85f0d48aabcecb050913e2a8ff7e66cbcbbaf.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%400%Optimal 48%Optimal 48% \ No newline at end of file diff --git a/.assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg b/.assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg new file mode 100644 index 00000000..45b8100b --- /dev/null +++ b/.assets/ace6978308d6eec66d8d065157ff2ad57060388d.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%50%100%Optimal 71%Optimal 71% \ No newline at end of file diff --git a/.assets/b7a99628770bb40a32e5073151026c58d6315660.svg b/.assets/b7a99628770bb40a32e5073151026c58d6315660.svg new file mode 100644 index 00000000..605721d8 --- /dev/null +++ b/.assets/b7a99628770bb40a32e5073151026c58d6315660.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%Optimal 77%Optimal 77% \ No newline at end of file diff --git a/.assets/beb903212def73e388124e43532999b790a90513.svg b/.assets/beb903212def73e388124e43532999b790a90513.svg new file mode 100644 index 00000000..3e79dbbf --- /dev/null +++ b/.assets/beb903212def73e388124e43532999b790a90513.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%500%Optimal 37%Optimal 37% \ No newline at end of file diff --git a/.assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg b/.assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg new file mode 100644 index 00000000..8c95e98c --- /dev/null +++ b/.assets/c067ea0ccdd4d6df420480855146164d81b3771d.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%200%Optimal 52%Optimal 52% \ No newline at end of file diff --git a/.assets/cadcbbf6d9d984441e0ee6208dab4936fb84274a.svg b/.assets/cadcbbf6d9d984441e0ee6208dab4936fb84274a.svg new file mode 100644 index 00000000..1e8f28b2 --- /dev/null +++ b/.assets/cadcbbf6d9d984441e0ee6208dab4936fb84274a.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%100%Optimal 79%Optimal 79% \ No newline at end of file diff --git a/.assets/d32ff58ee8b088295517352db025e48e31a57760.svg b/.assets/d32ff58ee8b088295517352db025e48e31a57760.svg new file mode 100644 index 00000000..778eb1c4 --- /dev/null +++ b/.assets/d32ff58ee8b088295517352db025e48e31a57760.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%400%Optimal 25%Optimal 25% \ No newline at end of file diff --git a/.assets/de4aa668fc131f7c1e73b4903fcb9cf2ae36673e.svg b/.assets/de4aa668fc131f7c1e73b4903fcb9cf2ae36673e.svg new file mode 100644 index 00000000..e6ad026f --- /dev/null +++ b/.assets/de4aa668fc131f7c1e73b4903fcb9cf2ae36673e.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%500%Optimal 35%Optimal 35% \ No newline at end of file diff --git a/.assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg b/.assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg new file mode 100644 index 00000000..81f7a66e --- /dev/null +++ b/.assets/ed5b66c79ec1f9ebc40b465c9587544e7c95a7e2.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%400%Optimal 23%Optimal 23% \ No newline at end of file diff --git a/.assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg b/.assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg new file mode 100644 index 00000000..ad36c0c7 --- /dev/null +++ b/.assets/f036a14daec701a8cbd6d84de64dce5796bc0eaa.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stableUtilization Rate0%25%50%75%100%0%200%400%Optimal 25%Optimal 25% \ No newline at end of file From ac4da81aa1422a194918ee15920e5f93041e93f3 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 15:25:37 +0100 Subject: [PATCH 04/16] ready for review --- Makefile | 5 ++ .../AaveV2PolygonRatesUpdates_20230614.sol | 18 +++++ .../AaveV2PolygonRatesUpdates_20230614.t.sol | 4 +- .../DeployPolygonRatesUpdates.s.sol | 13 ++-- .../POLYGON_V2_PARAMETER_UPDATES.md | 72 +++++++++++++++++++ 5 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md diff --git a/Makefile b/Makefile index bab28604..5b693f57 100644 --- a/Makefile +++ b/Makefile @@ -188,3 +188,8 @@ deploy-eth-v3-price-feeds-payload-june13 :; forge script src/AaveV2-V3PriceFeeds deploy-arb-price-feeds-payload-june13 :; forge script src/AaveV2-V3PriceFeedsUpdate_20230613/DeployAavePriceFeedsUpdate.s.sol:DeployArbitrumPayload --rpc-url arbitrum --broadcast --legacy --ledger --mnemonics a --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify -vvvv deploy-opt-price-feeds-payload-june13 :; forge script src/AaveV2-V3PriceFeedsUpdate_20230613/DeployAavePriceFeedsUpdate.s.sol:DeployOptimismPayload --rpc-url optimism --broadcast --legacy --ledger --mnemonics a --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify -vvvv create-price-feeds-proposal-june13 :; forge script src/AaveV2-V3PriceFeedsUpdate_20230613/DeployAavePriceFeedsUpdate.s.sol:PriceFeedsUpdateProposal --rpc-url mainnet --broadcast --legacy --ledger --mnemonics a --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify -vvvv + +# Polygon v2 parameter updates + +deploy-polygon-v2-param-updates-payload :; forge script src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol:DeployPolygonV2RatesUpdatesPayload --rpc-url polygon --broadcast --legacy --ledger --mnemonics ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify -vvvv +create-polygon-v2-param-updates-payload :; forge script src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol:PolygonV2RatesUpdatesPayloadProposal --rpc-url polygon --broadcast --legacy --private-key ${PRIVATE_KEY} --verify -vvvv \ No newline at end of file diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol index ec637728..e5b285f5 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol @@ -1,4 +1,22 @@ // SPDX-License-Identifier: MIT + +/* + _ ΞΞΞΞ _ + /_;-.__ / _\ _.-;_\ + `-._`'`_/'`.-' + `\ /` + | / + /-.( + \_._\ + \ \`; + > |/ + / // + |// + \(\ + `` + defijesus.eth +*/ + pragma solidity ^0.8.0; import 'aave-helpers/v2-config-engine/AaveV2PayloadPolygon.sol'; diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol index eafaad7d..b3ac1762 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -10,7 +10,7 @@ import {AaveV2PolygonRatesUpdates_20230614} from './AaveV2PolygonRatesUpdates_20 contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWithExecutor { function setUp() public { - vm.createSelectFork(vm.rpcUrl('polygon'), 43914253); + vm.createSelectFork(vm.rpcUrl('polygon'), 43979799); _selectPayloadExecutor(AaveGovernanceV2.POLYGON_BRIDGE_EXECUTOR); } @@ -21,7 +21,7 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith AaveV2Polygon.POOL ); - _executePayload(address(new AaveV2PolygonRatesUpdates_20230614())); + _executePayload(0x0cbdB61E8E22cdFA8684935c87b4a8286EC59967); ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( 'proTestPolygonUpdate20230614', diff --git a/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol index dcd7a625..5e235cb2 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol @@ -1,29 +1,26 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; -import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {PolygonScript} from 'aave-helpers/ScriptUtils.sol'; import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; import {AaveV2PolygonRatesUpdates_20230614} from 'src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol'; -contract DeployPolygonV2RatesUpdatesPayload is EthereumScript { +contract DeployPolygonV2RatesUpdatesPayload is PolygonScript { function run() external broadcast { new AaveV2PolygonRatesUpdates_20230614(); } } -contract PolygonV2RatesUpdatesPayloadProposal is EthereumScript { +contract PolygonV2RatesUpdatesPayloadProposal is PolygonScript { function run() external broadcast { GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](1); payloads[0] = GovHelpers.buildPolygon( - address(0) // TODO: Replace by actual payload + 0x0cbdB61E8E22cdFA8684935c87b4a8286EC59967 ); GovHelpers.createProposal( payloads, GovHelpers.ipfsHashFile( vm, - 'src/AaveV2PolygonRatesUpdates_20230614/TODO.md', - // if you set `upload` to `true`, your env must contain PINATA_KEY & PINATA_SECRET - // the file will be uploaded automatically once merged to main - true + 'src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md' ) ); } diff --git a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md new file mode 100644 index 00000000..d8bc4738 --- /dev/null +++ b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md @@ -0,0 +1,72 @@ +--- +title: Polygon v2 - Parameter Update +author: TokenLogic +discussions: https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817 +shortDescription: Encourage Polygon v2 users to migrate to v3 by updating Uoptimal, Reserve Factor and Slope2 paramters on Polygon v2. +created: 2023-06-20 +--- + +# Simple Summary + +This AIP will update risk parameters on Polygon v2 to encourage users to migrate funds to v3. No users funds are at risk. + +# Abstract + +With SD, MaticX and stMATIC rewards being distributed across v3, Aave DAO can further encourage the migration of users to the safer v3 protocol. + +This will be achieved by updating the Uoptimal, Reserve Factor (RF) and Slope2 parameters. This is expected to increase borrowing rates, with deposit rates remaining unchanged. + +# Motivation + +Currently, there are two communities distributing three tokens across Polygon v3. + +* SD - Stader Labs +* MaticX & stMATIC - Polygon Foundation + +This has led to Polygon v3 offering better deposit rates relative to v2. The TVL on v3 is increasing, largely due to incentives and LSTs being added to the liquidity pool whilst v2's TVL remains more correlated to asset spot pricing. + +Liquidity Mining on v3 is encouraging users to migrate and this AIP will further encourage migration by holding v2 deposit rates constant and increasing v2 borrowing costs. + +The approach presented has successfully passed [TEMP CHECK](https://snapshot.org/#/aave.eth/proposal/0x478169c0840488588b31d7e23b889b5f9442057db9c7a5b9b6cfdd61fe7108ff) and [ARFC](https://snapshot.org/#/aave.eth/proposal/0x013f763e92d253926bc7f04d79138593a1b31c969a34db7f0955e46850c796d9) votes, with the community electing to migrate via Option 2, the conservative approach. + +This AIP contains revised parameter updates in line with the ARFC Snapshot methodology. The methodogoly applied has been reviewed by Chaos Labs and Gauntlet at the time the ARFC was voted on. + +# Specification + +The following parameters are to be updated: + +|Asset|Uoptimal|RF |Slope 2| +|---|---|---|---| +|DAI|71.00%|21.00%|105.00%| +|USDC|77.00%|23.00%|134.00%| +|USDT|52.00%|22.00%|236.00%| +|wBTC|37.00%|55.00%|536.00%| +|wETH|40.00%|45.00%|167.00%| +|MATIC|48.00%|41.00%|440.00%| +|BAL|65.00%|32.00%|236.00%| +|CRV|25.00%|38.00%|392.00%| +|GHST|23.00%|60.00%|413.00%| +|LINK|25.00%|50.00%|402.00%| + + +# Implementation + +A list of relevant links like for this proposal: + +* [Governance Forum Discussion](https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817) +* [Test Cases](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol) +* [Pre-Post Payload Diff](https://github.com/defijesus/aave-proposals/blob/main/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md) +* [Payload Implementation](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol) +* [Deployed Contracts](TODO) + +The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). + +# Disclaimer + +The author, TokenLogic, receives payment indirectly from [Aave Grant DAO](https://twitter.com/AaveGrants) via [Butter](https://twitter.com/butterymoney) as part of the [Incentivised Delegate Campaign](https://governance.aave.com/t/temp-check-incentivized-delegate-campaign-3-month/11732). [TokenLogic is a delegate](https://governance.aave.com/t/tokenlogic-delegate-platform/12516) within Aave community. + +Delegate: [0xA06c2e5BB33cd6718b08EC9335081Cbba62861f7](https://app.aave.com/governance/) + +# Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file From a75ce74d2524a5c6adbdc2970cfd914bd62af6a3 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 15:33:14 +0100 Subject: [PATCH 05/16] quick fixes to .md --- .../POLYGON_V2_PARAMETER_UPDATES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md index d8bc4738..7defd480 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md +++ b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md @@ -2,7 +2,7 @@ title: Polygon v2 - Parameter Update author: TokenLogic discussions: https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817 -shortDescription: Encourage Polygon v2 users to migrate to v3 by updating Uoptimal, Reserve Factor and Slope2 paramters on Polygon v2. +shortDescription: Encourage Polygon v2 users to migrate to v3 created: 2023-06-20 --- @@ -57,7 +57,7 @@ A list of relevant links like for this proposal: * [Test Cases](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol) * [Pre-Post Payload Diff](https://github.com/defijesus/aave-proposals/blob/main/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md) * [Payload Implementation](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol) -* [Deployed Contracts](TODO) +* [Deployed Contracts](https://polygonscan.com/address/0x0cbdb61e8e22cdfa8684935c87b4a8286ec59967#code) The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). From e5c458eb5947d4ed9850f261e8e771dc83efe059 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 16:29:08 +0100 Subject: [PATCH 06/16] fix review issues --- .../AaveV2PolygonRatesUpdates_20230614.sol | 7 ++++--- .../AaveV2PolygonRatesUpdates_20230614.t.sol | 8 ++++---- .../DeployPolygonRatesUpdates.s.sol | 2 +- .../POLYGON_V2_PARAMETER_UPDATES.md | 3 +-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol index e5b285f5..cc50feb7 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol @@ -23,9 +23,10 @@ import 'aave-helpers/v2-config-engine/AaveV2PayloadPolygon.sol'; import {AaveV2Polygon, AaveV2PolygonAssets, ILendingPoolConfigurator} from 'aave-address-book/AaveV2Polygon.sol'; /** - * @dev Smart contract for a mock rates update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs + * @dev Encourage Polygon v2 users to migrate to v3 by updating Uoptimal, Reserve Factor and Slope2 paramters on Polygon v2. + * @author defijesus.eth - TokenLogic + * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x013f763e92d253926bc7f04d79138593a1b31c969a34db7f0955e46850c796d9 + * - Discussion: https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817 */ contract AaveV2PolygonRatesUpdates_20230614 is AaveV2PayloadPolygon { diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol index b3ac1762..0948c99a 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -10,7 +10,7 @@ import {AaveV2PolygonRatesUpdates_20230614} from './AaveV2PolygonRatesUpdates_20 contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWithExecutor { function setUp() public { - vm.createSelectFork(vm.rpcUrl('polygon'), 43979799); + vm.createSelectFork(vm.rpcUrl('polygon'), 43981679); _selectPayloadExecutor(AaveGovernanceV2.POLYGON_BRIDGE_EXECUTOR); } @@ -21,14 +21,14 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith AaveV2Polygon.POOL ); - _executePayload(0x0cbdB61E8E22cdFA8684935c87b4a8286EC59967); + _executePayload(0xBBD2B7418395d1782f0016095C6A26487d184873); ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'proTestPolygonUpdate20230614', + 'posTestPolygonUpdate20230614', AaveV2Polygon.POOL ); - diffReports('preTestPolygonUpdate20230614', 'proTestPolygonUpdate20230614'); + diffReports('preTestPolygonUpdate20230614', 'posTestPolygonUpdate20230614'); address[] memory assetsChanged = new address[](10); assetsChanged[0] = AaveV2PolygonAssets.DAI_UNDERLYING; diff --git a/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol index 5e235cb2..115c42e7 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/DeployPolygonRatesUpdates.s.sol @@ -14,7 +14,7 @@ contract PolygonV2RatesUpdatesPayloadProposal is PolygonScript { function run() external broadcast { GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](1); payloads[0] = GovHelpers.buildPolygon( - 0x0cbdB61E8E22cdFA8684935c87b4a8286EC59967 + 0xBBD2B7418395d1782f0016095C6A26487d184873 ); GovHelpers.createProposal( payloads, diff --git a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md index 7defd480..50217a61 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md +++ b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md @@ -3,7 +3,6 @@ title: Polygon v2 - Parameter Update author: TokenLogic discussions: https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817 shortDescription: Encourage Polygon v2 users to migrate to v3 -created: 2023-06-20 --- # Simple Summary @@ -57,7 +56,7 @@ A list of relevant links like for this proposal: * [Test Cases](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol) * [Pre-Post Payload Diff](https://github.com/defijesus/aave-proposals/blob/main/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md) * [Payload Implementation](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol) -* [Deployed Contracts](https://polygonscan.com/address/0x0cbdb61e8e22cdfa8684935c87b4a8286ec59967#code) +* [Deployed Contracts](https://polygonscan.com/address/0xbbd2b7418395d1782f0016095c6a26487d184873#code) The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). From eecd3c37045d6ed1f23e543417eaa9c75f84bbe7 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 16:37:46 +0100 Subject: [PATCH 07/16] fix: remove unneeded config fetching remove old diffs, fix typo in test, add new diff --- ...PolygonUpdate20230614_postTestPolygonUpdate20230614.md} | 0 .../AaveV2PolygonRatesUpdates_20230614.t.sol | 7 +++---- 2 files changed, 3 insertions(+), 4 deletions(-) rename diffs/{preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md => preTestPolygonUpdate20230614_postTestPolygonUpdate20230614.md} (100%) diff --git a/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md b/diffs/preTestPolygonUpdate20230614_postTestPolygonUpdate20230614.md similarity index 100% rename from diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md rename to diffs/preTestPolygonUpdate20230614_postTestPolygonUpdate20230614.md diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol index 0948c99a..07b22dec 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -24,11 +24,11 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith _executePayload(0xBBD2B7418395d1782f0016095C6A26487d184873); ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'posTestPolygonUpdate20230614', + 'postTestPolygonUpdate20230614', AaveV2Polygon.POOL ); - diffReports('preTestPolygonUpdate20230614', 'posTestPolygonUpdate20230614'); + diffReports('preTestPolygonUpdate20230614', 'postTestPolygonUpdate20230614'); address[] memory assetsChanged = new address[](10); assetsChanged[0] = AaveV2PolygonAssets.DAI_UNDERLYING; @@ -45,7 +45,6 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith _noReservesConfigsChangesApartFrom(allConfigsBefore, allConfigsAfter, assetsChanged); - ReserveConfig[] memory configs = _getReservesConfigs(AaveV2Polygon.POOL); for (uint i = 0; i < assetsChanged.length; i++) { if ( assetsChanged[i] == AaveV2PolygonAssets.BAL_UNDERLYING || @@ -55,7 +54,7 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith ) { continue; } - ReserveConfig memory cfg = _findReserveConfig(configs, assetsChanged[i]); + ReserveConfig memory cfg = _findReserveConfig(allConfigsAfter, assetsChanged[i]); _deposit(cfg, AaveV2Polygon.POOL, address(42), 100); } } From 504bdc49f5df82ff4e49fa6fa9a65b780e6a384c Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 16:44:50 +0100 Subject: [PATCH 08/16] ensure payload address is the implemented payload before passing address --- .../AaveV2PolygonRatesUpdates_20230614.t.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol index 07b22dec..3a0f3118 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol +++ b/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol @@ -21,7 +21,9 @@ contract AaveV2PolygonRatesUpdates_20230614_Test is ProtocolV2TestBase, TestWith AaveV2Polygon.POOL ); - _executePayload(0xBBD2B7418395d1782f0016095C6A26487d184873); + AaveV2PolygonRatesUpdates_20230614 payload = AaveV2PolygonRatesUpdates_20230614(0xBBD2B7418395d1782f0016095C6A26487d184873); + + _executePayload(address(payload)); ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( 'postTestPolygonUpdate20230614', From 1c31a5774909d583117707150cb3e09a5f4940a7 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 16 Jun 2023 17:03:33 +0100 Subject: [PATCH 09/16] fix typo in .md --- .../POLYGON_V2_PARAMETER_UPDATES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md index 50217a61..6991253c 100644 --- a/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md +++ b/src/AaveV2PolygonRatesUpdates_20230614/POLYGON_V2_PARAMETER_UPDATES.md @@ -54,7 +54,7 @@ A list of relevant links like for this proposal: * [Governance Forum Discussion](https://governance.aave.com/t/arfc-polygon-v2-parameter-update/12817) * [Test Cases](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.t.sol) -* [Pre-Post Payload Diff](https://github.com/defijesus/aave-proposals/blob/main/diffs/preTestPolygonUpdate20230614_proTestPolygonUpdate20230614.md) +* [Pre-Post Payload Diff](https://github.com/defijesus/aave-proposals/blob/main/diffs/preTestPolygonUpdate20230614_postTestPolygonUpdate20230614.md) * [Payload Implementation](https://github.com/defijesus/aave-proposals/blob/main/src/AaveV2PolygonRatesUpdates_20230614/AaveV2PolygonRatesUpdates_20230614.sol) * [Deployed Contracts](https://polygonscan.com/address/0xbbd2b7418395d1782f0016095c6a26487d184873#code) From ef7e0af6780c0f81ef344081770dcc16b1e3f3fc Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Wed, 16 Aug 2023 13:51:13 +0100 Subject: [PATCH 10/16] update aave-address-book --- lib/aave-address-book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aave-address-book b/lib/aave-address-book index 8540f5f4..b87a51d0 160000 --- a/lib/aave-address-book +++ b/lib/aave-address-book @@ -1 +1 @@ -Subproject commit 8540f5f4e85efaa8c8918f01673171afdbe6d9c5 +Subproject commit b87a51d014167effaaa7f6f7e33562b223b3d6b2 From 6c3ee0402d888fc5640ec697cefe803e4219f6ce Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Tue, 19 Sep 2023 02:01:30 +0100 Subject: [PATCH 11/16] a lot to do --- ...aveAvalancheTreasuryMigration_20230903.sol | 85 +++++++++++++++++++ ...eAvalancheTreasuryMigration_20230903.t.sol | 64 ++++++++++++++ .../DeployTreasuryMigration.s.sol | 15 ++++ ...E_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 62 ++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol new file mode 100644 index 00000000..ed7ceef5 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: MIT + +/* + _ ΞΞΞΞ _ + /_;-.__ / _\ _.-;_\ + `-._`'`_/'`.-' + `\ /` + | / + /-.( + \_._\ + \ \`; + > |/ + / // + |// + \(\ + `` + defijesus.eth +*/ + +pragma solidity ^0.8.0; + +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; +import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; +import {IMigrationHelper} from 'aave-address-book/common/IMigrationHelper.sol'; + +/** + * @dev Redeem aTokens from Aave v2 Avalanche and deposit the underlying assets into Aave v3 Avalanche. + * @author defijesus.eth - TokenLogic + * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882 + * - Discussion: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 + */ +contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { + + function execute() external { + IMigrationHelper MIGRATION_HELPER = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); + + address[] memory ASSETS_TO_MIGRATE = new address[](6); + ASSETS_TO_MIGRATE[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; + ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; + ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; + ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + ASSETS_TO_MIGRATE[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + ASSETS_TO_MIGRATE[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + + IMigrationHelper.RepaySimpleInput[] memory POSITIONS_TO_REPAY = new IMigrationHelper.RepaySimpleInput[](0); + IMigrationHelper.PermitInput[] memory PERMITS = new IMigrationHelper.PermitInput[](0); + IMigrationHelper.CreditDelegationInput[] memory CREDIT_DELEGATION_PERMITS = new IMigrationHelper.CreditDelegationInput[](0); + + uint256 i = 0; + + for(;i < ASSETS_TO_MIGRATE.length;) { + address aToken = MIGRATION_HELPER.aTokens(ASSETS_TO_MIGRATE[i]); + uint256 amount = IERC20(aToken).balanceOf(address(AaveV2Avalanche.COLLECTOR)); + AaveV2Avalanche.COLLECTOR.transfer(aToken, address(this), amount); + SafeERC20.forceApprove(IERC20(aToken), AaveV2Avalanche.MIGRATION_HELPER, amount); + unchecked { + i++; + } + } + + MIGRATION_HELPER.migrate(ASSETS_TO_MIGRATE, POSITIONS_TO_REPAY, PERMITS, CREDIT_DELEGATION_PERMITS); + + address[] memory NEW_ASSETS_MIGRATED = new address[](6); + NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_UNDERLYING; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + + for(i = 0; i < NEW_ASSETS_MIGRATED.length;) { + SafeERC20.safeTransfer( + IERC20(NEW_ASSETS_MIGRATED[i]), + address(AaveV3Avalanche.COLLECTOR), + IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(this)) + ); + unchecked { + i++; + } + } + } +} \ No newline at end of file diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol new file mode 100644 index 00000000..557a3d05 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; + +import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; +import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; +import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; +import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; + +contract AaveAvalancheTreasuryMigration_20230903_Test is Test { + function setUp() public { + vm.createSelectFork(vm.rpcUrl('avalanche'), 35177276); + } + + function testPayload() public { + address[] memory OLD_ASSETS_MIGRATED = new address[](6); + OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; + OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; + OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; + OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + OLD_ASSETS_MIGRATED[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + OLD_ASSETS_MIGRATED[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + + address[] memory NEW_ASSETS_MIGRATED = new address[](6); + NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_A_TOKEN; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + + uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](6); + uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](6); + + uint256 i = 0; + uint256 payloadBalanceAfter; + uint256 collectorBalanceAfter; + + for(; i < NEW_ASSETS_MIGRATED.length; i++) { + NEW_ASSETS_BEFORE_BALANCE[i] = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + OLD_ASSETS_BEFORE_BALANCE[i] = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); + } + + AaveAvalancheTreasuryMigration_20230903 payload = new AaveAvalancheTreasuryMigration_20230903(); + + GovHelpers.executePayload(vm, address(payload), AaveV3Avalanche.ACL_ADMIN); + + for(i = 0; i < OLD_ASSETS_MIGRATED.length; i++) { + payloadBalanceAfter = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(payload)); + assertEq(payloadBalanceAfter, 0); + } + + for(i = 0; i < NEW_ASSETS_MIGRATED.length; i++) { + payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); + assertEq(payloadBalanceAfter, 0); + collectorBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + /// 0.001e18 is 0.1% + assertApproxEqRel(NEW_ASSETS_BEFORE_BALANCE[i] + OLD_ASSETS_BEFORE_BALANCE[i], collectorBalanceAfter, 0.001e18); + } + } +} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol b/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol new file mode 100644 index 00000000..f89c5535 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.16; +import {AvalancheScript, EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; +import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; + +/** + * @dev Deploy AaveAvalancheTreasuryMigration_20230903 + * command: make deploy-ledger contract=src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol:DeployAvalancheV2TreasuryMigrationPayload chain=avalanche + */ +contract DeployAvalancheV2TreasuryMigrationPayload is AvalancheScript { + function run() external broadcast { + new AaveAvalancheTreasuryMigration_20230903(); + } +} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md new file mode 100644 index 00000000..dc276b0c --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md @@ -0,0 +1,62 @@ +--- +title: Treasury Management - Polygon v2 to v3 Migration +discussions: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 +author: TokenLogic +--- + +# Summary + +This AIP shall redeem aTokens from Aave v2 Polygon and deposit the underlying assets into Aave v3 Polygon. + +# Motivation + +On Polygon, Aave DAO is currently holding funds on the Aave v2 deployment and also some small unproductive allocations within the Treasury. This AIP will improve DAOs Treasury performance by improving the overall capital efficiency and yield being generated. + +As part of broader v2 to v3 migration effort, this AIP shall implement the following: +* Redeem Assets from Aave v2 +* Deposit Assets from Aave v2 into v3 + +* Deposit Assets held in Treasury into Aave v3 + +For reference, the Aave Polygon Treasury: [`0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383`](https://polygonscan.com/address/0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383) + +# Specification + +Transfer the following assets from Aave v2 to v3. The quantities in this table will change over time between proposal submission & proposal execution, and should not be taken as exact. + +|Network|Instance|Token|Quantity| +|---|---|---|---| +|Polygon|Aave V2|AMUSDC|3,775,623.68| +|Polygon|Aave V2|AMDAI|3,380,138.80| +|Polygon|Aave V2|AMUSDT|1,379,093.97| +|Polygon|Aave V2|AMWETH|230.91| +|Polygon|Aave V2|AMWMATIC|106,528.66| +|Polygon|Aave V2|AMBAL|1,336.76| +|Polygon|Aave V2|AMCRV|9,404.00| +|Polygon|Aave V2|AMWBTC|0.09| +|Polygon|Aave V2|AMGHST|1,918.59| +|Polygon|Aave V2|AMLINK|33.56| + +# Implementation + +A list of relevant links like for this proposal: + +* [Governance Forum Discussion](https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248) + +* [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882) + +* [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.t.sol) + +* [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.sol) + +* [Deployed Contracts](https://polygonscan.com/address/0xc34a9391c08b64c4a9167d9e1e884b3735ce21b0#code) + +The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). + +# Disclaimer + +TokenLogic receives no payment from Aave DAO or any external source for the creation of this proposal. TokenLogic is a delegate within the Aave ecosystem. + +# Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file From b6b1c17bdf19293d54df5f127ea60395defd44c8 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Tue, 19 Sep 2023 02:01:56 +0100 Subject: [PATCH 12/16] Revert "a lot to do" This reverts commit 6c3ee0402d888fc5640ec697cefe803e4219f6ce. --- ...aveAvalancheTreasuryMigration_20230903.sol | 85 ------------------- ...eAvalancheTreasuryMigration_20230903.t.sol | 64 -------------- .../DeployTreasuryMigration.s.sol | 15 ---- ...E_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 62 -------------- 4 files changed, 226 deletions(-) delete mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol delete mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol delete mode 100644 src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol delete mode 100644 src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol deleted file mode 100644 index ed7ceef5..00000000 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: MIT - -/* - _ ΞΞΞΞ _ - /_;-.__ / _\ _.-;_\ - `-._`'`_/'`.-' - `\ /` - | / - /-.( - \_._\ - \ \`; - > |/ - / // - |// - \(\ - `` - defijesus.eth -*/ - -pragma solidity ^0.8.0; - -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; -import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; -import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; -import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; -import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; -import {IMigrationHelper} from 'aave-address-book/common/IMigrationHelper.sol'; - -/** - * @dev Redeem aTokens from Aave v2 Avalanche and deposit the underlying assets into Aave v3 Avalanche. - * @author defijesus.eth - TokenLogic - * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882 - * - Discussion: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 - */ -contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { - - function execute() external { - IMigrationHelper MIGRATION_HELPER = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); - - address[] memory ASSETS_TO_MIGRATE = new address[](6); - ASSETS_TO_MIGRATE[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; - ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; - ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; - ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; - ASSETS_TO_MIGRATE[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; - ASSETS_TO_MIGRATE[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; - - IMigrationHelper.RepaySimpleInput[] memory POSITIONS_TO_REPAY = new IMigrationHelper.RepaySimpleInput[](0); - IMigrationHelper.PermitInput[] memory PERMITS = new IMigrationHelper.PermitInput[](0); - IMigrationHelper.CreditDelegationInput[] memory CREDIT_DELEGATION_PERMITS = new IMigrationHelper.CreditDelegationInput[](0); - - uint256 i = 0; - - for(;i < ASSETS_TO_MIGRATE.length;) { - address aToken = MIGRATION_HELPER.aTokens(ASSETS_TO_MIGRATE[i]); - uint256 amount = IERC20(aToken).balanceOf(address(AaveV2Avalanche.COLLECTOR)); - AaveV2Avalanche.COLLECTOR.transfer(aToken, address(this), amount); - SafeERC20.forceApprove(IERC20(aToken), AaveV2Avalanche.MIGRATION_HELPER, amount); - unchecked { - i++; - } - } - - MIGRATION_HELPER.migrate(ASSETS_TO_MIGRATE, POSITIONS_TO_REPAY, PERMITS, CREDIT_DELEGATION_PERMITS); - - address[] memory NEW_ASSETS_MIGRATED = new address[](6); - NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_UNDERLYING; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; - - for(i = 0; i < NEW_ASSETS_MIGRATED.length;) { - SafeERC20.safeTransfer( - IERC20(NEW_ASSETS_MIGRATED[i]), - address(AaveV3Avalanche.COLLECTOR), - IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(this)) - ); - unchecked { - i++; - } - } - } -} \ No newline at end of file diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol deleted file mode 100644 index 557a3d05..00000000 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import 'forge-std/Test.sol'; - -import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; -import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; -import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; -import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; -import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; -import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; - -contract AaveAvalancheTreasuryMigration_20230903_Test is Test { - function setUp() public { - vm.createSelectFork(vm.rpcUrl('avalanche'), 35177276); - } - - function testPayload() public { - address[] memory OLD_ASSETS_MIGRATED = new address[](6); - OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; - OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; - OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; - OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; - OLD_ASSETS_MIGRATED[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; - OLD_ASSETS_MIGRATED[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; - - address[] memory NEW_ASSETS_MIGRATED = new address[](6); - NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_A_TOKEN; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; - - uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](6); - uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](6); - - uint256 i = 0; - uint256 payloadBalanceAfter; - uint256 collectorBalanceAfter; - - for(; i < NEW_ASSETS_MIGRATED.length; i++) { - NEW_ASSETS_BEFORE_BALANCE[i] = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); - OLD_ASSETS_BEFORE_BALANCE[i] = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); - } - - AaveAvalancheTreasuryMigration_20230903 payload = new AaveAvalancheTreasuryMigration_20230903(); - - GovHelpers.executePayload(vm, address(payload), AaveV3Avalanche.ACL_ADMIN); - - for(i = 0; i < OLD_ASSETS_MIGRATED.length; i++) { - payloadBalanceAfter = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(payload)); - assertEq(payloadBalanceAfter, 0); - } - - for(i = 0; i < NEW_ASSETS_MIGRATED.length; i++) { - payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); - assertEq(payloadBalanceAfter, 0); - collectorBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); - /// 0.001e18 is 0.1% - assertApproxEqRel(NEW_ASSETS_BEFORE_BALANCE[i] + OLD_ASSETS_BEFORE_BALANCE[i], collectorBalanceAfter, 0.001e18); - } - } -} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol b/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol deleted file mode 100644 index f89c5535..00000000 --- a/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.16; -import {AvalancheScript, EthereumScript} from 'aave-helpers/ScriptUtils.sol'; -import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; -import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; - -/** - * @dev Deploy AaveAvalancheTreasuryMigration_20230903 - * command: make deploy-ledger contract=src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol:DeployAvalancheV2TreasuryMigrationPayload chain=avalanche - */ -contract DeployAvalancheV2TreasuryMigrationPayload is AvalancheScript { - function run() external broadcast { - new AaveAvalancheTreasuryMigration_20230903(); - } -} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md deleted file mode 100644 index dc276b0c..00000000 --- a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Treasury Management - Polygon v2 to v3 Migration -discussions: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 -author: TokenLogic ---- - -# Summary - -This AIP shall redeem aTokens from Aave v2 Polygon and deposit the underlying assets into Aave v3 Polygon. - -# Motivation - -On Polygon, Aave DAO is currently holding funds on the Aave v2 deployment and also some small unproductive allocations within the Treasury. This AIP will improve DAOs Treasury performance by improving the overall capital efficiency and yield being generated. - -As part of broader v2 to v3 migration effort, this AIP shall implement the following: -* Redeem Assets from Aave v2 -* Deposit Assets from Aave v2 into v3 - -* Deposit Assets held in Treasury into Aave v3 - -For reference, the Aave Polygon Treasury: [`0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383`](https://polygonscan.com/address/0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383) - -# Specification - -Transfer the following assets from Aave v2 to v3. The quantities in this table will change over time between proposal submission & proposal execution, and should not be taken as exact. - -|Network|Instance|Token|Quantity| -|---|---|---|---| -|Polygon|Aave V2|AMUSDC|3,775,623.68| -|Polygon|Aave V2|AMDAI|3,380,138.80| -|Polygon|Aave V2|AMUSDT|1,379,093.97| -|Polygon|Aave V2|AMWETH|230.91| -|Polygon|Aave V2|AMWMATIC|106,528.66| -|Polygon|Aave V2|AMBAL|1,336.76| -|Polygon|Aave V2|AMCRV|9,404.00| -|Polygon|Aave V2|AMWBTC|0.09| -|Polygon|Aave V2|AMGHST|1,918.59| -|Polygon|Aave V2|AMLINK|33.56| - -# Implementation - -A list of relevant links like for this proposal: - -* [Governance Forum Discussion](https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248) - -* [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882) - -* [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.t.sol) - -* [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.sol) - -* [Deployed Contracts](https://polygonscan.com/address/0xc34a9391c08b64c4a9167d9e1e884b3735ce21b0#code) - -The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). - -# Disclaimer - -TokenLogic receives no payment from Aave DAO or any external source for the creation of this proposal. TokenLogic is a delegate within the Aave ecosystem. - -# Copyright - -Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file From dcc75f60e18f41fa28970a825ef0838cce64b142 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Tue, 19 Sep 2023 02:05:50 +0100 Subject: [PATCH 13/16] a lot to do --- ...aveAvalancheTreasuryMigration_20230903.sol | 85 +++++++++++++++++++ ...eAvalancheTreasuryMigration_20230903.t.sol | 64 ++++++++++++++ .../DeployTreasuryMigration.s.sol | 15 ++++ ...E_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 62 ++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol create mode 100644 src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol new file mode 100644 index 00000000..ed7ceef5 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: MIT + +/* + _ ΞΞΞΞ _ + /_;-.__ / _\ _.-;_\ + `-._`'`_/'`.-' + `\ /` + | / + /-.( + \_._\ + \ \`; + > |/ + / // + |// + \(\ + `` + defijesus.eth +*/ + +pragma solidity ^0.8.0; + +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; +import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; +import {IMigrationHelper} from 'aave-address-book/common/IMigrationHelper.sol'; + +/** + * @dev Redeem aTokens from Aave v2 Avalanche and deposit the underlying assets into Aave v3 Avalanche. + * @author defijesus.eth - TokenLogic + * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882 + * - Discussion: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 + */ +contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { + + function execute() external { + IMigrationHelper MIGRATION_HELPER = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); + + address[] memory ASSETS_TO_MIGRATE = new address[](6); + ASSETS_TO_MIGRATE[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; + ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; + ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; + ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + ASSETS_TO_MIGRATE[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + ASSETS_TO_MIGRATE[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + + IMigrationHelper.RepaySimpleInput[] memory POSITIONS_TO_REPAY = new IMigrationHelper.RepaySimpleInput[](0); + IMigrationHelper.PermitInput[] memory PERMITS = new IMigrationHelper.PermitInput[](0); + IMigrationHelper.CreditDelegationInput[] memory CREDIT_DELEGATION_PERMITS = new IMigrationHelper.CreditDelegationInput[](0); + + uint256 i = 0; + + for(;i < ASSETS_TO_MIGRATE.length;) { + address aToken = MIGRATION_HELPER.aTokens(ASSETS_TO_MIGRATE[i]); + uint256 amount = IERC20(aToken).balanceOf(address(AaveV2Avalanche.COLLECTOR)); + AaveV2Avalanche.COLLECTOR.transfer(aToken, address(this), amount); + SafeERC20.forceApprove(IERC20(aToken), AaveV2Avalanche.MIGRATION_HELPER, amount); + unchecked { + i++; + } + } + + MIGRATION_HELPER.migrate(ASSETS_TO_MIGRATE, POSITIONS_TO_REPAY, PERMITS, CREDIT_DELEGATION_PERMITS); + + address[] memory NEW_ASSETS_MIGRATED = new address[](6); + NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_UNDERLYING; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + + for(i = 0; i < NEW_ASSETS_MIGRATED.length;) { + SafeERC20.safeTransfer( + IERC20(NEW_ASSETS_MIGRATED[i]), + address(AaveV3Avalanche.COLLECTOR), + IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(this)) + ); + unchecked { + i++; + } + } + } +} \ No newline at end of file diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol new file mode 100644 index 00000000..557a3d05 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; + +import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; +import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; +import {AaveV2Avalanche, AaveV2AvalancheAssets} from 'aave-address-book/AaveV2Avalanche.sol'; +import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; + +contract AaveAvalancheTreasuryMigration_20230903_Test is Test { + function setUp() public { + vm.createSelectFork(vm.rpcUrl('avalanche'), 35177276); + } + + function testPayload() public { + address[] memory OLD_ASSETS_MIGRATED = new address[](6); + OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; + OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; + OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; + OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + OLD_ASSETS_MIGRATED[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + OLD_ASSETS_MIGRATED[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + + address[] memory NEW_ASSETS_MIGRATED = new address[](6); + NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_A_TOKEN; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + + uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](6); + uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](6); + + uint256 i = 0; + uint256 payloadBalanceAfter; + uint256 collectorBalanceAfter; + + for(; i < NEW_ASSETS_MIGRATED.length; i++) { + NEW_ASSETS_BEFORE_BALANCE[i] = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + OLD_ASSETS_BEFORE_BALANCE[i] = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); + } + + AaveAvalancheTreasuryMigration_20230903 payload = new AaveAvalancheTreasuryMigration_20230903(); + + GovHelpers.executePayload(vm, address(payload), AaveV3Avalanche.ACL_ADMIN); + + for(i = 0; i < OLD_ASSETS_MIGRATED.length; i++) { + payloadBalanceAfter = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(payload)); + assertEq(payloadBalanceAfter, 0); + } + + for(i = 0; i < NEW_ASSETS_MIGRATED.length; i++) { + payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); + assertEq(payloadBalanceAfter, 0); + collectorBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + /// 0.001e18 is 0.1% + assertApproxEqRel(NEW_ASSETS_BEFORE_BALANCE[i] + OLD_ASSETS_BEFORE_BALANCE[i], collectorBalanceAfter, 0.001e18); + } + } +} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol b/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol new file mode 100644 index 00000000..f89c5535 --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.16; +import {AvalancheScript, EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {GovHelpers} from 'aave-helpers/GovHelpers.sol'; +import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMigration_20230903.sol'; + +/** + * @dev Deploy AaveAvalancheTreasuryMigration_20230903 + * command: make deploy-ledger contract=src/AaveAvalancheTreasuryMigration_20230903/DeployTreasuryMigration.s.sol:DeployAvalancheV2TreasuryMigrationPayload chain=avalanche + */ +contract DeployAvalancheV2TreasuryMigrationPayload is AvalancheScript { + function run() external broadcast { + new AaveAvalancheTreasuryMigration_20230903(); + } +} diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md new file mode 100644 index 00000000..dc276b0c --- /dev/null +++ b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md @@ -0,0 +1,62 @@ +--- +title: Treasury Management - Polygon v2 to v3 Migration +discussions: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 +author: TokenLogic +--- + +# Summary + +This AIP shall redeem aTokens from Aave v2 Polygon and deposit the underlying assets into Aave v3 Polygon. + +# Motivation + +On Polygon, Aave DAO is currently holding funds on the Aave v2 deployment and also some small unproductive allocations within the Treasury. This AIP will improve DAOs Treasury performance by improving the overall capital efficiency and yield being generated. + +As part of broader v2 to v3 migration effort, this AIP shall implement the following: +* Redeem Assets from Aave v2 +* Deposit Assets from Aave v2 into v3 + +* Deposit Assets held in Treasury into Aave v3 + +For reference, the Aave Polygon Treasury: [`0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383`](https://polygonscan.com/address/0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383) + +# Specification + +Transfer the following assets from Aave v2 to v3. The quantities in this table will change over time between proposal submission & proposal execution, and should not be taken as exact. + +|Network|Instance|Token|Quantity| +|---|---|---|---| +|Polygon|Aave V2|AMUSDC|3,775,623.68| +|Polygon|Aave V2|AMDAI|3,380,138.80| +|Polygon|Aave V2|AMUSDT|1,379,093.97| +|Polygon|Aave V2|AMWETH|230.91| +|Polygon|Aave V2|AMWMATIC|106,528.66| +|Polygon|Aave V2|AMBAL|1,336.76| +|Polygon|Aave V2|AMCRV|9,404.00| +|Polygon|Aave V2|AMWBTC|0.09| +|Polygon|Aave V2|AMGHST|1,918.59| +|Polygon|Aave V2|AMLINK|33.56| + +# Implementation + +A list of relevant links like for this proposal: + +* [Governance Forum Discussion](https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248) + +* [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882) + +* [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.t.sol) + +* [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.sol) + +* [Deployed Contracts](https://polygonscan.com/address/0xc34a9391c08b64c4a9167d9e1e884b3735ce21b0#code) + +The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). + +# Disclaimer + +TokenLogic receives no payment from Aave DAO or any external source for the creation of this proposal. TokenLogic is a delegate within the Aave ecosystem. + +# Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file From a40cd213e2d6312316d4e81fb9c4c73c0d93a17e Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Thu, 21 Sep 2023 00:20:26 +0100 Subject: [PATCH 14/16] stop migrating some assets. fix issues raised in review. ready for review --- ...aveAvalancheTreasuryMigration_20230903.sol | 20 +++---- ...eAvalancheTreasuryMigration_20230903.t.sol | 32 +++++------ ...E_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 56 ++++++++----------- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol index ed7ceef5..a168f984 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol @@ -37,13 +37,11 @@ contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { function execute() external { IMigrationHelper MIGRATION_HELPER = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); - address[] memory ASSETS_TO_MIGRATE = new address[](6); + address[] memory ASSETS_TO_MIGRATE = new address[](4); ASSETS_TO_MIGRATE[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; - ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; - ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; - ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; - ASSETS_TO_MIGRATE[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; - ASSETS_TO_MIGRATE[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; IMigrationHelper.RepaySimpleInput[] memory POSITIONS_TO_REPAY = new IMigrationHelper.RepaySimpleInput[](0); IMigrationHelper.PermitInput[] memory PERMITS = new IMigrationHelper.PermitInput[](0); @@ -63,13 +61,11 @@ contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { MIGRATION_HELPER.migrate(ASSETS_TO_MIGRATE, POSITIONS_TO_REPAY, PERMITS, CREDIT_DELEGATION_PERMITS); - address[] memory NEW_ASSETS_MIGRATED = new address[](6); + address[] memory NEW_ASSETS_MIGRATED = new address[](4); NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_UNDERLYING; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; for(i = 0; i < NEW_ASSETS_MIGRATED.length;) { SafeERC20.safeTransfer( diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol index 557a3d05..e2bd4a23 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol @@ -12,28 +12,24 @@ import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMi contract AaveAvalancheTreasuryMigration_20230903_Test is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('avalanche'), 35177276); + vm.createSelectFork(vm.rpcUrl('avalanche'), 35447142); } function testPayload() public { - address[] memory OLD_ASSETS_MIGRATED = new address[](6); - OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; - OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.USDCe_UNDERLYING; - OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.USDTe_UNDERLYING; - OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; - OLD_ASSETS_MIGRATED[4] = AaveV2AvalancheAssets.WETHe_UNDERLYING; - OLD_ASSETS_MIGRATED[5] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + address[] memory OLD_ASSETS_MIGRATED = new address[](4); + OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_A_TOKEN; + OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.WBTCe_A_TOKEN; + OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.WETHe_A_TOKEN; + OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WAVAX_A_TOKEN; - address[] memory NEW_ASSETS_MIGRATED = new address[](6); + address[] memory NEW_ASSETS_MIGRATED = new address[](4); NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.USDC_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.USDt_A_TOKEN; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[4] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[5] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; - uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](6); - uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](6); + uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](4); + uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](4); uint256 i = 0; uint256 payloadBalanceAfter; @@ -51,11 +47,11 @@ contract AaveAvalancheTreasuryMigration_20230903_Test is Test { for(i = 0; i < OLD_ASSETS_MIGRATED.length; i++) { payloadBalanceAfter = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(payload)); assertEq(payloadBalanceAfter, 0); + payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); + assertEq(payloadBalanceAfter, 0); } for(i = 0; i < NEW_ASSETS_MIGRATED.length; i++) { - payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); - assertEq(payloadBalanceAfter, 0); collectorBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); /// 0.001e18 is 0.1% assertApproxEqRel(NEW_ASSETS_BEFORE_BALANCE[i] + OLD_ASSETS_BEFORE_BALANCE[i], collectorBalanceAfter, 0.001e18); diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md index dc276b0c..9106844c 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md +++ b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md @@ -1,55 +1,47 @@ --- -title: Treasury Management - Polygon v2 to v3 Migration -discussions: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 +title: Treasury Management - Avalanche v2 to v3 Migration +discussions: https://governance.aave.com/t/arfc-treasury-management-avalanche-v2-to-v3-migration/14469 author: TokenLogic --- # Summary -This AIP shall redeem aTokens from Aave v2 Polygon and deposit the underlying assets into Aave v3 Polygon. +Redeem the Aave DAO funds on Aave v2 Avalanche and deposit underlying assets in Aave v3 Avalanche. # Motivation -On Polygon, Aave DAO is currently holding funds on the Aave v2 deployment and also some small unproductive allocations within the Treasury. This AIP will improve DAOs Treasury performance by improving the overall capital efficiency and yield being generated. +Aave DAO currently holds around $4.52M on Avalanche v2. There are several drivers for migrating Aave DAO's funds: -As part of broader v2 to v3 migration effort, this AIP shall implement the following: -* Redeem Assets from Aave v2 -* Deposit Assets from Aave v2 into v3 +* Higher deposit rates +* wAVAX incentives +* Encourage migration v2 to v3 -* Deposit Assets held in Treasury into Aave v3 - -For reference, the Aave Polygon Treasury: [`0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383`](https://polygonscan.com/address/0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383) +Most of these funds can be migrated to v3 with the exception of USDT. There is not enough liquidity to redeem the entire 541.51K of USDT. As a result, approximately 25% of the USDT will be redeemed and deposited into v3. # Specification -Transfer the following assets from Aave v2 to v3. The quantities in this table will change over time between proposal submission & proposal execution, and should not be taken as exact. - -|Network|Instance|Token|Quantity| -|---|---|---|---| -|Polygon|Aave V2|AMUSDC|3,775,623.68| -|Polygon|Aave V2|AMDAI|3,380,138.80| -|Polygon|Aave V2|AMUSDT|1,379,093.97| -|Polygon|Aave V2|AMWETH|230.91| -|Polygon|Aave V2|AMWMATIC|106,528.66| -|Polygon|Aave V2|AMBAL|1,336.76| -|Polygon|Aave V2|AMCRV|9,404.00| -|Polygon|Aave V2|AMWBTC|0.09| -|Polygon|Aave V2|AMGHST|1,918.59| -|Polygon|Aave V2|AMLINK|33.56| - -# Implementation +Migrate the following holdings: -A list of relevant links like for this proposal: +| Asset | Migrate (%) | +| --- | --- | +|wBTC.e|100| +|wETH.e|100| +|DAI.e|100| +|AVAX.e|100| -* [Governance Forum Discussion](https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248) +Deposit wAVAX held passively in the Treasury into Aave v3. -* [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882) +For reference, the Aave Avalanche v2 Treasury: [`0x5ba7fd868c40c16f7aDfAe6CF87121E13FC2F7a0`](https://snowtrace.io/address/0x5ba7fd868c40c16f7aDfAe6CF87121E13FC2F7a0) -* [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.t.sol) +# Implementation -* [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AavePolygonTreasuryMigration_20230801/AavePolygonTreasuryMigration_20230801.sol) +A list of relevant links like for this proposal: -* [Deployed Contracts](https://polygonscan.com/address/0xc34a9391c08b64c4a9167d9e1e884b3735ce21b0#code) +* [Governance Forum Discussion](https://governance.aave.com/t/arfc-treasury-management-avalanche-v2-to-v3-migration/14469) +* [Snapshot vote](https://snapshot.org/#/aave.eth/proposal/0x0be8229173181fe0aaf5ed1883e53752546efb810e55610e7ac8b991155ab788) +* [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol) +* [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol) +* [Deployed Contracts](TODO) The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/). From 2b2880aa5af09cba61ac2532b58a526cbcaac356 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 22 Sep 2023 19:15:03 +0100 Subject: [PATCH 15/16] fix issues raised in review --- ...aveAvalancheTreasuryMigration_20230903.sol | 50 ++++++++--------- ...eAvalancheTreasuryMigration_20230903.t.sol | 55 +++++++++---------- ...E_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 2 - 3 files changed, 52 insertions(+), 55 deletions(-) diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol index a168f984..f046064f 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol @@ -29,52 +29,52 @@ import {IMigrationHelper} from 'aave-address-book/common/IMigrationHelper.sol'; /** * @dev Redeem aTokens from Aave v2 Avalanche and deposit the underlying assets into Aave v3 Avalanche. * @author defijesus.eth - TokenLogic - * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x1b816c12b6f547a1982198ffd0e36412390b05828b560c9edee4e8a6903c4882 - * - Discussion: https://governance.aave.com/t/arfc-migrate-consolidate-polygon-treasury/12248 + * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0xfe17ba406d90f8308794d14e8cad4f8d44c1f74e5589a5a106f9af17df916a59 + * - Discussion: https://governance.aave.com/t/arfc-treasury-management-avalanche-v2-to-v3-migration/14469 */ contract AaveAvalancheTreasuryMigration_20230903 is IProposalGenericExecutor { function execute() external { - IMigrationHelper MIGRATION_HELPER = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); + IMigrationHelper migrationHelper = IMigrationHelper(AaveV2Avalanche.MIGRATION_HELPER); - address[] memory ASSETS_TO_MIGRATE = new address[](4); - ASSETS_TO_MIGRATE[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; - ASSETS_TO_MIGRATE[1] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; - ASSETS_TO_MIGRATE[2] = AaveV2AvalancheAssets.WETHe_UNDERLYING; - ASSETS_TO_MIGRATE[3] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; + address[] memory assetsToMigrate = new address[](4); + assetsToMigrate[0] = AaveV2AvalancheAssets.DAIe_UNDERLYING; + assetsToMigrate[1] = AaveV2AvalancheAssets.WBTCe_UNDERLYING; + assetsToMigrate[2] = AaveV2AvalancheAssets.WETHe_UNDERLYING; + assetsToMigrate[3] = AaveV2AvalancheAssets.WAVAX_UNDERLYING; - IMigrationHelper.RepaySimpleInput[] memory POSITIONS_TO_REPAY = new IMigrationHelper.RepaySimpleInput[](0); - IMigrationHelper.PermitInput[] memory PERMITS = new IMigrationHelper.PermitInput[](0); - IMigrationHelper.CreditDelegationInput[] memory CREDIT_DELEGATION_PERMITS = new IMigrationHelper.CreditDelegationInput[](0); + IMigrationHelper.RepaySimpleInput[] memory positionsToRepay = new IMigrationHelper.RepaySimpleInput[](0); + IMigrationHelper.PermitInput[] memory permits = new IMigrationHelper.PermitInput[](0); + IMigrationHelper.CreditDelegationInput[] memory creditDelegationPermits = new IMigrationHelper.CreditDelegationInput[](0); uint256 i = 0; - for(;i < ASSETS_TO_MIGRATE.length;) { - address aToken = MIGRATION_HELPER.aTokens(ASSETS_TO_MIGRATE[i]); + for(;i < assetsToMigrate.length;) { + address aToken = migrationHelper.aTokens(assetsToMigrate[i]); uint256 amount = IERC20(aToken).balanceOf(address(AaveV2Avalanche.COLLECTOR)); AaveV2Avalanche.COLLECTOR.transfer(aToken, address(this), amount); - SafeERC20.forceApprove(IERC20(aToken), AaveV2Avalanche.MIGRATION_HELPER, amount); + SafeERC20.forceApprove(IERC20(aToken), address(migrationHelper), amount); unchecked { - i++; + ++i; } } - MIGRATION_HELPER.migrate(ASSETS_TO_MIGRATE, POSITIONS_TO_REPAY, PERMITS, CREDIT_DELEGATION_PERMITS); + migrationHelper.migrate(assetsToMigrate, positionsToRepay, permits, creditDelegationPermits); - address[] memory NEW_ASSETS_MIGRATED = new address[](4); - NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + address[] memory newAssetsMigrated = new address[](4); + newAssetsMigrated[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + newAssetsMigrated[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + newAssetsMigrated[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + newAssetsMigrated[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; - for(i = 0; i < NEW_ASSETS_MIGRATED.length;) { + for(i = 0; i < newAssetsMigrated.length;) { SafeERC20.safeTransfer( - IERC20(NEW_ASSETS_MIGRATED[i]), + IERC20(newAssetsMigrated[i]), address(AaveV3Avalanche.COLLECTOR), - IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(this)) + IERC20(newAssetsMigrated[i]).balanceOf(address(this)) ); unchecked { - i++; + ++i; } } } diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol index e2bd4a23..79192145 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol @@ -16,45 +16,44 @@ contract AaveAvalancheTreasuryMigration_20230903_Test is Test { } function testPayload() public { - address[] memory OLD_ASSETS_MIGRATED = new address[](4); - OLD_ASSETS_MIGRATED[0] = AaveV2AvalancheAssets.DAIe_A_TOKEN; - OLD_ASSETS_MIGRATED[1] = AaveV2AvalancheAssets.WBTCe_A_TOKEN; - OLD_ASSETS_MIGRATED[2] = AaveV2AvalancheAssets.WETHe_A_TOKEN; - OLD_ASSETS_MIGRATED[3] = AaveV2AvalancheAssets.WAVAX_A_TOKEN; - - address[] memory NEW_ASSETS_MIGRATED = new address[](4); - NEW_ASSETS_MIGRATED[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; - NEW_ASSETS_MIGRATED[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; - NEW_ASSETS_MIGRATED[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; - NEW_ASSETS_MIGRATED[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; - - uint256[] memory NEW_ASSETS_BEFORE_BALANCE = new uint256[](4); - uint256[] memory OLD_ASSETS_BEFORE_BALANCE = new uint256[](4); - - uint256 i = 0; - uint256 payloadBalanceAfter; + address[4] memory oldAssetsMigrated; + oldAssetsMigrated[0] = AaveV2AvalancheAssets.DAIe_A_TOKEN; + oldAssetsMigrated[1] = AaveV2AvalancheAssets.WBTCe_A_TOKEN; + oldAssetsMigrated[2] = AaveV2AvalancheAssets.WETHe_A_TOKEN; + oldAssetsMigrated[3] = AaveV2AvalancheAssets.WAVAX_A_TOKEN; + + address[4] memory newAssetsMigrated; + newAssetsMigrated[0] = AaveV3AvalancheAssets.DAIe_A_TOKEN; + newAssetsMigrated[1] = AaveV3AvalancheAssets.WBTCe_A_TOKEN; + newAssetsMigrated[2] = AaveV3AvalancheAssets.WETHe_A_TOKEN; + newAssetsMigrated[3] = AaveV3AvalancheAssets.WAVAX_A_TOKEN; + + uint256[4] memory newAssetsBeforeBalance; + uint256[4] memory oldAssetsBeforeBalance; + + uint256 executorBalanceAfter; uint256 collectorBalanceAfter; - for(; i < NEW_ASSETS_MIGRATED.length; i++) { - NEW_ASSETS_BEFORE_BALANCE[i] = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); - OLD_ASSETS_BEFORE_BALANCE[i] = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); + for(uint256 i = 0; i < newAssetsMigrated.length; i++) { + newAssetsBeforeBalance[i] = IERC20(newAssetsMigrated[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + oldAssetsBeforeBalance[i] = IERC20(oldAssetsMigrated[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); } AaveAvalancheTreasuryMigration_20230903 payload = new AaveAvalancheTreasuryMigration_20230903(); GovHelpers.executePayload(vm, address(payload), AaveV3Avalanche.ACL_ADMIN); - for(i = 0; i < OLD_ASSETS_MIGRATED.length; i++) { - payloadBalanceAfter = IERC20(OLD_ASSETS_MIGRATED[i]).balanceOf(address(payload)); - assertEq(payloadBalanceAfter, 0); - payloadBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(payload)); - assertEq(payloadBalanceAfter, 0); + for(uint256 i = 0; i < oldAssetsMigrated.length; i++) { + executorBalanceAfter = IERC20(oldAssetsMigrated[i]).balanceOf(AaveV3Avalanche.ACL_ADMIN); + assertEq(executorBalanceAfter, 0); + executorBalanceAfter = IERC20(newAssetsMigrated[i]).balanceOf(AaveV3Avalanche.ACL_ADMIN); + assertEq(executorBalanceAfter, 0); } - for(i = 0; i < NEW_ASSETS_MIGRATED.length; i++) { - collectorBalanceAfter = IERC20(NEW_ASSETS_MIGRATED[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); + for(uint256 i = 0; i < newAssetsMigrated.length; i++) { + collectorBalanceAfter = IERC20(newAssetsMigrated[i]).balanceOf(address(AaveV3Avalanche.COLLECTOR)); /// 0.001e18 is 0.1% - assertApproxEqRel(NEW_ASSETS_BEFORE_BALANCE[i] + OLD_ASSETS_BEFORE_BALANCE[i], collectorBalanceAfter, 0.001e18); + assertApproxEqRel(newAssetsBeforeBalance[i] + oldAssetsBeforeBalance[i], collectorBalanceAfter, 0.001e18); } } } diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md index 9106844c..e0257325 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md +++ b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md @@ -16,8 +16,6 @@ Aave DAO currently holds around $4.52M on Avalanche v2. There are several driver * wAVAX incentives * Encourage migration v2 to v3 -Most of these funds can be migrated to v3 with the exception of USDT. There is not enough liquidity to redeem the entire 541.51K of USDT. As a result, approximately 25% of the USDT will be redeemed and deposited into v3. - # Specification Migrate the following holdings: From 3f8b195784c87e71c7e6d02c4830dac64fb8157c Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Mon, 25 Sep 2023 16:12:26 +0100 Subject: [PATCH 16/16] deploy payload, update .md & test --- .../AaveAvalancheTreasuryMigration_20230903.t.sol | 4 ++-- .../MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol index 79192145..ff195a95 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol +++ b/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol @@ -12,7 +12,7 @@ import {AaveAvalancheTreasuryMigration_20230903} from './AaveAvalancheTreasuryMi contract AaveAvalancheTreasuryMigration_20230903_Test is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('avalanche'), 35447142); + vm.createSelectFork(vm.rpcUrl('avalanche'), 35644766); } function testPayload() public { @@ -39,7 +39,7 @@ contract AaveAvalancheTreasuryMigration_20230903_Test is Test { oldAssetsBeforeBalance[i] = IERC20(oldAssetsMigrated[i]).balanceOf(address(AaveV2Avalanche.COLLECTOR)); } - AaveAvalancheTreasuryMigration_20230903 payload = new AaveAvalancheTreasuryMigration_20230903(); + AaveAvalancheTreasuryMigration_20230903 payload = AaveAvalancheTreasuryMigration_20230903(0x2DD58BeDC4A91110Bf9aF1d2bc3f13966d1C6643); GovHelpers.executePayload(vm, address(payload), AaveV3Avalanche.ACL_ADMIN); diff --git a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md index e0257325..23912fd2 100644 --- a/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md +++ b/src/AaveAvalancheTreasuryMigration_20230903/MIGRATE_AVALANCHE_V2_TREASURY_TO_AVALANCHE_V3.md @@ -39,7 +39,7 @@ A list of relevant links like for this proposal: * [Snapshot vote](https://snapshot.org/#/aave.eth/proposal/0x0be8229173181fe0aaf5ed1883e53752546efb810e55610e7ac8b991155ab788) * [Test Cases](https://github.com/bgd-labs/aave-proposals/tree/main/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.t.sol) * [Payload Implementation](https://github.com/bgd-labs/aave-proposals/tree/main/src/AaveAvalancheTreasuryMigration_20230903/AaveAvalancheTreasuryMigration_20230903.sol) -* [Deployed Contracts](TODO) +* [Deployed Contracts](https://snowtrace.io/address/0x2dd58bedc4a91110bf9af1d2bc3f13966d1c6643) The proposal Payload was reviewed by [Bored Ghost Developing](https://bgdlabs.com/).