Skip to content

Commit

Permalink
Merge pull request #12 from aave/feat/proposal-revision-stk
Browse files Browse the repository at this point in the history
Feat/proposal revision stk
  • Loading branch information
The-3D authored Jan 19, 2024
2 parents 79f2011 + 6d58d1f commit 0ac9c62
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/20240118_StkGHO_Activation/IStakeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
18 changes: 9 additions & 9 deletions src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -29,30 +30,29 @@ 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);

// 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
vm.startBroadcast();
GovV3Helpers.createProposal(
vm,
payloads,
GovV3Helpers.ipfsHashFile(
vm,
'src/StkGHO_Activation_20240118/StkGHOActivation.md'
)
GovV3Helpers.ipfsHashFile(vm, 'src/StkGHO_Activation_20240118/StkGHOActivation.md')
);
}
}
10 changes: 3 additions & 7 deletions src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 48 additions & 3 deletions src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,15 +31,47 @@ 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();
}

/**
* @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
);
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "0.2.1"
Expand Down

0 comments on commit 0ac9c62

Please sign in to comment.