From 24a3f7d23e03aca479c43c3f5d8a26c06d2686e8 Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Wed, 6 Dec 2023 03:34:57 +0530 Subject: [PATCH 01/26] Add proposal for Gho Incident Report 20231113 (#1) * chore: add payload and deploy script for update of GHO variable debt token * forge install: gho-core * chore: add gho-core to dependency * test: Add tests for update of gho variable token * test: Add tests for update of gho variable token * fix: add modifier in method of interface * fix: remove gho dependency from repo and fix test * fix: Remove unnecesary dependency * fix: Add latest details --------- Co-authored-by: miguelmtzinf --- remappings.txt | 2 +- ...veV3Ethereum_GhoIncidentReport_20231113.md | 28 +++++++++ ...3Ethereum_GhoIncidentReport_20231113.s.sol | 58 +++++++++++++++++++ ...eV3Ethereum_GhoIncidentReport_20231113.sol | 33 +++++++++++ ...3Ethereum_GhoIncidentReport_20231113.t.sol | 44 ++++++++++++++ 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md create mode 100644 src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol create mode 100644 src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol create mode 100644 src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol diff --git a/remappings.txt b/remappings.txt index b3b219556..620a76fc2 100644 --- a/remappings.txt +++ b/remappings.txt @@ -6,4 +6,4 @@ aave-v3-core/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/ aave-v3-periphery/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-periphery/ ds-test/=lib/aave-helpers/lib/forge-std/lib/ds-test/src/ forge-std/=lib/aave-helpers/lib/forge-std/src/ -solidity-utils/=lib/aave-helpers/lib/solidity-utils/src/ +solidity-utils/=lib/aave-helpers/lib/solidity-utils/src/ \ No newline at end of file diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md new file mode 100644 index 000000000..98d6ad0c4 --- /dev/null +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md @@ -0,0 +1,28 @@ +--- +title: "GHO update on Aave V3 Ethereum Pool for 13/11/2023 Report" +author: "Aave Labs @aave" +discussions: "https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642" +--- + +## Simple Summary + +This proposal patches the GHO integration with the Aave V3 Pool, fixing an issue reported by Immunefi on November 13, 2023. The patch, developed by Aave Labs in collaboration with Certora, upholds the highest safety standards. + +## Motivation + +A resolution for the identified technical issue identified in the GHO integration with the Aave V3 Ethereum Pool. The patch guarantees a permanent solution without altering any of the existing GHO features within the Aave Pool. + +## Specification + +The proposal payload upgrades the implementation of GhoVariableDebtToken. + +## References + +- GhoVariableDebtToken implementation: [GhoVariableDebtToken](https://etherscan.io/address/0x20cb2f303ede313e2cc44549ad8653a5e8c0050e#code) +- Implementation: [Payload]() +- [Discussion](https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642) + + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol new file mode 100644 index 000000000..89ea31bb9 --- /dev/null +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {AaveV3Ethereum_GhoIncidentReport_20231113} from './AaveV3Ethereum_GhoIncidentReport_20231113.sol'; +import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; +import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; + +/** + * @dev Deploy AaveV3Ethereum_GhoIncidentReport_20231113 + * command: make deploy-ledger contract=src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol:DeployEthereum chain=mainnet + */ +contract DeployEthereum is EthereumScript { + address constant NEW_VGHO_IMPL = 0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e; + + function run() external broadcast { + // deploy payloads + AaveV3Ethereum_GhoIncidentReport_20231113 payload = new AaveV3Ethereum_GhoIncidentReport_20231113( + NEW_VGHO_IMPL + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(address(payload)); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Create Proposal + * command: make deploy-ledger contract=src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol:CreateProposal chain=mainnet + */ +contract CreateProposal is EthereumScript { + function run() external { + // create payloads + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); + + // compose actions for validation + IPayloadsControllerCore.ExecutionAction[] + memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); + //TODO: Replace this address with payload address + actionsEthereum[0] = GovV3Helpers.buildAction(0xfb1163CD80850CD107bB134C15E5dfDF284F63FE); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); + + // create proposal + vm.startBroadcast(); + GovV3Helpers.createProposal2_5( + vm, + payloads, + GovV3Helpers.ipfsHashFile( + vm, + 'src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md' + ) + ); + } +} diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol new file mode 100644 index 000000000..b80e50a1d --- /dev/null +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {ConfiguratorInputTypes} from 'aave-address-book/AaveV3.sol'; +import {IERC20} from 'forge-std/interfaces/IERC20.sol'; +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; + +/** + * @title GHO update on Aave V3 Ethereum Pool for 13/11/2023 Report + * @dev Upgrades the implementation of the GhoVariableDebtToken contract + * @author Aave Labs (@aave) + * - Discussion: https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642 + */ +contract AaveV3Ethereum_GhoIncidentReport_20231113 { + address public immutable NEW_VGHO_IMPL; + + constructor(address newVGhoImpl) { + NEW_VGHO_IMPL = newVGhoImpl; + } + + function execute() external { + AaveV3Ethereum.POOL_CONFIGURATOR.updateVariableDebtToken( + ConfiguratorInputTypes.UpdateDebtTokenInput({ + asset: AaveV3EthereumAssets.GHO_UNDERLYING, + incentivesController: AaveV3Ethereum.DEFAULT_INCENTIVES_CONTROLLER, + name: IERC20(AaveV3EthereumAssets.GHO_V_TOKEN).name(), + symbol: IERC20(AaveV3EthereumAssets.GHO_V_TOKEN).symbol(), + implementation: NEW_VGHO_IMPL, + params: bytes('') + }) + ); + } +} diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol new file mode 100644 index 000000000..344b71a41 --- /dev/null +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; +import {AaveV3EthereumAssets, AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {AaveV3Ethereum_GhoIncidentReport_20231113} from './AaveV3Ethereum_GhoIncidentReport_20231113.sol'; + +interface IGhoVariableDebtTokenHelper { + function DEBT_TOKEN_REVISION() external view returns (uint256); +} + +/** + * @dev Test for AaveV3Ethereum_GhoIncidentReport_20231113 + * command: make test-contract filter=AaveV3Ethereum_GhoIncidentReport_20231113 + */ +contract AaveV3Ethereum_GhoIncidentReport_20231113_Test is ProtocolV3TestBase { + address constant NEW_VGHO_IMPL = 0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e; + + AaveV3Ethereum_GhoIncidentReport_20231113 internal proposal; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('mainnet'), 18722500); + proposal = new AaveV3Ethereum_GhoIncidentReport_20231113(NEW_VGHO_IMPL); + } + + function test_defaultProposalExecution() public { + defaultTest( + 'AaveV3Ethereum_GhoIncidentReport_20231113', + AaveV3Ethereum.POOL, + address(proposal) + ); + } + + function test_debtTokenRevisionUpdate() public { + assertTrue( + IGhoVariableDebtTokenHelper(AaveV3EthereumAssets.GHO_V_TOKEN).DEBT_TOKEN_REVISION() == 0x2 + ); + executePayload(vm, address(proposal)); + assertTrue( + IGhoVariableDebtTokenHelper(AaveV3EthereumAssets.GHO_V_TOKEN).DEBT_TOKEN_REVISION() == 0x3 + ); + } +} From 4aa6143b87b5e26d980cba5079de79f5210b7ccc Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:13:37 +0100 Subject: [PATCH 02/26] fix: Make new impl constant (#3) --- .../AaveV3Ethereum_GhoIncidentReport_20231113.s.sol | 6 ++---- .../AaveV3Ethereum_GhoIncidentReport_20231113.sol | 6 +----- .../AaveV3Ethereum_GhoIncidentReport_20231113.t.sol | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol index 89ea31bb9..d197070fa 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol @@ -14,9 +14,7 @@ contract DeployEthereum is EthereumScript { function run() external broadcast { // deploy payloads - AaveV3Ethereum_GhoIncidentReport_20231113 payload = new AaveV3Ethereum_GhoIncidentReport_20231113( - NEW_VGHO_IMPL - ); + AaveV3Ethereum_GhoIncidentReport_20231113 payload = new AaveV3Ethereum_GhoIncidentReport_20231113(); // compose action IPayloadsControllerCore.ExecutionAction[] @@ -47,7 +45,7 @@ contract CreateProposal is EthereumScript { // create proposal vm.startBroadcast(); GovV3Helpers.createProposal2_5( - vm, + vm, payloads, GovV3Helpers.ipfsHashFile( vm, diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol index b80e50a1d..08fc96cec 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.sol @@ -12,11 +12,7 @@ import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethe * - Discussion: https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642 */ contract AaveV3Ethereum_GhoIncidentReport_20231113 { - address public immutable NEW_VGHO_IMPL; - - constructor(address newVGhoImpl) { - NEW_VGHO_IMPL = newVGhoImpl; - } + address public constant NEW_VGHO_IMPL = 0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e; function execute() external { AaveV3Ethereum.POOL_CONFIGURATOR.updateVariableDebtToken( diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol index 344b71a41..f3286efb8 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol @@ -21,7 +21,7 @@ contract AaveV3Ethereum_GhoIncidentReport_20231113_Test is ProtocolV3TestBase { function setUp() public { vm.createSelectFork(vm.rpcUrl('mainnet'), 18722500); - proposal = new AaveV3Ethereum_GhoIncidentReport_20231113(NEW_VGHO_IMPL); + proposal = new AaveV3Ethereum_GhoIncidentReport_20231113(); } function test_defaultProposalExecution() public { From 27dd485e2f2fb5ceb42ba5c67f5e1cc95b0ae3ec Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:17:54 +0100 Subject: [PATCH 03/26] fix: Amend AIP text (#4) * fix: Make new impl constant * fix: Fix AIP text --- .../AaveV3Ethereum_GhoIncidentReport_20231113.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md index 98d6ad0c4..21902514e 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md @@ -10,7 +10,7 @@ This proposal patches the GHO integration with the Aave V3 Pool, fixing an issue ## Motivation -A resolution for the identified technical issue identified in the GHO integration with the Aave V3 Ethereum Pool. The patch guarantees a permanent solution without altering any of the existing GHO features within the Aave Pool. +The proposed patch guarantees a permanent solution for the technical issue that was identified and reported by Immunefi with the GHO integration with the Aave V3 Ethereum Pool. The fix will be implemented without altering any of the existing GHO features within the Aave V3 Pool. ## Specification From 2f242a671075a02ca4b1d2e08556c67295fb1088 Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:53:57 +0100 Subject: [PATCH 04/26] test: Tweak default tests with borrow cap update (#5) --- .../AaveV3Ethereum_GhoIncidentReport_20231113.t.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol index f3286efb8..dcbfb4659 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import {AaveV3EthereumAssets, AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {IPoolConfigurator} from 'aave-address-book/AaveV3.sol'; import {AaveV3Ethereum_GhoIncidentReport_20231113} from './AaveV3Ethereum_GhoIncidentReport_20231113.sol'; interface IGhoVariableDebtTokenHelper { @@ -25,6 +26,9 @@ contract AaveV3Ethereum_GhoIncidentReport_20231113_Test is ProtocolV3TestBase { } function test_defaultProposalExecution() public { + // increase GHO borrow cap so test borrows can succeed + vm.prank(AaveV3Ethereum.CAPS_PLUS_RISK_STEWARD); + AaveV3Ethereum.POOL_CONFIGURATOR.setBorrowCap(AaveV3Ethereum.GHO_TOKEN, 36_000_000); defaultTest( 'AaveV3Ethereum_GhoIncidentReport_20231113', AaveV3Ethereum.POOL, From 4812d01dc7f76975ffb20b80f30251f8f2a70924 Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Fri, 8 Dec 2023 00:10:52 +0530 Subject: [PATCH 05/26] fix: lint issue (#6) --- .../AaveV3Ethereum_GhoIncidentReport_20231113.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md index 21902514e..21e9b39ec 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md @@ -22,7 +22,6 @@ The proposal payload upgrades the implementation of GhoVariableDebtToken. - Implementation: [Payload]() - [Discussion](https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642) - ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From 43a7687a4c629f11d1c3be19bbafb59b8d12d70e Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Thu, 7 Dec 2023 19:44:59 +0100 Subject: [PATCH 06/26] test: Add diffs from test running (#7) --- ...hereum_GhoIncidentReport_20231113_after.md | 25 +++++++++++++++++++ ...hereum_GhoIncidentReport_20231126_after.md | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 diffs/AaveV3Ethereum_GhoIncidentReport_20231113_before_AaveV3Ethereum_GhoIncidentReport_20231113_after.md create mode 100644 diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md diff --git a/diffs/AaveV3Ethereum_GhoIncidentReport_20231113_before_AaveV3Ethereum_GhoIncidentReport_20231113_after.md b/diffs/AaveV3Ethereum_GhoIncidentReport_20231113_before_AaveV3Ethereum_GhoIncidentReport_20231113_after.md new file mode 100644 index 000000000..1088d0e5d --- /dev/null +++ b/diffs/AaveV3Ethereum_GhoIncidentReport_20231113_before_AaveV3Ethereum_GhoIncidentReport_20231113_after.md @@ -0,0 +1,25 @@ +## Reserve changes + +### Reserves altered + +#### GHO ([0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f](https://etherscan.io/address/0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f)) + +| description | value before | value after | +| --- | --- | --- | +| variableDebtTokenImpl | [0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775](https://etherscan.io/address/0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775) | [0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e](https://etherscan.io/address/0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e) | + + +## Raw diff + +```json +{ + "reserves": { + "0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f": { + "variableDebtTokenImpl": { + "from": "0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775", + "to": "0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e" + } + } + } +} +``` \ No newline at end of file diff --git a/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md b/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md new file mode 100644 index 000000000..1088d0e5d --- /dev/null +++ b/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md @@ -0,0 +1,25 @@ +## Reserve changes + +### Reserves altered + +#### GHO ([0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f](https://etherscan.io/address/0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f)) + +| description | value before | value after | +| --- | --- | --- | +| variableDebtTokenImpl | [0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775](https://etherscan.io/address/0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775) | [0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e](https://etherscan.io/address/0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e) | + + +## Raw diff + +```json +{ + "reserves": { + "0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f": { + "variableDebtTokenImpl": { + "from": "0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775", + "to": "0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e" + } + } + } +} +``` \ No newline at end of file From 4c79bb9fd4120ff068eaa946cc01961d51b6a892 Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:15:32 +0100 Subject: [PATCH 07/26] fix: Add payload address (#8) --- .../AaveV3Ethereum_GhoIncidentReport_20231113.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md index 21e9b39ec..2cf269d2a 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.md @@ -19,7 +19,7 @@ The proposal payload upgrades the implementation of GhoVariableDebtToken. ## References - GhoVariableDebtToken implementation: [GhoVariableDebtToken](https://etherscan.io/address/0x20cb2f303ede313e2cc44549ad8653a5e8c0050e#code) -- Implementation: [Payload]() +- Implementation: [Payload](https://etherscan.io/address/0xbc9ffee8d18d75a412474b92192257d3c18471ff#code) - [Discussion](https://governance.aave.com/t/arfc-gho-technical-incident-13-11-2023/15642) ## Copyright From 76cd4b62ea788ce12259adcc565128bcea4a1181 Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:40:00 +0100 Subject: [PATCH 08/26] fix: Fix payload address in script (#9) --- .../AaveV3Ethereum_GhoIncidentReport_20231113.s.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol index d197070fa..4345823a2 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.s.sol @@ -38,8 +38,7 @@ contract CreateProposal is EthereumScript { // compose actions for validation IPayloadsControllerCore.ExecutionAction[] memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); - //TODO: Replace this address with payload address - actionsEthereum[0] = GovV3Helpers.buildAction(0xfb1163CD80850CD107bB134C15E5dfDF284F63FE); + actionsEthereum[0] = GovV3Helpers.buildAction(0xbC9ffee8d18d75a412474B92192257d3c18471FF); payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); // create proposal From 120f5649187b1f70d39e37d3f4ca88416968aece Mon Sep 17 00:00:00 2001 From: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:53:41 +0100 Subject: [PATCH 09/26] fix: Remove unneeded diff file (#10) --- ...hereum_GhoIncidentReport_20231126_after.md | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md diff --git a/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md b/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md deleted file mode 100644 index 1088d0e5d..000000000 --- a/diffs/AaveV3Ethereum_GhoIncidentReport_20231126_before_AaveV3Ethereum_GhoIncidentReport_20231126_after.md +++ /dev/null @@ -1,25 +0,0 @@ -## Reserve changes - -### Reserves altered - -#### GHO ([0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f](https://etherscan.io/address/0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f)) - -| description | value before | value after | -| --- | --- | --- | -| variableDebtTokenImpl | [0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775](https://etherscan.io/address/0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775) | [0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e](https://etherscan.io/address/0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e) | - - -## Raw diff - -```json -{ - "reserves": { - "0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f": { - "variableDebtTokenImpl": { - "from": "0x7aa606b1B341fFEeAfAdbbE4A2992EFB35972775", - "to": "0x20Cb2f303EDe313e2Cc44549Ad8653a5E8c0050e" - } - } - } -} -``` \ No newline at end of file From 6c5ee89fd595ee6c064074f1440abaa3b4508f12 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Thu, 18 Jan 2024 21:29:18 +0100 Subject: [PATCH 10/26] feat: added stkgho initialization proposal --- .gitmodules | 3 + lib/stake-token | 1 + .../StkGHOActivation.md | 33 +++++++++++ .../StkGHO_Activation_20240118.s.sol | 58 +++++++++++++++++++ .../StkGHO_Activation_20240118.sol | 43 ++++++++++++++ .../StkGHO_Activation_20240118.t.sol | 32 ++++++++++ src/20240118_StkGHO_Activation/config.ts | 13 +++++ 7 files changed, 183 insertions(+) create mode 160000 lib/stake-token create mode 100644 src/20240118_StkGHO_Activation/StkGHOActivation.md create mode 100644 src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol create mode 100644 src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol create mode 100644 src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol create mode 100644 src/20240118_StkGHO_Activation/config.ts diff --git a/.gitmodules b/.gitmodules index f7316a1d6..d90e9d612 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/aave-helpers"] path = lib/aave-helpers url = https://github.com/bgd-labs/aave-helpers +[submodule "lib/stake-token"] + path = lib/stake-token + url = https://github.com/bgd-labs/stake-token.git diff --git a/lib/stake-token b/lib/stake-token new file mode 160000 index 000000000..e6530c110 --- /dev/null +++ b/lib/stake-token @@ -0,0 +1 @@ +Subproject commit e6530c1106b250c4ee6e9bc2904deb1604e0bf9f diff --git a/src/20240118_StkGHO_Activation/StkGHOActivation.md b/src/20240118_StkGHO_Activation/StkGHOActivation.md new file mode 100644 index 000000000..6d8e7475d --- /dev/null +++ b/src/20240118_StkGHO_Activation/StkGHOActivation.md @@ -0,0 +1,33 @@ +--- +title: "Polygon V2 Reserve Factor Updates" +author: "karpatkey_TokenLogic" +discussions: "https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635" +--- + +## Simple Summary + +This AIP activates the new GHO based Safety module by initiating the emission schedule approved by the community during the vote +https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 + +## Motivation + +The GHO Safety Module will fortify the Aave Protocol’s resilience by adding a stablecoin asset, which is inherently less volatile than AAVE. This strategic move diversifies the Safety Module’s capacity to absorb shocks from various risk vectors in case of shortfall events. + +## Specification + +The GHO Safety module will be activated with the following parameters: + +Base emission: 50 AAVE/day +Duration: Three months + +## References + +[TBD] + +## Disclaimer + +Aave Labs, BGD Labs and ACI receive no compensation beyond Aave protocol for the creation of this proposal. BGD Labs and ACI are both delegates within the Aave ecosystem. + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol new file mode 100644 index 000000000..07523f1b8 --- /dev/null +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; +import {EthereumScript, PolygonScript} from 'aave-helpers/ScriptUtils.sol'; +import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; + +/** + * @dev Deploy Ethereum + * deploy-command: make deploy-ledger contract=src/20240102_AaveV2Polygon_ReserveFactorUpdates/ReserveFactorUpdates_20240102.s.sol:DeployPolygon chain=polygon + * verify-command: npx catapulta-verify -b broadcast/ReserveFactorUpdates_20240102.s.sol/137/run-latest.json + */ +contract DeployPolygon is PolygonScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(StkGHO_Activation_20240118).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Create Proposal + * command: make deploy-ledger contract=src/20240102_AaveV2Polygon_ReserveFactorUpdates/ReserveFactorUpdates_20240102.s.sol:CreateProposal chain=mainnet + */ +contract CreateProposal is EthereumScript { + function run() external { + // create payloads + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); + + // compose actions for validation + IPayloadsControllerCore.ExecutionAction[] + memory actionsPolygon = new IPayloadsControllerCore.ExecutionAction[](1); + actionsPolygon[0] = GovV3Helpers.buildAction( + type(StkGHO_Activation_20240118).creationCode + ); + payloads[0] = GovV3Helpers.buildPolygonPayload(vm, actionsPolygon); + + // create proposal + vm.startBroadcast(); + GovV3Helpers.createProposal( + vm, + payloads, + GovV3Helpers.ipfsHashFile( + vm, + 'src/StkGHO_Activation_20240118/StkGHOActivation.md' + ) + ); + } +} diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol new file mode 100644 index 000000000..cd555282a --- /dev/null +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.19; + +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; +import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import {IAggregatedStakeToken} from 'stake-token/src/contracts/IAggregatedStakeToken.sol'; +import {DistributionTypes} from 'stake-token/src/contracts/lib/DistributionTypes.sol'; +import {IAaveDistributionManager} from 'stake-token/src/contracts/IAaveDistributionManager.sol'; +import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; + +/** + * @title StkGHO Activation + * @author the3d.eth + * - Snapshot: 'https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 + * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 + */ +contract StkGHO_Activation_20240118 is IProposalGenericExecutor { + uint256 public constant STKGHO_EMISSION_PER_SECOND = 5787037037037037; // 50 AAVE/day + uint256 public constant DISTRIBUTION_DURATION = 3*30*86400; // three months + address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; + + function execute() external { + IAggregatedStakeToken(STKGHO_PROXY).setDistributionEnd( + block.timestamp + DISTRIBUTION_DURATION + ); + DistributionTypes.AssetConfigInput[] + memory enableConfigs = new DistributionTypes.AssetConfigInput[](1); + enableConfigs[0] = DistributionTypes.AssetConfigInput({ + emissionPerSecond: uint128(STKGHO_EMISSION_PER_SECOND), + totalStaked: 0, // it's overwritten internally + underlyingAsset: AaveV3Ethereum.GHO_TOKEN + }); + IAaveDistributionManager(STKGHO_PROXY).configureAssets(enableConfigs); + MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( + MiscEthereum.ECOSYSTEM_RESERVE, + AaveV3EthereumAssets.AAVE_UNDERLYING, + STKGHO_PROXY, + STKGHO_EMISSION_PER_SECOND * DISTRIBUTION_DURATION + ); + } +} diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol new file mode 100644 index 000000000..e5935f5e7 --- /dev/null +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {ProtocolV2TestBase, ReserveConfig} from 'aave-helpers/ProtocolV2TestBase.sol'; + +import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; + +/** + * @dev Test for StkGHO_Activation_20240118 + * command: make test-contract filter=StkGHO_Activation_20240118 + */ +contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { + struct Changes { + address asset; + uint256 reserveFactor; + } + + StkGHO_Activation_20240118 internal proposal; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('ethereum'), 51940815); + proposal = new StkGHO_Activation_20240118(); + } + + /** + * @dev executes the generic test suite including e2e and config snapshots + */ + function test_defaultProposalExecution() public { + + + } +} diff --git a/src/20240118_StkGHO_Activation/config.ts b/src/20240118_StkGHO_Activation/config.ts new file mode 100644 index 000000000..cbe143fe4 --- /dev/null +++ b/src/20240118_StkGHO_Activation/config.ts @@ -0,0 +1,13 @@ +import {ConfigFile} from '../../generator/types'; +export const config: ConfigFile = { + rootOptions: { + pools: ['AaveV3Ethereum'], + title: 'StkGHO Activation', + shortName: 'StkGHOActivation', + date: '20240118', + author: 'Bgdlabs_Aave_ACI', + discussion: 'https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635', + snapshot: 'https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065', + }, + poolOptions: {AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 51855274}}}, +}; From 1b99bd872fe6acc0121a4636144c9d16213183ea Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Thu, 18 Jan 2024 21:32:27 +0100 Subject: [PATCH 11/26] feat: fixed proposal description --- src/20240118_StkGHO_Activation/StkGHOActivation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHOActivation.md b/src/20240118_StkGHO_Activation/StkGHOActivation.md index 6d8e7475d..86d3a6b33 100644 --- a/src/20240118_StkGHO_Activation/StkGHOActivation.md +++ b/src/20240118_StkGHO_Activation/StkGHOActivation.md @@ -1,6 +1,6 @@ --- -title: "Polygon V2 Reserve Factor Updates" -author: "karpatkey_TokenLogic" +title: "GHO Safety Module Initialization" +author: "Aave_BGDLabs_ACI" discussions: "https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635" --- From c3d48cd8c26dfff590e117798eb2988b248d7c18 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 15:44:05 +0100 Subject: [PATCH 12/26] feat: removed submodule --- .gitmodules | 3 - lib/stake-token | 1 - .../IStakeToken.sol | 194 ++++++++++++++++++ .../StkGHO_Activation_20240118.sol | 18 +- 4 files changed, 204 insertions(+), 12 deletions(-) delete mode 160000 lib/stake-token create mode 100644 src/20240118_StkGHO_Activation/IStakeToken.sol diff --git a/.gitmodules b/.gitmodules index d90e9d612..f7316a1d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "lib/aave-helpers"] path = lib/aave-helpers url = https://github.com/bgd-labs/aave-helpers -[submodule "lib/stake-token"] - path = lib/stake-token - url = https://github.com/bgd-labs/stake-token.git diff --git a/lib/stake-token b/lib/stake-token deleted file mode 160000 index e6530c110..000000000 --- a/lib/stake-token +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e6530c1106b250c4ee6e9bc2904deb1604e0bf9f diff --git a/src/20240118_StkGHO_Activation/IStakeToken.sol b/src/20240118_StkGHO_Activation/IStakeToken.sol new file mode 100644 index 000000000..a677ed29f --- /dev/null +++ b/src/20240118_StkGHO_Activation/IStakeToken.sol @@ -0,0 +1,194 @@ +pragma solidity ^0.8.10; + +interface IStakeToken { + event Approval(address indexed owner, address indexed spender, uint256 value); + event AssetConfigUpdated(address indexed asset, uint256 emission); + event AssetIndexUpdated(address indexed asset, uint256 index); + event Cooldown(address indexed user, uint256 amount); + event CooldownSecondsChanged(uint256 cooldownSeconds); + event DistributionEndChanged(uint256 endTimestamp); + event EIP712DomainChanged(); + event ExchangeRateChanged(uint216 exchangeRate); + event FundsReturned(uint256 amount); + event Initialized(uint64 version); + event MaxSlashablePercentageChanged(uint256 newPercentage); + event PendingAdminChanged(address indexed newPendingAdmin, uint256 role); + event Redeem(address indexed from, address indexed to, uint256 assets, uint256 shares); + event RewardsAccrued(address user, uint256 amount); + event RewardsClaimed(address indexed from, address indexed to, uint256 amount); + event RoleClaimed(address indexed newAdmin, uint256 role); + event Slashed(address indexed destination, uint256 amount); + event SlashingExitWindowDurationChanged(uint256 windowSeconds); + event SlashingSettled(); + event Staked(address indexed from, address indexed to, uint256 assets, uint256 shares); + event Transfer(address indexed from, address indexed to, uint256 value); + event UserIndexUpdated(address indexed user, address indexed asset, uint256 index); + + struct AssetConfigInput { + uint128 emissionPerSecond; + uint256 totalStaked; + address underlyingAsset; + } + + function CLAIM_HELPER_ROLE() external view returns (uint256); + + function COOLDOWN_ADMIN_ROLE() external view returns (uint256); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + + function EMISSION_MANAGER() external view returns (address); + + function EXCHANGE_RATE_UNIT() external view returns (uint256); + + function INITIAL_EXCHANGE_RATE() external view returns (uint216); + + function LOWER_BOUND() external view returns (uint256); + + function PRECISION() external view returns (uint8); + + function REWARDS_VAULT() external view returns (address); + + function REWARD_TOKEN() external view returns (address); + + function SLASH_ADMIN_ROLE() external view returns (uint256); + + function STAKED_TOKEN() external view returns (address); + + function UNSTAKE_WINDOW() external view returns (uint256); + + function allowance(address owner, address spender) external view returns (uint256); + + function approve(address spender, uint256 value) external returns (bool); + + function assets( + address + ) external view returns (uint128 emissionPerSecond, uint128 lastUpdateTimestamp, uint256 index); + + function balanceOf(address account) external view returns (uint256); + + function claimRewards(address to, uint256 amount) external; + + function claimRewardsAndRedeem(address to, uint256 claimAmount, uint256 redeemAmount) external; + + function claimRewardsAndRedeemOnBehalf( + address from, + address to, + uint256 claimAmount, + uint256 redeemAmount + ) external; + + function claimRewardsOnBehalf( + address from, + address to, + uint256 amount + ) external returns (uint256); + + function claimRoleAdmin(uint256 role) external; + + function configureAssets(AssetConfigInput[] memory assetsConfigInput) external; + + function cooldown() external; + + function cooldownOnBehalfOf(address from) external; + + function decimals() external view returns (uint8); + + function distributionEnd() external view returns (uint256); + + function eip712Domain() + external + view + returns ( + bytes1 fields, + string memory name, + string memory version, + uint256 chainId, + address verifyingContract, + bytes32 salt, + uint256[] memory extensions + ); + + function getAdmin(uint256 role) external view returns (address); + + function getCooldownSeconds() external view returns (uint256); + + function getExchangeRate() external view returns (uint216); + + function getMaxSlashablePercentage() external view returns (uint256); + + function getPendingAdmin(uint256 role) external view returns (address); + + function getTotalRewardsBalance(address staker) external view returns (uint256); + + function getUserAssetData(address user, address asset) external view returns (uint256); + + function inPostSlashingPeriod() external view returns (bool); + + function initialize( + string memory name, + string memory symbol, + address slashingAdmin, + address cooldownPauseAdmin, + address claimHelper, + uint256 maxSlashablePercentage, + uint256 cooldownSeconds + ) external; + + function name() external view returns (string memory); + + function nonces(address owner) external view returns (uint256); + + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + function previewRedeem(uint256 shares) external view returns (uint256); + + function previewStake(uint256 assets) external view returns (uint256); + + function redeem(address to, uint256 amount) external; + + function redeemOnBehalf(address from, address to, uint256 amount) external; + + function returnFunds(uint256 amount) external; + + function setCooldownSeconds(uint256 cooldownSeconds) external; + + function setDistributionEnd(uint256 newDistributionEnd) external; + + function setMaxSlashablePercentage(uint256 percentage) external; + + function setPendingAdmin(uint256 role, address newPendingAdmin) external; + + function settleSlashing() external; + + function slash(address destination, uint256 amount) external returns (uint256); + + function stake(address to, uint256 amount) external; + + function stakeWithPermit( + uint256 amount, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + function stakerRewardsToClaim(address) external view returns (uint256); + + function stakersCooldowns(address) external view returns (uint40 timestamp, uint216 amount); + + function symbol() external view returns (string memory); + + function totalSupply() external view returns (uint256); + + function transfer(address to, uint256 value) external returns (bool); + + function transferFrom(address from, address to, uint256 value) external returns (bool); +} \ No newline at end of file diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index cd555282a..dd5b15696 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -5,10 +5,8 @@ pragma solidity 0.8.19; import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; -import {IAggregatedStakeToken} from 'stake-token/src/contracts/IAggregatedStakeToken.sol'; -import {DistributionTypes} from 'stake-token/src/contracts/lib/DistributionTypes.sol'; -import {IAaveDistributionManager} from 'stake-token/src/contracts/IAaveDistributionManager.sol'; import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {IStakeToken} from './IStakeToken.sol'; /** * @title StkGHO Activation @@ -22,17 +20,21 @@ contract StkGHO_Activation_20240118 is IProposalGenericExecutor { address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; function execute() external { - IAggregatedStakeToken(STKGHO_PROXY).setDistributionEnd( + + IStakeToken(STKGHO_PROXY).setDistributionEnd( block.timestamp + DISTRIBUTION_DURATION ); - DistributionTypes.AssetConfigInput[] - memory enableConfigs = new DistributionTypes.AssetConfigInput[](1); - enableConfigs[0] = DistributionTypes.AssetConfigInput({ + + IStakeToken.AssetConfigInput[] + memory enableConfigs = new IStakeToken.AssetConfigInput[](1); + enableConfigs[0] = IStakeToken.AssetConfigInput({ emissionPerSecond: uint128(STKGHO_EMISSION_PER_SECOND), totalStaked: 0, // it's overwritten internally underlyingAsset: AaveV3Ethereum.GHO_TOKEN }); - IAaveDistributionManager(STKGHO_PROXY).configureAssets(enableConfigs); + + IStakeToken(STKGHO_PROXY).configureAssets(enableConfigs); + MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( MiscEthereum.ECOSYSTEM_RESERVE, AaveV3EthereumAssets.AAVE_UNDERLYING, From 7938a2d6fe80172b4120d32df5d53a505b915b20 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 15:46:50 +0100 Subject: [PATCH 13/26] feat: fixed deployment script --- .../StkGHO_Activation_20240118.s.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 07523f1b8..2e2c0deac 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; -import {EthereumScript, PolygonScript} from 'aave-helpers/ScriptUtils.sol'; +import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; /** @@ -10,7 +10,7 @@ import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; * deploy-command: make deploy-ledger contract=src/20240102_AaveV2Polygon_ReserveFactorUpdates/ReserveFactorUpdates_20240102.s.sol:DeployPolygon chain=polygon * verify-command: npx catapulta-verify -b broadcast/ReserveFactorUpdates_20240102.s.sol/137/run-latest.json */ -contract DeployPolygon is PolygonScript { +contract DeployEthereum is EthereumScript { function run() external broadcast { // deploy payloads address payload0 = GovV3Helpers.deployDeterministic( From 575b44567639e67017473ab31e31d559287ca439 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 15:47:57 +0100 Subject: [PATCH 14/26] feat: replaced duration calculation --- src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index dd5b15696..08d74af9d 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -16,7 +16,7 @@ import {IStakeToken} from './IStakeToken.sol'; */ contract StkGHO_Activation_20240118 is IProposalGenericExecutor { uint256 public constant STKGHO_EMISSION_PER_SECOND = 5787037037037037; // 50 AAVE/day - uint256 public constant DISTRIBUTION_DURATION = 3*30*86400; // three months + uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; function execute() external { From b777395af9318c173b5181146de48c33a5a52b62 Mon Sep 17 00:00:00 2001 From: Mark Hinschberger Date: Fri, 19 Jan 2024 14:54:41 +0000 Subject: [PATCH 15/26] git commit remove submodule --- .gitmodules | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index d90e9d612..9f93dcf35 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,4 @@ [submodule "lib/aave-helpers"] path = lib/aave-helpers url = https://github.com/bgd-labs/aave-helpers -[submodule "lib/stake-token"] - path = lib/stake-token - url = https://github.com/bgd-labs/stake-token.git + From 79f2011b175d376cf309d57a19ca33645cca2f0b Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 15:59:35 +0100 Subject: [PATCH 16/26] feat: fixed payload build function --- src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 2e2c0deac..983dfbae2 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -42,7 +42,7 @@ contract CreateProposal is EthereumScript { actionsPolygon[0] = GovV3Helpers.buildAction( type(StkGHO_Activation_20240118).creationCode ); - payloads[0] = GovV3Helpers.buildPolygonPayload(vm, actionsPolygon); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsPolygon); // create proposal vm.startBroadcast(); From 1062d67a2fe0f067867e49470b7157192f6ab6f7 Mon Sep 17 00:00:00 2001 From: Mark Hinschberger Date: Fri, 19 Jan 2024 15:03:47 +0000 Subject: [PATCH 17/26] update proposal --- package.json | 2 +- .../StkGHO_Activation_20240118.s.sol | 20 ++++---- .../StkGHO_Activation_20240118.sol | 11 ++-- .../StkGHO_Activation_20240118.t.sol | 51 +++++++++++++++++-- yarn.lock | 8 +-- 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index a0c19d5aa..efb10b836 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "vitest": "^1.0.4" }, "dependencies": { - "@bgd-labs/aave-address-book": "^2.14.0", + "@bgd-labs/aave-address-book": "^2.17.0", "@bgd-labs/aave-cli": "0.2.1", "@inquirer/prompts": "^3.3.0", "@inquirer/testing": "^2.1.9", diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 07523f1b8..5efe01248 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -4,10 +4,11 @@ pragma solidity ^0.8.0; import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; import {EthereumScript, PolygonScript} from 'aave-helpers/ScriptUtils.sol'; import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; +import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; /** * @dev Deploy Ethereum - * deploy-command: make deploy-ledger contract=src/20240102_AaveV2Polygon_ReserveFactorUpdates/ReserveFactorUpdates_20240102.s.sol:DeployPolygon chain=polygon + * deploy-command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:DeployPolygon chain=polygon * verify-command: npx catapulta-verify -b broadcast/ReserveFactorUpdates_20240102.s.sol/137/run-latest.json */ contract DeployPolygon is PolygonScript { @@ -29,9 +30,13 @@ contract DeployPolygon is PolygonScript { /** * @dev Create Proposal - * command: make deploy-ledger contract=src/20240102_AaveV2Polygon_ReserveFactorUpdates/ReserveFactorUpdates_20240102.s.sol:CreateProposal chain=mainnet + * command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:CreateProposal chain=mainnet */ contract CreateProposal is EthereumScript { + uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day + uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months + address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO; + function run() external { // create payloads PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); @@ -39,20 +44,15 @@ contract CreateProposal is EthereumScript { // compose actions for validation IPayloadsControllerCore.ExecutionAction[] memory actionsPolygon = new IPayloadsControllerCore.ExecutionAction[](1); - actionsPolygon[0] = GovV3Helpers.buildAction( - type(StkGHO_Activation_20240118).creationCode - ); - payloads[0] = GovV3Helpers.buildPolygonPayload(vm, actionsPolygon); + actionsPolygon[0] = GovV3Helpers.buildAction(type(StkGHO_Activation_20240118).creationCode); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsPolygon); // create proposal vm.startBroadcast(); GovV3Helpers.createProposal( vm, payloads, - GovV3Helpers.ipfsHashFile( - vm, - 'src/StkGHO_Activation_20240118/StkGHOActivation.md' - ) + GovV3Helpers.ipfsHashFile(vm, 'src/StkGHO_Activation_20240118/StkGHOActivation.md') ); } } diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index cd555282a..5dcc933a6 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -9,6 +9,7 @@ import {IAggregatedStakeToken} from 'stake-token/src/contracts/IAggregatedStakeT import {DistributionTypes} from 'stake-token/src/contracts/lib/DistributionTypes.sol'; import {IAaveDistributionManager} from 'stake-token/src/contracts/IAaveDistributionManager.sol'; import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; /** * @title StkGHO Activation @@ -17,14 +18,12 @@ import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 */ contract StkGHO_Activation_20240118 is IProposalGenericExecutor { - uint256 public constant STKGHO_EMISSION_PER_SECOND = 5787037037037037; // 50 AAVE/day - uint256 public constant DISTRIBUTION_DURATION = 3*30*86400; // three months - address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; + uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day + uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months + address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO; function execute() external { - IAggregatedStakeToken(STKGHO_PROXY).setDistributionEnd( - block.timestamp + DISTRIBUTION_DURATION - ); + IAggregatedStakeToken(STKGHO_PROXY).setDistributionEnd(block.timestamp + DISTRIBUTION_DURATION); DistributionTypes.AssetConfigInput[] memory enableConfigs = new DistributionTypes.AssetConfigInput[](1); enableConfigs[0] = DistributionTypes.AssetConfigInput({ diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index e5935f5e7..369aae68a 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -2,14 +2,27 @@ pragma solidity ^0.8.0; import {ProtocolV2TestBase, ReserveConfig} from 'aave-helpers/ProtocolV2TestBase.sol'; - +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import 'forge-std/console.sol'; import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; +import {IAggregatedStakeToken} from 'stake-token/src/contracts/IAggregatedStakeToken.sol'; +import {IStakeToken} from 'stake-token/src/contracts/IStakeToken.sol'; +import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; +import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; /** * @dev Test for StkGHO_Activation_20240118 * command: make test-contract filter=StkGHO_Activation_20240118 */ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { + uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day + uint256 public constant DISTRIBUTION_DURATION = 3 * 30 * 86400; // three months + address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO; + struct Changes { address asset; uint256 reserveFactor; @@ -18,7 +31,8 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { StkGHO_Activation_20240118 internal proposal; function setUp() public { - vm.createSelectFork(vm.rpcUrl('ethereum'), 51940815); + vm.createSelectFork(vm.rpcUrl('mainnet'), 19040576); + proposal = new StkGHO_Activation_20240118(); } @@ -26,7 +40,38 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { + (uint128 emissionPerSecondBefore, , ) = IAggregatedStakeToken(STKGHO_PROXY).assets( + AaveV3Ethereum.GHO_TOKEN + ); + + GovV3Helpers.executePayload(vm, address(proposal)); + ( + uint128 emissionPerSecondAfter, + uint128 lastUpdateTimestampAfter, // uint256 indexAfter + + ) = IAggregatedStakeToken(STKGHO_PROXY).assets(AaveV3Ethereum.GHO_TOKEN); + + // NOTE index is still 0 + assertEq((emissionPerSecondBefore + emissionPerSecondAfter), STKGHO_EMISSION_PER_SECOND); + assertEq(lastUpdateTimestampAfter, block.timestamp); + } + + function test_EcosystemCorrectAllowance() public { + uint256 allowanceBefore = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( + MiscEthereum.ECOSYSTEM_RESERVE, + STKGHO_PROXY + ); + + GovV3Helpers.executePayload(vm, address(proposal)); + + uint256 allowanceAfter = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( + MiscEthereum.ECOSYSTEM_RESERVE, + STKGHO_PROXY + ); - + assertEq( + (allowanceAfter + allowanceBefore), + STKGHO_EMISSION_PER_SECOND * DISTRIBUTION_DURATION + ); } } diff --git a/yarn.lock b/yarn.lock index 419baa37d..a090e2c67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,10 +44,10 @@ resolved "https://registry.yarnpkg.com/@bgd-labs/aave-address-book/-/aave-address-book-2.10.0.tgz#19873ec0edf9ee1f1a5539162e6092b0a2b2c4b4" integrity sha512-DVglkDCYUf7etb6mnCziIY2HPgap4X3AnC/1tC0ZqpXFrhO0lQzWBiMeWy20r1x/b81iHMQa02ULaco3LhdeVw== -"@bgd-labs/aave-address-book@^2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@bgd-labs/aave-address-book/-/aave-address-book-2.14.0.tgz#5cf20d1d9bfd2f9dbb57ebadb4e066ff7631009d" - integrity sha512-FFlfxOByUclzb6tY7LuA4rVRY6lRv3U6+FFXOegV6wxwYrsZEP9v3g0gQK0PTnbo3+Ua3kl+TlvySMQU7Klalw== +"@bgd-labs/aave-address-book@^2.17.0": + version "2.17.0" + resolved "https://registry.yarnpkg.com/@bgd-labs/aave-address-book/-/aave-address-book-2.17.0.tgz#06f5e8950135d00039220a0a6f44055e520924e2" + integrity sha512-JhKGyaCm6Qg+0jtX3UiNNi7c8+vYqFp8gbAsgMnxMZhDOEoNo4gPtiEq9M9rFl1PwjSEdMyzoRcP/nquFPC52g== "@bgd-labs/aave-cli@0.2.1": version "0.2.1" From 6d58d1f6c12ffe63b06eb52cf6c7cfd979848547 Mon Sep 17 00:00:00 2001 From: Mark Hinschberger Date: Fri, 19 Jan 2024 15:12:29 +0000 Subject: [PATCH 18/26] sync branch --- .../StkGHO_Activation_20240118.sol | 2 +- .../StkGHO_Activation_20240118.t.sol | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index 516801ac0..88f03c36e 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -15,7 +15,7 @@ import {IStakeToken} from './IStakeToken.sol'; * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 */ contract StkGHO_Activation_20240118 is IProposalGenericExecutor { - uint256 public constant STKGHO_EMISSION_PER_SECOND = 5787037037037037; // 50 AAVE/day + uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index 369aae68a..8ce60b9f0 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -6,8 +6,8 @@ import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; import 'forge-std/console.sol'; import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; -import {IAggregatedStakeToken} from 'stake-token/src/contracts/IAggregatedStakeToken.sol'; -import {IStakeToken} from 'stake-token/src/contracts/IStakeToken.sol'; +import {IStakeToken} from './IStakeToken.sol'; + import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; @@ -40,7 +40,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { - (uint128 emissionPerSecondBefore, , ) = IAggregatedStakeToken(STKGHO_PROXY).assets( + (uint128 emissionPerSecondBefore, , ) = IStakeToken(STKGHO_PROXY).assets( AaveV3Ethereum.GHO_TOKEN ); @@ -49,7 +49,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { uint128 emissionPerSecondAfter, uint128 lastUpdateTimestampAfter, // uint256 indexAfter - ) = IAggregatedStakeToken(STKGHO_PROXY).assets(AaveV3Ethereum.GHO_TOKEN); + ) = IStakeToken(STKGHO_PROXY).assets(AaveV3Ethereum.GHO_TOKEN); // NOTE index is still 0 assertEq((emissionPerSecondBefore + emissionPerSecondAfter), STKGHO_EMISSION_PER_SECOND); From 35a12a3f80015df3ad8bd4451de5d2e87a8fb433 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 16:20:29 +0100 Subject: [PATCH 19/26] fix: variable name --- .../StkGHO_Activation_20240118.s.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 0fcc9b036..7a043facf 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -43,9 +43,9 @@ contract CreateProposal is EthereumScript { // compose actions for validation IPayloadsControllerCore.ExecutionAction[] - memory actionsPolygon = new IPayloadsControllerCore.ExecutionAction[](1); - actionsPolygon[0] = GovV3Helpers.buildAction(type(StkGHO_Activation_20240118).creationCode); - payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsPolygon); + memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsEthereum[0] = GovV3Helpers.buildAction(type(StkGHO_Activation_20240118).creationCode); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); // create proposal vm.startBroadcast(); From 5df6a3e13e8247d80bab97e8bb8b1650473449d7 Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Fri, 19 Jan 2024 16:23:46 +0100 Subject: [PATCH 20/26] fix: Fix AIP payload --- ...3Ethereum_GhoIncidentReport_20231113.t.sol | 4 +-- .../StkGHO_Activation_20240118.sol | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol index dcbfb4659..cdd4517c2 100644 --- a/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol +++ b/src/20231207_AaveV3Ethereum_GhoIncidentReport_20231126/AaveV3Ethereum_GhoIncidentReport_20231113.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {AaveV3EthereumAssets, AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; import {IPoolConfigurator} from 'aave-address-book/AaveV3.sol'; import {AaveV3Ethereum_GhoIncidentReport_20231113} from './AaveV3Ethereum_GhoIncidentReport_20231113.sol'; @@ -28,7 +28,7 @@ contract AaveV3Ethereum_GhoIncidentReport_20231113_Test is ProtocolV3TestBase { function test_defaultProposalExecution() public { // increase GHO borrow cap so test borrows can succeed vm.prank(AaveV3Ethereum.CAPS_PLUS_RISK_STEWARD); - AaveV3Ethereum.POOL_CONFIGURATOR.setBorrowCap(AaveV3Ethereum.GHO_TOKEN, 36_000_000); + AaveV3Ethereum.POOL_CONFIGURATOR.setBorrowCap(AaveV3EthereumAssets.GHO_UNDERLYING, 36_000_000); defaultTest( 'AaveV3Ethereum_GhoIncidentReport_20231113', AaveV3Ethereum.POOL, diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index 88f03c36e..391082c16 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -1,41 +1,41 @@ // SPDX-License-Identifier: MIT - -pragma solidity 0.8.19; +pragma solidity ^0.8.0; import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; -import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; -import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; import {IStakeToken} from './IStakeToken.sol'; /** * @title StkGHO Activation * @author the3d.eth - * - Snapshot: 'https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 + * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 */ contract StkGHO_Activation_20240118 is IProposalGenericExecutor { - uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day - uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months - address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; + uint128 public constant AAVE_EMISSION_PER_SECOND = uint128(50e18) / 1 days; // 50 AAVE per day + uint256 public constant DISTRIBUTION_DURATION = 90 days; // 3 months function execute() external { - IStakeToken(STKGHO_PROXY).setDistributionEnd(block.timestamp + DISTRIBUTION_DURATION); - + // Configure distribution + IStakeToken(AaveSafetyModule.STK_GHO).setDistributionEnd( + block.timestamp + DISTRIBUTION_DURATION + ); IStakeToken.AssetConfigInput[] memory enableConfigs = new IStakeToken.AssetConfigInput[](1); enableConfigs[0] = IStakeToken.AssetConfigInput({ - emissionPerSecond: uint128(STKGHO_EMISSION_PER_SECOND), + emissionPerSecond: AAVE_EMISSION_PER_SECOND, totalStaked: 0, // it's overwritten internally - underlyingAsset: AaveV3Ethereum.GHO_TOKEN + underlyingAsset: AaveSafetyModule.STK_GHO }); + IStakeToken(AaveSafetyModule.STK_GHO).configureAssets(enableConfigs); - IStakeToken(STKGHO_PROXY).configureAssets(enableConfigs); - + // Allowance to pull funds from Ecosystem Reserve MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( MiscEthereum.ECOSYSTEM_RESERVE, AaveV3EthereumAssets.AAVE_UNDERLYING, - STKGHO_PROXY, - STKGHO_EMISSION_PER_SECOND * DISTRIBUTION_DURATION + AaveSafetyModule.STK_GHO, + AAVE_EMISSION_PER_SECOND * DISTRIBUTION_DURATION ); } } From 121b4f40566e6d3648f254da8e27f32804ec8f3f Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Fri, 19 Jan 2024 16:24:31 +0100 Subject: [PATCH 21/26] fix: Fix tests --- .../StkGHO_Activation_20240118.t.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index 8ce60b9f0..a2ada86bd 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -41,7 +41,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { */ function test_defaultProposalExecution() public { (uint128 emissionPerSecondBefore, , ) = IStakeToken(STKGHO_PROXY).assets( - AaveV3Ethereum.GHO_TOKEN + AaveV3EthereumAssets.GHO_UNDERLYING ); GovV3Helpers.executePayload(vm, address(proposal)); @@ -49,7 +49,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { uint128 emissionPerSecondAfter, uint128 lastUpdateTimestampAfter, // uint256 indexAfter - ) = IStakeToken(STKGHO_PROXY).assets(AaveV3Ethereum.GHO_TOKEN); + ) = IStakeToken(STKGHO_PROXY).assets(AaveV3EthereumAssets.GHO_UNDERLYING); // NOTE index is still 0 assertEq((emissionPerSecondBefore + emissionPerSecondAfter), STKGHO_EMISSION_PER_SECOND); From d1e97c6b9ce52615101a16f06c72c61b1cbd7f34 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 18:01:05 +0100 Subject: [PATCH 22/26] test: added further test on emission per day --- lib/aave-helpers | 2 +- .../StkGHO_Activation_20240118.t.sol | 46 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/aave-helpers b/lib/aave-helpers index 1adaebd6f..fae3da081 160000 --- a/lib/aave-helpers +++ b/lib/aave-helpers @@ -1 +1 @@ -Subproject commit 1adaebd6fe409770e3a2d56560e0127df85b3e2e +Subproject commit fae3da0811f41ecb30da1129976c53d15350b895 diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index a2ada86bd..e080fc375 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -19,9 +19,8 @@ import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; * command: make test-contract filter=StkGHO_Activation_20240118 */ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { - uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day - uint256 public constant DISTRIBUTION_DURATION = 3 * 30 * 86400; // three months - address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO; + uint128 public constant AAVE_EMISSION_PER_SECOND = uint128(50e18) / 1 days; // 50 AAVE per day + uint256 public constant DISTRIBUTION_DURATION = 90 days; // 3 months struct Changes { address asset; @@ -40,7 +39,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { - (uint128 emissionPerSecondBefore, , ) = IStakeToken(STKGHO_PROXY).assets( + (uint128 emissionPerSecondBefore, , ) = IStakeToken(AaveSafetyModule.STK_GHO).assets( AaveV3EthereumAssets.GHO_UNDERLYING ); @@ -49,29 +48,54 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { uint128 emissionPerSecondAfter, uint128 lastUpdateTimestampAfter, // uint256 indexAfter - ) = IStakeToken(STKGHO_PROXY).assets(AaveV3EthereumAssets.GHO_UNDERLYING); + ) = IStakeToken(AaveSafetyModule.STK_GHO).assets(AaveSafetyModule.STK_GHO); // NOTE index is still 0 - assertEq((emissionPerSecondBefore + emissionPerSecondAfter), STKGHO_EMISSION_PER_SECOND); + assertEq((emissionPerSecondBefore + emissionPerSecondAfter), AAVE_EMISSION_PER_SECOND); assertEq(lastUpdateTimestampAfter, block.timestamp); } function test_EcosystemCorrectAllowance() public { uint256 allowanceBefore = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( MiscEthereum.ECOSYSTEM_RESERVE, - STKGHO_PROXY + AaveSafetyModule.STK_GHO ); GovV3Helpers.executePayload(vm, address(proposal)); uint256 allowanceAfter = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( MiscEthereum.ECOSYSTEM_RESERVE, - STKGHO_PROXY + AaveSafetyModule.STK_GHO ); - assertEq( - (allowanceAfter + allowanceBefore), - STKGHO_EMISSION_PER_SECOND * DISTRIBUTION_DURATION + assertEq((allowanceAfter + allowanceBefore), AAVE_EMISSION_PER_SECOND * DISTRIBUTION_DURATION); + } + + function test_emission() public { + address prankAddress = 0xF5Fb27b912D987B5b6e02A1B1BE0C1F0740E2c6f; + + uint256 confidenceMargin = 1e6; // margin of error due to rounding + uint256 rewardsPerDay = 50e18; + + GovV3Helpers.executePayload(vm, address(proposal)); + + // impersonating address with AAVE balance + vm.prank(prankAddress); + IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).approve(AaveSafetyModule.STK_GHO, 1e18); + + vm.prank(prankAddress); + IStakeToken(AaveSafetyModule.STK_GHO).stake(prankAddress, 1e18); + + vm.warp(block.timestamp + 1 days); + + vm.prank(prankAddress); + uint256 rewardsBalance = IStakeToken(AaveSafetyModule.STK_GHO).getTotalRewardsBalance( + prankAddress + ); + + assertTrue( + rewardsBalance >= (rewardsPerDay - confidenceMargin) && + rewardsBalance <= (rewardsPerDay + confidenceMargin) ); } } From 8e940ebb7ecfa090ab099ac24c6e4c2e819d119d Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 18:05:40 +0100 Subject: [PATCH 23/26] refactor: removed unused constants --- .../StkGHO_Activation_20240118.s.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 7a043facf..4c840bde1 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -33,10 +33,6 @@ contract DeployEthereum is EthereumScript { * command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:CreateProposal chain=mainnet */ contract CreateProposal is EthereumScript { - uint256 public constant STKGHO_EMISSION_PER_SECOND = 578703703703704; // 50 AAVE/day - uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months - address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO; - function run() external { // create payloads PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); From 33fac2645e2c8c9e8a9b73891d9274b91cc0e920 Mon Sep 17 00:00:00 2001 From: Emilio Frangella Date: Fri, 19 Jan 2024 18:12:10 +0100 Subject: [PATCH 24/26] fix: catapulta commands --- .../StkGHO_Activation_20240118.s.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 4c840bde1..8ad988305 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol @@ -8,8 +8,8 @@ import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; /** * @dev Deploy Ethereum - * deploy-command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:DeployPolygon chain=polygon - * verify-command: npx catapulta-verify -b broadcast/ReserveFactorUpdates_20240102.s.sol/137/run-latest.json + * deploy-command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:DeployEthereum chain=mainnet + * verify-command: npx catapulta-verify -b broadcast/20240118_StkGHO_Activation.s.sol/137/run-latest.json */ contract DeployEthereum is EthereumScript { function run() external broadcast { From c50ff04747663e3c699aa7ef51879a895ded363d Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Fri, 19 Jan 2024 18:22:35 +0100 Subject: [PATCH 25/26] fix: Add fixes to payload --- .../StkGHOActivation.md | 4 +-- .../StkGHO_Activation_20240118.sol | 2 +- .../StkGHO_Activation_20240118.t.sol | 34 +++++++------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/20240118_StkGHO_Activation/StkGHOActivation.md b/src/20240118_StkGHO_Activation/StkGHOActivation.md index 86d3a6b33..b77da0774 100644 --- a/src/20240118_StkGHO_Activation/StkGHOActivation.md +++ b/src/20240118_StkGHO_Activation/StkGHOActivation.md @@ -6,7 +6,7 @@ discussions: "https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkg ## Simple Summary -This AIP activates the new GHO based Safety module by initiating the emission schedule approved by the community during the vote +This AIP activates the new GHO based Safety module by initiating the emission schedule approved by the community during the vote https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 ## Motivation @@ -26,7 +26,7 @@ Duration: Three months ## Disclaimer -Aave Labs, BGD Labs and ACI receive no compensation beyond Aave protocol for the creation of this proposal. BGD Labs and ACI are both delegates within the Aave ecosystem. +Aave Labs, and ACI receive no compensation beyond Aave protocol for the creation of this proposal. ACI is delegate within the Aave ecosystem. ## Copyright diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol index 391082c16..90ac12c23 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -9,7 +9,7 @@ import {IStakeToken} from './IStakeToken.sol'; /** * @title StkGHO Activation - * @author the3d.eth + * @author ACI & Aave Labs (@aave) * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 */ diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index e080fc375..e69a84f1d 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol @@ -1,32 +1,21 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {ProtocolV2TestBase, ReserveConfig} from 'aave-helpers/ProtocolV2TestBase.sol'; -import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; -import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; import 'forge-std/console.sol'; -import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; -import {IStakeToken} from './IStakeToken.sol'; - +import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; -import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; -import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; -import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {IStakeToken} from './IStakeToken.sol'; +import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; /** * @dev Test for StkGHO_Activation_20240118 * command: make test-contract filter=StkGHO_Activation_20240118 */ -contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { - uint128 public constant AAVE_EMISSION_PER_SECOND = uint128(50e18) / 1 days; // 50 AAVE per day - uint256 public constant DISTRIBUTION_DURATION = 90 days; // 3 months - - struct Changes { - address asset; - uint256 reserveFactor; - } - +contract StkGHO_Activation_20240118_Test is ProtocolV3TestBase { StkGHO_Activation_20240118 internal proposal; function setUp() public { @@ -51,11 +40,11 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { ) = IStakeToken(AaveSafetyModule.STK_GHO).assets(AaveSafetyModule.STK_GHO); // NOTE index is still 0 - assertEq((emissionPerSecondBefore + emissionPerSecondAfter), AAVE_EMISSION_PER_SECOND); + assertEq(emissionPerSecondBefore + emissionPerSecondAfter, proposal.AAVE_EMISSION_PER_SECOND()); assertEq(lastUpdateTimestampAfter, block.timestamp); } - function test_EcosystemCorrectAllowance() public { + function test_ecosystemCorrectAllowance() public { uint256 allowanceBefore = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( MiscEthereum.ECOSYSTEM_RESERVE, AaveSafetyModule.STK_GHO @@ -68,7 +57,10 @@ contract StkGHO_Activation_20240118_Test is ProtocolV2TestBase { AaveSafetyModule.STK_GHO ); - assertEq((allowanceAfter + allowanceBefore), AAVE_EMISSION_PER_SECOND * DISTRIBUTION_DURATION); + assertEq( + allowanceAfter - allowanceBefore, + proposal.AAVE_EMISSION_PER_SECOND() * proposal.DISTRIBUTION_DURATION() + ); } function test_emission() public { From 1f79a775a24ba5a7c45fcdda3cd2f1147caf9b1e Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Fri, 19 Jan 2024 18:45:03 +0100 Subject: [PATCH 26/26] fix: Rebuild proposal with autogenerate tool --- .../StkGHOActivation.md | 33 --------------- ...eV3Ethereum_StkGHOActivation_20240119.sol} | 4 +- ...3Ethereum_StkGHOActivation_20240119.t.sol} | 42 ++++++++++--------- .../IStakeToken.sol | 0 .../StkGHOActivation.md | 37 ++++++++++++++++ .../StkGHOActivation_20240119.s.sol} | 20 +++++---- .../config.ts | 9 ++-- 7 files changed, 79 insertions(+), 66 deletions(-) delete mode 100644 src/20240118_StkGHO_Activation/StkGHOActivation.md rename src/{20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol => 20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.sol} (94%) rename src/{20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol => 20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.t.sol} (68%) rename src/{20240118_StkGHO_Activation => 20240119_AaveV3Ethereum_StkGHOActivation}/IStakeToken.sol (100%) create mode 100644 src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation.md rename src/{20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol => 20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol} (61%) rename src/{20240118_StkGHO_Activation => 20240119_AaveV3Ethereum_StkGHOActivation}/config.ts (63%) diff --git a/src/20240118_StkGHO_Activation/StkGHOActivation.md b/src/20240118_StkGHO_Activation/StkGHOActivation.md deleted file mode 100644 index b77da0774..000000000 --- a/src/20240118_StkGHO_Activation/StkGHOActivation.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "GHO Safety Module Initialization" -author: "Aave_BGDLabs_ACI" -discussions: "https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635" ---- - -## Simple Summary - -This AIP activates the new GHO based Safety module by initiating the emission schedule approved by the community during the vote -https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 - -## Motivation - -The GHO Safety Module will fortify the Aave Protocol’s resilience by adding a stablecoin asset, which is inherently less volatile than AAVE. This strategic move diversifies the Safety Module’s capacity to absorb shocks from various risk vectors in case of shortfall events. - -## Specification - -The GHO Safety module will be activated with the following parameters: - -Base emission: 50 AAVE/day -Duration: Three months - -## References - -[TBD] - -## Disclaimer - -Aave Labs, and ACI receive no compensation beyond Aave protocol for the creation of this proposal. ACI is delegate within the Aave ecosystem. - -## Copyright - -Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol b/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.sol similarity index 94% rename from src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol rename to src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.sol index 90ac12c23..cc87e11b6 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.sol @@ -9,11 +9,11 @@ import {IStakeToken} from './IStakeToken.sol'; /** * @title StkGHO Activation - * @author ACI & Aave Labs (@aave) + * @author Aave Labs & ACI * - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065 * - Discussion: https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635 */ -contract StkGHO_Activation_20240118 is IProposalGenericExecutor { +contract AaveV3Ethereum_StkGHOActivation_20240119 is IProposalGenericExecutor { uint128 public constant AAVE_EMISSION_PER_SECOND = uint128(50e18) / 1 days; // 50 AAVE per day uint256 public constant DISTRIBUTION_DURATION = 90 days; // 3 months diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.t.sol similarity index 68% rename from src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol rename to src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.t.sol index e69a84f1d..9ec271373 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol +++ b/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.t.sol @@ -1,38 +1,42 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import 'forge-std/console.sol'; -import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; -import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; + +import 'forge-std/Test.sol'; +import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; import {IStakeToken} from './IStakeToken.sol'; -import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; +import {AaveV3Ethereum_StkGHOActivation_20240119} from './AaveV3Ethereum_StkGHOActivation_20240119.sol'; /** - * @dev Test for StkGHO_Activation_20240118 - * command: make test-contract filter=StkGHO_Activation_20240118 + * @dev Test for AaveV3Ethereum_StkGHOActivation_20240119 + * command: make test-contract filter=AaveV3Ethereum_StkGHOActivation_20240119 */ -contract StkGHO_Activation_20240118_Test is ProtocolV3TestBase { - StkGHO_Activation_20240118 internal proposal; +contract AaveV3Ethereum_StkGHOActivation_20240119_Test is ProtocolV3TestBase { + AaveV3Ethereum_StkGHOActivation_20240119 internal proposal; function setUp() public { - vm.createSelectFork(vm.rpcUrl('mainnet'), 19040576); - - proposal = new StkGHO_Activation_20240118(); + vm.createSelectFork(vm.rpcUrl('mainnet'), 19042382); + proposal = new AaveV3Ethereum_StkGHOActivation_20240119(); } /** * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { + defaultTest('AaveV3Ethereum_StkGHOActivation_20240119', AaveV3Ethereum.POOL, address(proposal)); + } + + function test_checkConfig() public { (uint128 emissionPerSecondBefore, , ) = IStakeToken(AaveSafetyModule.STK_GHO).assets( AaveV3EthereumAssets.GHO_UNDERLYING ); - GovV3Helpers.executePayload(vm, address(proposal)); + executePayload(vm, address(proposal)); + ( uint128 emissionPerSecondAfter, uint128 lastUpdateTimestampAfter, // uint256 indexAfter @@ -44,13 +48,13 @@ contract StkGHO_Activation_20240118_Test is ProtocolV3TestBase { assertEq(lastUpdateTimestampAfter, block.timestamp); } - function test_ecosystemCorrectAllowance() public { + function test_checkAllowance() public { uint256 allowanceBefore = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( MiscEthereum.ECOSYSTEM_RESERVE, AaveSafetyModule.STK_GHO ); - GovV3Helpers.executePayload(vm, address(proposal)); + executePayload(vm, address(proposal)); uint256 allowanceAfter = IERC20(AaveV3EthereumAssets.AAVE_UNDERLYING).allowance( MiscEthereum.ECOSYSTEM_RESERVE, @@ -63,24 +67,22 @@ contract StkGHO_Activation_20240118_Test is ProtocolV3TestBase { ); } - function test_emission() public { + function test_checkRewards() public { address prankAddress = 0xF5Fb27b912D987B5b6e02A1B1BE0C1F0740E2c6f; uint256 confidenceMargin = 1e6; // margin of error due to rounding uint256 rewardsPerDay = 50e18; - GovV3Helpers.executePayload(vm, address(proposal)); + executePayload(vm, address(proposal)); // impersonating address with AAVE balance - vm.prank(prankAddress); + vm.startPrank(prankAddress); IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).approve(AaveSafetyModule.STK_GHO, 1e18); - vm.prank(prankAddress); IStakeToken(AaveSafetyModule.STK_GHO).stake(prankAddress, 1e18); vm.warp(block.timestamp + 1 days); - vm.prank(prankAddress); uint256 rewardsBalance = IStakeToken(AaveSafetyModule.STK_GHO).getTotalRewardsBalance( prankAddress ); @@ -89,5 +91,7 @@ contract StkGHO_Activation_20240118_Test is ProtocolV3TestBase { rewardsBalance >= (rewardsPerDay - confidenceMargin) && rewardsBalance <= (rewardsPerDay + confidenceMargin) ); + + vm.stopPrank(); } } diff --git a/src/20240118_StkGHO_Activation/IStakeToken.sol b/src/20240119_AaveV3Ethereum_StkGHOActivation/IStakeToken.sol similarity index 100% rename from src/20240118_StkGHO_Activation/IStakeToken.sol rename to src/20240119_AaveV3Ethereum_StkGHOActivation/IStakeToken.sol diff --git a/src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation.md b/src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation.md new file mode 100644 index 000000000..c71fbc237 --- /dev/null +++ b/src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation.md @@ -0,0 +1,37 @@ +--- +title: "StkGHO Activation" +author: "Aave Labs & ACI" +discussions: "https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635" +--- + +## Simple Summary + +This AIP activates the new GHO based Safety module by initiating the emission schedule approved by the community during the [Snapshot vote](https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065) + +## Motivation + +The GHO Safety Module will fortify the Aave Protocol’s resilience by adding a stablecoin asset, which is inherently less volatile than AAVE. This strategic move diversifies the Safety Module’s capacity to absorb shocks from various risk vectors in case of shortfall events. + +## Specification + +The GHO Safety module will be activated with the following parameters: + +- Base emission: 50 AAVE/day +- Duration: Three months + +## References + +- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.sol) +- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240119_AaveV3Ethereum_StkGHOActivation/AaveV3Ethereum_StkGHOActivation_20240119.t.sol) +- [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065) +- [Discussion](https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635) +- [StkGHO](https://etherscan.io/address/0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d) +- [StakeToken Repository](https://github.com/bgd-labs/stake-token) + +## Disclaimer + +Aave Labs, and ACI receive no compensation beyond Aave protocol for the creation of this proposal. ACI is delegate within the Aave ecosystem. + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol b/src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol similarity index 61% rename from src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol rename to src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol index 8ad988305..a37a72673 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol +++ b/src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol @@ -3,19 +3,18 @@ pragma solidity ^0.8.0; import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; -import {StkGHO_Activation_20240118} from './StkGHO_Activation_20240118.sol'; -import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; +import {AaveV3Ethereum_StkGHOActivation_20240119} from './AaveV3Ethereum_StkGHOActivation_20240119.sol'; /** * @dev Deploy Ethereum - * deploy-command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:DeployEthereum chain=mainnet - * verify-command: npx catapulta-verify -b broadcast/20240118_StkGHO_Activation.s.sol/137/run-latest.json + * deploy-command: make deploy-ledger contract=src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol:DeployEthereum chain=mainnet + * verify-command: npx catapulta-verify -b broadcast/StkGHOActivation_20240119.s.sol/1/run-latest.json */ contract DeployEthereum is EthereumScript { function run() external broadcast { // deploy payloads address payload0 = GovV3Helpers.deployDeterministic( - type(StkGHO_Activation_20240118).creationCode + type(AaveV3Ethereum_StkGHOActivation_20240119).creationCode ); // compose action @@ -30,7 +29,7 @@ contract DeployEthereum is EthereumScript { /** * @dev Create Proposal - * command: make deploy-ledger contract=src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol:CreateProposal chain=mainnet + * command: make deploy-ledger contract=src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation_20240119.s.sol:CreateProposal chain=mainnet */ contract CreateProposal is EthereumScript { function run() external { @@ -40,7 +39,9 @@ contract CreateProposal is EthereumScript { // compose actions for validation IPayloadsControllerCore.ExecutionAction[] memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); - actionsEthereum[0] = GovV3Helpers.buildAction(type(StkGHO_Activation_20240118).creationCode); + actionsEthereum[0] = GovV3Helpers.buildAction( + type(AaveV3Ethereum_StkGHOActivation_20240119).creationCode + ); payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); // create proposal @@ -48,7 +49,10 @@ contract CreateProposal is EthereumScript { GovV3Helpers.createProposal( vm, payloads, - GovV3Helpers.ipfsHashFile(vm, 'src/StkGHO_Activation_20240118/StkGHOActivation.md') + GovV3Helpers.ipfsHashFile( + vm, + 'src/20240119_AaveV3Ethereum_StkGHOActivation/StkGHOActivation.md' + ) ); } } diff --git a/src/20240118_StkGHO_Activation/config.ts b/src/20240119_AaveV3Ethereum_StkGHOActivation/config.ts similarity index 63% rename from src/20240118_StkGHO_Activation/config.ts rename to src/20240119_AaveV3Ethereum_StkGHOActivation/config.ts index cbe143fe4..5323ef21e 100644 --- a/src/20240118_StkGHO_Activation/config.ts +++ b/src/20240119_AaveV3Ethereum_StkGHOActivation/config.ts @@ -4,10 +4,11 @@ export const config: ConfigFile = { pools: ['AaveV3Ethereum'], title: 'StkGHO Activation', shortName: 'StkGHOActivation', - date: '20240118', - author: 'Bgdlabs_Aave_ACI', + date: '20240119', + author: 'Aave Labs & ACI', discussion: 'https://governance.aave.com/t/arfc-upgrade-safety-module-with-stkgho/15635', - snapshot: 'https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065', + snapshot: + 'https://snapshot.org/#/aave.eth/proposal/0x4bc99a842adab6cdd8c7d5c7a787ee4c0056be554fde0d008d53b45b3e795065', }, - poolOptions: {AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 51855274}}}, + poolOptions: {AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 19042382}}}, };