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/IStakeToken.sol b/src/20240118_StkGHO_Activation/IStakeToken.sol index a677ed29f..412bb2301 100644 --- a/src/20240118_StkGHO_Activation/IStakeToken.sol +++ b/src/20240118_StkGHO_Activation/IStakeToken.sol @@ -191,4 +191,4 @@ interface IStakeToken { 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.s.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol index 983dfbae2..0fcc9b036 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} 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 DeployEthereum is EthereumScript { @@ -29,9 +30,13 @@ contract DeployEthereum is EthereumScript { /** * @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,9 +44,7 @@ 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 - ); + actionsPolygon[0] = GovV3Helpers.buildAction(type(StkGHO_Activation_20240118).creationCode); payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsPolygon); // create proposal @@ -49,10 +52,7 @@ contract CreateProposal is EthereumScript { 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 08d74af9d..88f03c36e 100644 --- a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol +++ b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol @@ -15,18 +15,14 @@ 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; function execute() external { - - IStakeToken(STKGHO_PROXY).setDistributionEnd( - block.timestamp + DISTRIBUTION_DURATION - ); + IStakeToken(STKGHO_PROXY).setDistributionEnd(block.timestamp + DISTRIBUTION_DURATION); - IStakeToken.AssetConfigInput[] - memory enableConfigs = new IStakeToken.AssetConfigInput[](1); + IStakeToken.AssetConfigInput[] memory enableConfigs = new IStakeToken.AssetConfigInput[](1); enableConfigs[0] = IStakeToken.AssetConfigInput({ emissionPerSecond: uint128(STKGHO_EMISSION_PER_SECOND), totalStaked: 0, // it's overwritten internally diff --git a/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol b/src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol index e5935f5e7..8ce60b9f0 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 {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'; +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, , ) = IStakeToken(STKGHO_PROXY).assets( + AaveV3Ethereum.GHO_TOKEN + ); + + GovV3Helpers.executePayload(vm, address(proposal)); + ( + uint128 emissionPerSecondAfter, + uint128 lastUpdateTimestampAfter, // uint256 indexAfter + + ) = IStakeToken(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"