-
Notifications
You must be signed in to change notification settings - Fork 60
Feat/emergency shutdown #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LHerskind
wants to merge
19
commits into
feat/slash
Choose a base branch
from
feat/emergency-shutdown
base: feat/slash
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fe32727
feat: Add modifier for emergencies to functions
LHerskind e501dd3
fix: Update emergency modifier usage + access control to emergency sh…
LHerskind 51c34de
fix: Update hardhat + dotenv
LHerskind 1b8d8bd
test: Add governance proposal test
LHerskind 90f2105
fix: Increment revision + `upgradeToAndCall`
LHerskind 786acee
test: Add additional tests
LHerskind df3da1d
fix: Use newer block for proposal testing
LHerskind 17c255d
fix: Add StakeAbptV3 implementation + update payload
LHerskind 0f3ece6
fix: Update proposal test to update both staked assets
LHerskind cca2a0f
fix: Sanitise package.json
LHerskind 06196e6
fix: Introduce dynamic domain separator
LHerskind e2b327c
fix: Add additional check for reward accrual
LHerskind fa3654e
fix: Use cached `DOMAIN_SEPARATOR` when same chain id as initialize
LHerskind 5845ec2
fix: Fix tests for chainId and remove comment
LHerskind 104b432
fix: Remove dead code + params from StakedTokenV3 initialize
LHerskind 02bf958
Merge pull request #21 from aave/fix/20-adaptive-domain-separator
LHerskind c7d6ea9
refactor: Simplify cooldown to use `super`
LHerskind 5f0e0d2
test: Add test for cooldown and redeem after proposal
LHerskind b44feec
fix: Shadowing in `StakedTokenV2::getNextCooldownTimestamp()`
LHerskind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import '@aave/governance-v2/contracts/governance/Executor.sol'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,105 +1 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0 | ||
| pragma solidity 0.7.5; | ||
| pragma abicoder v2; | ||
|
|
||
| // simplified interface to expose functions added events for tests | ||
| interface IAaveGovernanceV2 { | ||
| struct Vote { | ||
| bool support; | ||
| uint248 votingPower; | ||
| } | ||
|
|
||
| /** | ||
| Added for test purposes | ||
| **/ | ||
| event ReserveInitialized( | ||
| address indexed asset, | ||
| address indexed aToken, | ||
| address stableDebtToken, | ||
| address variableDebtToken, | ||
| address interestRateStrategyAddress | ||
| ); | ||
| enum ProposalState {Pending, Canceled, Active, Failed, Succeeded, Queued, Expired, Executed} | ||
|
|
||
| /** | ||
| * @dev Creates a Proposal (needs Proposition Power of creator > Threshold) | ||
| * @param executor The ExecutorWithTimelock contract that will execute the proposal | ||
| * @param targets list of contracts called by proposal's associated transactions | ||
| * @param values list of value in wei for each propoposal's associated transaction | ||
| * @param signatures list of function signatures (can be empty) to be used when created the callData | ||
| * @param calldatas list of calldatas: if associated signature empty, calldata ready, else calldata is arguments | ||
| * @param withDelegatecalls if true, transaction delegatecalls the taget, else calls the target | ||
| * @param ipfsHash IPFS hash of the proposal | ||
| **/ | ||
| function create( | ||
| address executor, | ||
| address[] memory targets, | ||
| uint256[] memory values, | ||
| string[] memory signatures, | ||
| bytes[] memory calldatas, | ||
| bool[] memory withDelegatecalls, | ||
| bytes32 ipfsHash | ||
| ) external returns (uint256); | ||
|
|
||
| /** | ||
| * @dev Cancels a Proposal, | ||
| * either at anytime by guardian | ||
| * or when proposal is Pending/Active and threshold no longer reached | ||
| * @param proposalId id of the proposal | ||
| **/ | ||
| function cancel(uint256 proposalId) external; | ||
|
|
||
| /** | ||
| * @dev Queue the proposal (If Proposal Succeeded) | ||
| * @param proposalId id of the proposal to queue | ||
| **/ | ||
| function queue(uint256 proposalId) external; | ||
|
|
||
| /** | ||
| * @dev Execute the proposal (If Proposal Queued) | ||
| * @param proposalId id of the proposal to execute | ||
| **/ | ||
| function execute(uint256 proposalId) external payable; | ||
|
|
||
| /** | ||
| * @dev Function allowing msg.sender to vote for/against a proposal | ||
| * @param proposalId id of the proposal | ||
| * @param support boolean, true = vote for, false = vote against | ||
| **/ | ||
| function submitVote(uint256 proposalId, bool support) external; | ||
|
|
||
| /** | ||
| * @dev Function to register the vote of user that has voted offchain via signature | ||
| * @param proposalId id of the proposal | ||
| * @param support boolean, true = vote for, false = vote against | ||
| * @param v v part of the voter signature | ||
| * @param r r part of the voter signature | ||
| * @param s s part of the voter signature | ||
| **/ | ||
| function submitVoteBySignature( | ||
| uint256 proposalId, | ||
| bool support, | ||
| uint8 v, | ||
| bytes32 r, | ||
| bytes32 s | ||
| ) external; | ||
|
|
||
| /** | ||
| * @dev Getter of the proposal count (the current number of proposals ever created) | ||
| * @return the proposal count | ||
| **/ | ||
| function getProposalsCount() external view returns (uint256); | ||
|
|
||
| function getProposalState(uint256 proposalId) external view returns (ProposalState); | ||
|
|
||
| function getGuardian() external view returns (address); | ||
|
|
||
| /** | ||
| * @dev Getter of the Vote of a voter about a proposal | ||
| * Note: Vote is a struct: ({bool support, uint248 votingPower}) | ||
| * @param proposalId id of the proposal | ||
| * @param voter address of the voter | ||
| * @return The associated Vote memory object | ||
| **/ | ||
| function getVoteOnProposal(uint256 proposalId, address voter) external view returns (Vote memory); | ||
| } | ||
| import '@aave/governance-v2/contracts/interfaces/IAaveGovernanceV2.sol'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| pragma solidity ^0.7.5; | ||
|
|
||
| interface IBaseAdminUpgradabilityProxy { | ||
| function upgradeTo(address newImplementation) external; | ||
|
|
||
| function upgradeToAndCall(address newImplementation, bytes calldata data) external; | ||
|
|
||
| function implementation() external returns (address); | ||
|
|
||
| function admin() external returns (address); | ||
|
|
||
| function changeAdmin(address newAdmin) external; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0 | ||
| pragma solidity 0.7.5; | ||
| pragma abicoder v2; | ||
|
|
||
| import {IBaseAdminUpgradabilityProxy} from './../interfaces/IBaseAdminUpgradabilityProxy.sol'; | ||
|
|
||
| contract StakeTokenUpgradeProposalExecutor { | ||
| address constant SHORT_EXECUTOR = address(0xEE56e2B3D491590B5b31738cC34d5232F378a8D5); | ||
|
|
||
| // TODO: Replace immutable with constant address when implementations are deployed | ||
| // TODO: replace claimhelper for the real address when decided decided | ||
| address immutable NEW_STAKED_AAVE_TOKEN_IMPLEMENTATION; | ||
| address immutable NEW_STAKED_ABP_TOKEN_IMPLEMENTATION; | ||
| address constant CLAIM_HELPER = SHORT_EXECUTOR; | ||
|
|
||
| address constant SLASHING_ADMIN = SHORT_EXECUTOR; | ||
| address constant COOLDOWN_PAUSE_ADMIN = SHORT_EXECUTOR; | ||
| uint256 constant MAX_SLASHABLE_PERCENTAGE = 3000; | ||
|
|
||
| IBaseAdminUpgradabilityProxy constant STAKED_AAVE_TOKEN_PROXY = | ||
| IBaseAdminUpgradabilityProxy(0x4da27a545c0c5B758a6BA100e3a049001de870f5); | ||
| IBaseAdminUpgradabilityProxy constant STAKED_ABP_TOKEN_PROXY = | ||
| IBaseAdminUpgradabilityProxy(0xa1116930326D21fB917d5A27F1E9943A9595fb47); | ||
|
|
||
| constructor(address newStakedAaveTokenImplementation, address newStakedAbpTokenImplementation) { | ||
| NEW_STAKED_AAVE_TOKEN_IMPLEMENTATION = newStakedAaveTokenImplementation; | ||
| NEW_STAKED_ABP_TOKEN_IMPLEMENTATION = newStakedAbpTokenImplementation; | ||
| } | ||
|
|
||
| function execute() external { | ||
| _upgradeStakedAave(); | ||
| _upgradeStakedAbpt(); | ||
| } | ||
|
|
||
| function _upgradeStakedAave() internal { | ||
| bytes memory params = abi.encodeWithSignature( | ||
| 'initialize(address,address,address,uint256)', | ||
| SLASHING_ADMIN, | ||
| COOLDOWN_PAUSE_ADMIN, | ||
| CLAIM_HELPER, | ||
| MAX_SLASHABLE_PERCENTAGE | ||
| ); | ||
|
|
||
| STAKED_AAVE_TOKEN_PROXY.upgradeToAndCall(NEW_STAKED_AAVE_TOKEN_IMPLEMENTATION, params); | ||
| } | ||
|
|
||
| function _upgradeStakedAbpt() internal { | ||
| bytes memory params = abi.encodeWithSignature( | ||
| 'initialize(address,address,address,uint256)', | ||
| SLASHING_ADMIN, | ||
| COOLDOWN_PAUSE_ADMIN, | ||
| CLAIM_HELPER, | ||
| MAX_SLASHABLE_PERCENTAGE | ||
| ); | ||
|
|
||
| STAKED_ABP_TOKEN_PROXY.upgradeToAndCall(NEW_STAKED_ABP_TOKEN_IMPLEMENTATION, params); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // SPDX-License-Identifier: agpl-3.0 | ||
| pragma solidity 0.7.5; | ||
| pragma experimental ABIEncoderV2; | ||
|
|
||
| import {IERC20} from '../interfaces/IERC20.sol'; | ||
| import {StakedTokenV3} from './StakedTokenV3.sol'; | ||
|
|
||
| /** | ||
| * @title StakedAbptV3 | ||
| * @notice StakedTokenV3 with Aave Balance Pool token as staked token | ||
| * @author Aave | ||
| **/ | ||
| contract StakedAbptV3 is StakedTokenV3 { | ||
| string internal constant NAME = 'Staked Aave Balance Pool Token'; | ||
| string internal constant SYMBOL = 'stkABPT'; | ||
| uint8 internal constant DECIMALS = 18; | ||
|
|
||
| constructor( | ||
| IERC20 stakedToken, | ||
| IERC20 rewardToken, | ||
| uint256 cooldownSeconds, | ||
| uint256 unstakeWindow, | ||
| address rewardsVault, | ||
| address emissionManager, | ||
| uint128 distributionDuration, | ||
| address governance | ||
| ) | ||
| public | ||
| StakedTokenV3( | ||
| stakedToken, | ||
| rewardToken, | ||
| cooldownSeconds, | ||
| unstakeWindow, | ||
| rewardsVault, | ||
| emissionManager, | ||
| distributionDuration, | ||
| NAME, | ||
| SYMBOL, | ||
| DECIMALS, | ||
| governance | ||
| ) | ||
| {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems clearer to fix the address here directly (instead of using the constructor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed when we have an implementation that is deployed.
Using the constructor for passing freshly deployed implementation made testing easier.