Skip to content

Commit

Permalink
chore: sync
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka committed Jan 19, 2024
2 parents 1062d67 + 79f2011 commit fd43d71
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 15 deletions.
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[submodule "lib/aave-helpers"]
path = lib/aave-helpers
url = https://github.com/bgd-labs/aave-helpers

1 change: 0 additions & 1 deletion lib/stake-token
Submodule stake-token deleted from e6530c
194 changes: 194 additions & 0 deletions src/20240118_StkGHO_Activation/IStakeToken.sol
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol';

Expand All @@ -11,7 +11,7 @@ import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol';
* 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 {
contract DeployEthereum is EthereumScript {
function run() external broadcast {
// deploy payloads
address payload0 = GovV3Helpers.deployDeterministic(
Expand Down
21 changes: 10 additions & 11 deletions src/20240118_StkGHO_Activation/StkGHO_Activation_20240118.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +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 {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol';
import {IStakeToken} from './IStakeToken.sol';

/**
* @title StkGHO Activation
Expand All @@ -18,20 +15,22 @@ import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.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 = 578703703703704; // 50 AAVE/day
uint256 public constant STKGHO_EMISSION_PER_SECOND = 5787037037037037; // 50 AAVE/day
uint256 public constant DISTRIBUTION_DURATION = 90 days; // three months
address public constant STKGHO_PROXY = 0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d; // AaveSafetyModule.STK_GHO;
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({
IStakeToken(STKGHO_PROXY).setDistributionEnd(block.timestamp + DISTRIBUTION_DURATION);

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,
Expand Down

0 comments on commit fd43d71

Please sign in to comment.