generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add proposal for Gho Incident Report 20231113 (#1) * chore: add payload and deploy script for update of GHO variable debt token * forge install: gho-core * chore: add gho-core to dependency * test: Add tests for update of gho variable token * test: Add tests for update of gho variable token * fix: add modifier in method of interface * fix: remove gho dependency from repo and fix test * fix: Remove unnecesary dependency * fix: Add latest details --------- Co-authored-by: miguelmtzinf <miguelmtz.mail@gmail.com> * fix: Make new impl constant (#3) * fix: Amend AIP text (#4) * fix: Make new impl constant * fix: Fix AIP text * test: Tweak default tests with borrow cap update (#5) * fix: lint issue (#6) * test: Add diffs from test running (#7) * fix: Add payload address (#8) * fix: Fix payload address in script (#9) * fix: Remove unneeded diff file (#10) * feat: Add payload * test: Add tests * feat: Add script and tests with final addresses * fix: Fix link and gasLimit amounts * fix: Update dependencies * fix: Fix oracle swap freezer addresses * fix: Bump block number for tests * fix: Reduce LINK amount so its enough in treasury * add test for OracleSwapFreezer * fix: Clean up in tests * docs: Add AIP text * docs: Fix typo in natspec docs Co-authored-by: Harsh Pandey <harshsatishpandey@gmail.com> * fix: Fix typo on natspec docs Co-authored-by: Harsh Pandey <harshsatishpandey@gmail.com> * docs: Fix typo in natspec docs * fix: Add DAO as swap freezer --------- Co-authored-by: Parth Patel <parth4321patel@gmail.com> Co-authored-by: Harsh Pandey <harshsatishpandey@gmail.com>
- Loading branch information
1 parent
012e357
commit 0f4c6e7
Showing
6 changed files
with
611 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: "GHO Stability Module" | ||
author: "Aave Labs @aave" | ||
discussions: "https://governance.aave.com/t/gho-stability-module-update/14442" | ||
--- | ||
|
||
## Simple Summary | ||
|
||
This AIP proposes the deployment of the GHO Stability Module (GSM), a system facilitating the conversion between GHO and two governance-accepted stablecoins, USDC and USDT, at a predetermined ratio. | ||
|
||
The GSM has undergone thorough iterations of design, development, testing, and implementation with Aave Labs driving this process and actively seeking community feedback. Additionally, the security aspect was carefully addressed through collaboration with DAO service providers SigmaPrime and Certora for code reviews. Furthermore, an extra layer of security was added by commissioning an independent review from a security researcher (Emanuele Ricci [@stermi](https://governance.aave.com/u/stermi/summary)). | ||
|
||
Following extensive community discussion and multiple phases of Aave DAO governance, this AIP suggests deploying two GSM contracts for seamless conversions between GHO and USDC as well as GHO and USDT. | ||
|
||
## Motivation | ||
|
||
The GHO Stability Module (GSM) is a contract designed to facilitate conversions between two tokens with its primary purpose being to help further maintain GHO's peg. The module allows swaps between GHO and other governance-accepted stablecoins, offering a variety of functionalities that make it paramount in the fields of security and risk management. | ||
|
||
Summarizing the functionality offered by the GHO Stability Module (GSM), here is a list of these features and their planned implementation for this proposal: | ||
|
||
- **Exposure Cap**: Denominated in token units, it limits exposure to the exogenous asset. | ||
- **Price Strategies**: Utilizing a fixed price strategy with a 1:1 ratio for stablecoins. | ||
- **Fee Strategies**: Employing a flat basis point (bps) approach, differentiated by direction (sell/buy). | ||
- **Last Resort Liquidation**: Aave DAO is the exclusive entity granted with the role of last resort liquidation, empowering it to take control of GSM funds in worst-case scenarios. | ||
- **Swap Freeze**: Aave DAO and a chainlink-automated keeper contract have the authority to freeze the swap functionality. The chainlink-automated keeper contract bases its actions on the price of the exogenous asset, freezing if the price is outside the range and unfreezing if inside the range. | ||
- **Capital Allocation**: Supporting this feature by allowing ERC4626 assets as underlying assets. This enables redirecting the yield generated by the ERC4626 asset, while residing in the GSM contract, to the GHO Treasury. | ||
|
||
## Specification | ||
|
||
The proposed payload entails the comprehensive activation of GSM USDC and GSM USDT, involving the following steps: | ||
|
||
1. Incorporate GSM USDC and GSM USDT as facilitators of the GHO Token on Ethereum. | ||
2. Adjust the Fee Strategy for both GSMs to implement a 0.2% flat fee for both directions (buy/sell). | ||
3. Add both GSMs to the GSM Registry. | ||
4. Designate OracleSwapFreezer contracts and Aave DAO as SwapFreezer entities in each GSM contract, respectively. | ||
5. Activate these OracleSwapFreezer contracts as keepers of the Aave DAO through AaveRobot with a funding of 80 LINK for each. | ||
|
||
The table below outlines the initially proposed risk parameters for each GSM contract, as approved through the snapshot: | ||
|
||
**GSM USDC** | ||
| Parameter | Value | | ||
|------------------------------------------ |----------------- | | ||
| Underlying Price Range for Swap Freeze | [0.99 - 1.01] | | ||
| Underlying Price Range for Swap Unfreeze | [0.995 - 1.005] | | ||
| Buy Fee | 0.2% | | ||
| Sell Fee | 0.2% | | ||
| Exposure Cap | 500,000 USDC | | ||
| Facilitator Bucket Capacity | 500,000 GHO | | ||
| Swap Active | True | | ||
|
||
**GSM USDT** | ||
| Parameter | Value | | ||
|------------------------------------------ |----------------- | | ||
| Underlying Price Range for Swap Freeze | [0.99 - 1.01] | | ||
| Underlying Price Range for Swap Unfreeze | [0.995 - 1.005] | | ||
| Buy Fee | 0.2% | | ||
| Sell Fee | 0.2% | | ||
| Exposure Cap | 500,000 USDT | | ||
| Facilitator Bucket Capacity | 500,000 GHO | | ||
| Swap Active | True | | ||
|
||
## References | ||
|
||
- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240119_Gho_GHOStabilityModule/AaveV3Ethereum_GHOStabilityModule_20240119.sol) | ||
- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240119_Gho_GHOStabilityModule/AaveV3Ethereum_GHOStabilityModule_20240119.t.sol) | ||
- [Snapshot](https://snapshot.org/#/aave.eth/proposal/0xe9b62e197a98832da7d1231442b5960588747f184415fba4699b6325d7618842) | ||
- [Discussion](https://governance.aave.com/t/gho-stability-module-update/14442) | ||
- [GSM Repository](https://github.com/aave/gho-core/tree/main/src/contracts/facilitators/gsm) | ||
- [GSM Audit Reports](https://github.com/aave/gho-core/tree/main/audits) | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
55 changes: 55 additions & 0 deletions
55
src/20240119_Gho_GHOStabilityModule/GHOStabilityModule_20240119.s.sol
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; | ||
import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; | ||
import {Gho_GHOStabilityModule_20240119} from './Gho_GHOStabilityModule_20240119.sol'; | ||
|
||
/** | ||
* @dev Deploy Ethereum | ||
* deploy-command: make deploy-ledger contract=src/20240119_Gho_GHOStabilityModule/GHOStabilityModule_20240119.s.sol:DeployEthereum chain=mainnet | ||
* verify-command: npx catapulta-verify -b broadcast/GHOStabilityModule_20240119.s.sol/1/run-latest.json | ||
*/ | ||
contract DeployEthereum is EthereumScript { | ||
function run() external broadcast { | ||
// deploy payloads | ||
address payload0 = GovV3Helpers.deployDeterministic( | ||
type(Gho_GHOStabilityModule_20240119).creationCode | ||
); | ||
|
||
// compose action | ||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actions = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actions[0] = GovV3Helpers.buildAction(payload0); | ||
|
||
// register action at payloadsController | ||
GovV3Helpers.createPayload(actions); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Create Proposal | ||
* command: make deploy-ledger contract=src/20240119_Gho_GHOStabilityModule/GHOStabilityModule_20240119.s.sol:CreateProposal chain=mainnet | ||
*/ | ||
contract CreateProposal is EthereumScript { | ||
function run() external { | ||
// create payloads | ||
PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); | ||
|
||
// compose actions for validation | ||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actionsEthereum[0] = GovV3Helpers.buildAction( | ||
type(Gho_GHOStabilityModule_20240119).creationCode | ||
); | ||
payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); | ||
|
||
// create proposal | ||
vm.startBroadcast(); | ||
GovV3Helpers.createProposal( | ||
vm, | ||
payloads, | ||
GovV3Helpers.ipfsHashFile(vm, 'src/20240119_Gho_GHOStabilityModule/GHOStabilityModule.md') | ||
); | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
src/20240119_Gho_GHOStabilityModule/Gho_GHOStabilityModule_20240119.sol
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 |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; | ||
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; | ||
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; | ||
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; | ||
import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; | ||
|
||
interface IGhoToken { | ||
function addFacilitator( | ||
address facilitatorAddress, | ||
string calldata facilitatorLabel, | ||
uint128 bucketCapacity | ||
) external; | ||
} | ||
|
||
interface IGsm { | ||
function updateFeeStrategy(address feeStrategy) external; | ||
|
||
function SWAP_FREEZER_ROLE() external pure returns (bytes32); | ||
|
||
function grantRole(bytes32 role, address account) external; | ||
} | ||
|
||
interface IGsmRegistry { | ||
function addGsm(address gsmAddress) external; | ||
} | ||
|
||
interface IAaveCLRobotOperator { | ||
function register( | ||
string memory name, | ||
address upkeepContract, | ||
uint32 gasLimit, | ||
uint96 amountToFund | ||
) external returns (uint256); | ||
} | ||
|
||
/** | ||
* @title GHO Stability Module | ||
* @author Aave labs (@aave) | ||
* @dev This proposal enables 2 GHO Stability Modules (USDC, USDT): | ||
* - Addition of USDC and USDT GSMs as GHO Facilitators | ||
* - Give Swap Freezer permissions to OracleSwapFreezers, one per module | ||
* - Give Swap Freezer permissions to the DAO Level 1 Executor | ||
* - Install a 0.2% fee strategy into both modules | ||
* - Register both GSMs in the GsmRegistry | ||
* - Activate OracleSwapFreezer contracts as AaveRobot Keepers | ||
* Relevant governance links: | ||
* 1. GHO Stability Module | ||
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x98bdd30f645b2981320f82c671ae9fee31ee771766c13cd2627b66a22f0d438e | ||
* - Discussion: https://governance.aave.com/t/temp-check-gho-stability-module/13927 | ||
* 2. GHO Stability Module Update | ||
* - Discussion: https://governance.aave.com/t/gho-stability-module-update/14442 | ||
* 3. GHO Stability Module Launch | ||
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0xe9b62e197a98832da7d1231442b5960588747f184415fba4699b6325d7618842 | ||
*/ | ||
contract Gho_GHOStabilityModule_20240119 is IProposalGenericExecutor { | ||
using SafeERC20 for IERC20; | ||
|
||
address public constant GSM_USDC = 0x0d8eFfC11dF3F229AA1EA0509BC9DFa632A13578; | ||
address public constant GSM_USDC_ORACLE_SWAP_FREEZER = 0xef6beCa8D9543eC007bceA835aF768B58F730C1f; | ||
address public constant GSM_USDT = 0x686F8D21520f4ecEc7ba577be08354F4d1EB8262; | ||
address public constant GSM_USDT_ORACLE_SWAP_FREEZER = 0x71381e6718b37C12155CB961Ca3D374A8BfFa0e5; | ||
address public constant GSM_REGISTRY = 0x167527DB01325408696326e3580cd8e55D99Dc1A; | ||
address public constant GSM_FIXED_FEE_STRATEGY = 0xD4478A76aCeA81D3768A0ACB6e38f25eEB6Eb1B5; | ||
|
||
string public constant GSM_USDC_FACILITATOR_LABEL = 'GSM USDC'; | ||
uint128 public constant GSM_USDC_BUCKET_CAPACITY = 500_000e18; | ||
string public constant GSM_USDT_FACILITATOR_LABEL = 'GSM USDT'; | ||
uint128 public constant GSM_USDT_BUCKET_CAPACITY = 500_000e18; | ||
|
||
address public constant ROBOT_OPERATOR = 0x020E452b463568f55BAc6Dc5aFC8F0B62Ea5f0f3; | ||
uint96 public constant LINK_AMOUNT_ORACLE_FREEZER_KEEPER = 80 ether; | ||
uint96 public constant TOTAL_LINK_AMOUNT_KEEPERS = LINK_AMOUNT_ORACLE_FREEZER_KEEPER * 2; // 2 GSMs | ||
uint32 public constant KEEPER_GAS_LIMIT = 150_000; | ||
|
||
function execute() external { | ||
// 1. Enroll GSMs as GHO Facilitators | ||
IGhoToken(MiscEthereum.GHO_TOKEN).addFacilitator( | ||
GSM_USDC, | ||
GSM_USDC_FACILITATOR_LABEL, | ||
GSM_USDC_BUCKET_CAPACITY | ||
); | ||
IGhoToken(MiscEthereum.GHO_TOKEN).addFacilitator( | ||
GSM_USDT, | ||
GSM_USDT_FACILITATOR_LABEL, | ||
GSM_USDT_BUCKET_CAPACITY | ||
); | ||
|
||
// 2. Add GSM Swap Freezer role to OracleSwapFreezers | ||
IGsm(GSM_USDC).grantRole(IGsm(GSM_USDC).SWAP_FREEZER_ROLE(), GSM_USDC_ORACLE_SWAP_FREEZER); | ||
IGsm(GSM_USDT).grantRole(IGsm(GSM_USDT).SWAP_FREEZER_ROLE(), GSM_USDT_ORACLE_SWAP_FREEZER); | ||
IGsm(GSM_USDC).grantRole( | ||
IGsm(GSM_USDC).SWAP_FREEZER_ROLE(), | ||
GovernanceV3Ethereum.EXECUTOR_LVL_1 | ||
); | ||
IGsm(GSM_USDT).grantRole( | ||
IGsm(GSM_USDT).SWAP_FREEZER_ROLE(), | ||
GovernanceV3Ethereum.EXECUTOR_LVL_1 | ||
); | ||
|
||
// 3. Update Fee Strategy | ||
IGsm(GSM_USDC).updateFeeStrategy(GSM_FIXED_FEE_STRATEGY); | ||
IGsm(GSM_USDT).updateFeeStrategy(GSM_FIXED_FEE_STRATEGY); | ||
|
||
// 4. Add GSMs to GSM Registry | ||
IGsmRegistry(GSM_REGISTRY).addGsm(GSM_USDC); | ||
IGsmRegistry(GSM_REGISTRY).addGsm(GSM_USDT); | ||
|
||
// 5. Register OracleSwapFreezer as keepers | ||
AaveV3Ethereum.COLLECTOR.transfer( | ||
AaveV3EthereumAssets.LINK_UNDERLYING, | ||
address(this), | ||
TOTAL_LINK_AMOUNT_KEEPERS | ||
); | ||
IERC20(AaveV3EthereumAssets.LINK_UNDERLYING).forceApprove( | ||
ROBOT_OPERATOR, | ||
TOTAL_LINK_AMOUNT_KEEPERS | ||
); | ||
|
||
IAaveCLRobotOperator(ROBOT_OPERATOR).register( | ||
'GHO GSM USDC OracleSwapFreezer', | ||
GSM_USDC_ORACLE_SWAP_FREEZER, | ||
KEEPER_GAS_LIMIT, | ||
LINK_AMOUNT_ORACLE_FREEZER_KEEPER | ||
); | ||
IAaveCLRobotOperator(ROBOT_OPERATOR).register( | ||
'GHO GSM USDT OracleSwapFreezer', | ||
GSM_USDT_ORACLE_SWAP_FREEZER, | ||
KEEPER_GAS_LIMIT, | ||
LINK_AMOUNT_ORACLE_FREEZER_KEEPER | ||
); | ||
} | ||
} |
Oops, something went wrong.
0f4c6e7
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.
Foundry report
Build log
Test success 🌈