generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade to new staked token (#4)
* feat: deploy first oracle * fix: update imports * fix: add new stake-token * fix: upgrade code * fix: update tests * fix: use addresses from address book * fix: use aave from address book * fix: update to latest version * Update src/libs/GenericProposal.sol * Apply suggestions from code review Co-authored-by: Ernesto Boado <ebdmrr@gmail.com> * Update src/contracts/StkABPTMigrator.sol Co-authored-by: Ernesto Boado <ebdmrr@gmail.com> * fix: use selector * fix: remove comment * fix: remove proportional migration * fix: add balance checks to prevent draining donation * fix: use executor-lvl1 as referral * fix: remove duplicate import * fix: remove unused import * fix: add a few more migration tests * fix: add emission end * Update scripts/01_DeployStkAbptV2Impl.sol Co-authored-by: Ernesto Boado <ebdmrr@gmail.com> * fix: use default create --------- Co-authored-by: Ernesto Boado <ebdmrr@gmail.com>
- Loading branch information
Showing
14 changed files
with
191 additions
and
286 deletions.
There are no files selected for viewing
This file contains 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 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
Submodule aave-address-book
deleted from
b87a51
Submodule aave-helpers
updated
214 files
Submodule aave-stk-gov-v3
deleted from
748cde
Submodule stake-token
added at
f42de8
This file contains 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,11 +1,11 @@ | ||
aave-address-book/=lib/aave-address-book/src/ | ||
aave-address-book/=lib/aave-helpers/lib/aave-address-book/src/ | ||
aave-helpers/=lib/aave-helpers/src/ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
forge-std/=lib/aave-helpers/lib/forge-std/src/ | ||
solidity-utils/=lib/solidity-utils/src/ | ||
aave-v3-periphery/=lib/aave-v3-periphery/contracts/ | ||
aave-v3-core/=lib/aave-address-book/lib/aave-v3-core/ | ||
aave-stk-gov-v3/=lib/aave-stk-gov-v3/src/ | ||
aave-v3-periphery/=lib/aave-helpers/lib/aave-v3-periphery/contracts/ | ||
aave-v3-core/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/ | ||
stake-token/=lib/stake-token/src/ | ||
stk-no-cooldown/=lib/stk-no-cooldown/src/ | ||
aave-token-v3/=lib/aave-stk-gov-v3/lib/aave-token-v3/src | ||
openzeppelin-contracts/=lib/aave-stk-gov-v3/lib/aave-token-v3/lib/openzeppelin-contracts | ||
aave-token-v3/=lib/stake-token/lib/aave-token-v3/src | ||
openzeppelin-contracts/=lib/stake-token/lib/openzeppelin-contracts |
This file contains 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 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 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,82 +1,79 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import {AaveMisc} from 'aave-address-book/AaveMisc.sol'; | ||
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; | ||
import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; | ||
import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; | ||
import {GenericProposal} from '../libs/GenericProposal.sol'; | ||
import {DistributionTypes} from 'aave-stk-gov-v3/lib/DistributionTypes.sol'; | ||
import {IAaveDistributionManager} from 'aave-stk-gov-v3/interfaces/IAaveDistributionManager.sol'; | ||
import {Vault} from '../interfaces/Actions.sol'; | ||
import {Addresses} from '../libs/Addresses.sol'; | ||
import {DistributionTypes} from 'stake-token/contracts/lib/DistributionTypes.sol'; | ||
import {IAaveDistributionManager} from 'stake-token/contracts/IAaveDistributionManager.sol'; | ||
import {IAggregatedStakeToken} from 'stake-token/contracts/IAggregatedStakeToken.sol'; | ||
import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {AaveSafetyModule} from 'aave-address-book/AaveSafetyModule.sol'; | ||
|
||
/** | ||
* @title StkABPTV2 Proposal | ||
* @author BGD Labs | ||
* @notice migrates emissions to a new stkABPT | ||
*/ | ||
contract ProposalPayload { | ||
address public constant AAVE = Addresses.AAVE; | ||
address public constant WSTETH = Addresses.WSTETH; | ||
address public constant STK_ABPT_V1 = Addresses.STK_ABPT_V1; | ||
Vault public constant VAULT = Vault(Addresses.BALANCER_VAULT); | ||
uint256 public constant EMISSION_PER_SECOND = 4456018518518518; // same as current | ||
|
||
address public immutable STK_ABPT_V1_IMPL; | ||
address public immutable STK_ABPT_V2_IMPL; | ||
address public immutable STK_ABPT_V2_PROXY; | ||
|
||
constructor(address newStkABPTV1Impl, address newStkABPTV2Impl, address stkABPTV2Proxy) { | ||
constructor(address newStkABPTV1Impl, address stkABPTV2Proxy) { | ||
STK_ABPT_V1_IMPL = newStkABPTV1Impl; | ||
STK_ABPT_V2_IMPL = newStkABPTV2Impl; | ||
STK_ABPT_V2_PROXY = stkABPTV2Proxy; | ||
} | ||
|
||
function execute() external { | ||
// 1. stop emission on module v1 | ||
// 1. disable cooldown by upgrading the impl | ||
ProxyAdmin(MiscEthereum.PROXY_ADMIN).upgradeAndCall( | ||
TransparentUpgradeableProxy(payable(AaveSafetyModule.STK_ABPT)), | ||
STK_ABPT_V1_IMPL, | ||
abi.encodeWithSignature('initialize()') | ||
); | ||
|
||
// 2. stop emission on module v1 | ||
DistributionTypes.AssetConfigInput[] | ||
memory disableConfigs = new DistributionTypes.AssetConfigInput[](1); | ||
disableConfigs[0] = DistributionTypes.AssetConfigInput({ | ||
emissionPerSecond: 0, | ||
totalStaked: 0, // it's overwritten internally | ||
underlyingAsset: STK_ABPT_V1 | ||
underlyingAsset: AaveSafetyModule.STK_ABPT | ||
}); | ||
IAaveDistributionManager(STK_ABPT_V1).configureAssets(disableConfigs); | ||
|
||
// 2. disable cooldown by upgrading the impl | ||
ProxyAdmin(AaveMisc.PROXY_ADMIN_ETHEREUM).upgradeAndCall( | ||
TransparentUpgradeableProxy(payable(STK_ABPT_V1)), | ||
STK_ABPT_V1_IMPL, | ||
abi.encodeWithSignature('initialize()') | ||
IAaveDistributionManager(AaveSafetyModule.STK_ABPT).configureAssets(disableConfigs); | ||
MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( | ||
MiscEthereum.ECOSYSTEM_RESERVE, | ||
AaveV3EthereumAssets.AAVE_UNDERLYING, | ||
AaveSafetyModule.STK_ABPT, | ||
0 | ||
); | ||
|
||
// 3. create new SM | ||
ProxyAdmin(AaveMisc.PROXY_ADMIN_ETHEREUM).upgradeAndCall( | ||
TransparentUpgradeableProxy(payable(STK_ABPT_V2_PROXY)), | ||
STK_ABPT_V2_IMPL, | ||
abi.encodeWithSignature( | ||
'initialize(address,address,address,uint256,uint256)', | ||
GenericProposal.SLASHING_ADMIN, | ||
GenericProposal.COOLDOWN_ADMIN, | ||
GenericProposal.CLAIM_HELPER, | ||
GenericProposal.MAX_SLASHING, | ||
GenericProposal.COOLDOWN_SECONDS | ||
) | ||
MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( | ||
MiscEthereum.ECOSYSTEM_RESERVE, | ||
AaveV3EthereumAssets.AAVE_UNDERLYING, | ||
AaveSafetyModule.STK_ABPT, | ||
15_000 ether // rough estimation on total claimable + emission until execution | ||
); | ||
|
||
// 4. start emission on module v2 | ||
AaveMisc.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( | ||
AaveMisc.ECOSYSTEM_RESERVE, | ||
AAVE, | ||
STK_ABPT_V2_PROXY, | ||
180_000 ether // TODO: what is the correct value here? | ||
// 3. start emission on module v2 | ||
IAggregatedStakeToken(STK_ABPT_V2_PROXY).setDistributionEnd( | ||
block.timestamp + GenericProposal.DISTRIBUTION_DURATION | ||
); | ||
DistributionTypes.AssetConfigInput[] | ||
memory enableConfigs = new DistributionTypes.AssetConfigInput[](1); | ||
enableConfigs[0] = DistributionTypes.AssetConfigInput({ | ||
emissionPerSecond: 6365740740740741, // same as current | ||
emissionPerSecond: uint128(EMISSION_PER_SECOND), | ||
totalStaked: 0, // it's overwritten internally | ||
underlyingAsset: STK_ABPT_V2_PROXY | ||
}); | ||
IAaveDistributionManager(STK_ABPT_V2_PROXY).configureAssets(enableConfigs); | ||
MiscEthereum.AAVE_ECOSYSTEM_RESERVE_CONTROLLER.approve( | ||
MiscEthereum.ECOSYSTEM_RESERVE, | ||
AaveV3EthereumAssets.AAVE_UNDERLYING, | ||
STK_ABPT_V2_PROXY, | ||
EMISSION_PER_SECOND * GenericProposal.DISTRIBUTION_DURATION | ||
); | ||
} | ||
} |
Oops, something went wrong.