|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import 'solidity-utils/contracts/utils/ScriptUtils.sol'; |
| 5 | +import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; |
| 6 | +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; |
| 7 | +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; |
| 8 | +import {ICreate3Factory} from 'solidity-utils/contracts/create3/interfaces/ICreate3Factory.sol'; |
| 9 | +import {EdgeRiskStewardDiscountRate, IRiskSteward} from '../../src/contracts/EdgeRiskStewardDiscountRate.sol'; |
| 10 | +import {AaveStewardInjectorDiscountRate} from '../../src/contracts/AaveStewardInjectorDiscountRate.sol'; |
| 11 | + |
| 12 | +library DeployStewardContracts { |
| 13 | + struct DeployStewardInput { |
| 14 | + address pool; |
| 15 | + address configEngine; |
| 16 | + address riskCouncil; |
| 17 | + address owner; |
| 18 | + } |
| 19 | + |
| 20 | + struct DeployInjectorInput { |
| 21 | + address create3Factory; |
| 22 | + bytes32 salt; |
| 23 | + address riskSteward; |
| 24 | + address aaveOracle; |
| 25 | + address edgeRiskOracle; |
| 26 | + address owner; |
| 27 | + address guardian; |
| 28 | + address[] whitelistedMarkets; |
| 29 | + } |
| 30 | + |
| 31 | + function _deployRiskStewards( |
| 32 | + DeployStewardInput memory input |
| 33 | + ) internal returns (address) { |
| 34 | + address riskSteward = address( |
| 35 | + new EdgeRiskStewardDiscountRate(input.pool, input.configEngine, input.riskCouncil, input.owner, _getRiskConfig()) |
| 36 | + ); |
| 37 | + return riskSteward; |
| 38 | + } |
| 39 | + |
| 40 | + function _deployDiscountRateStewardInjector( |
| 41 | + DeployInjectorInput memory input |
| 42 | + ) internal returns (address) { |
| 43 | + address stewardInjector = ICreate3Factory(input.create3Factory).create( |
| 44 | + input.salt, |
| 45 | + abi.encodePacked( |
| 46 | + type(AaveStewardInjectorDiscountRate).creationCode, |
| 47 | + abi.encode(input.aaveOracle, input.edgeRiskOracle, input.riskSteward, input.whitelistedMarkets, input.owner, input.guardian) |
| 48 | + ) |
| 49 | + ); |
| 50 | + return stewardInjector; |
| 51 | + } |
| 52 | + |
| 53 | + function _getRiskConfig() internal pure returns (IRiskSteward.Config memory) { |
| 54 | + IRiskSteward.Config memory config; |
| 55 | + config.priceCapConfig.discountRatePendle = IRiskSteward.RiskParamConfig({ |
| 56 | + minDelay: 2 days, |
| 57 | + maxPercentChange: 0.01e18 // 1% |
| 58 | + }); |
| 59 | + |
| 60 | + return config; |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +// make deploy-ledger contract=scripts/deploy/DeployDiscountRateInjector.s.sol:DeployEthereum chain=mainnet |
| 65 | +contract DeployEthereum is EthereumScript { |
| 66 | + address constant GUARDIAN = 0xff37939808EcF199A2D599ef91D699Fb13dab7F7; |
| 67 | + address constant EDGE_RISK_ORACLE = 0x7ABB46C690C52E919687D19ebF89C81A6136C1F2; |
| 68 | + |
| 69 | + function run() external { |
| 70 | + vm.startBroadcast(); |
| 71 | + bytes32 salt = 'DiscountRateStewardInjector'; |
| 72 | + address predictedStewardsInjector = ICreate3Factory(MiscEthereum.CREATE_3_FACTORY) |
| 73 | + .predictAddress(msg.sender, salt); |
| 74 | + |
| 75 | + address riskSteward = DeployStewardContracts._deployRiskStewards( |
| 76 | + DeployStewardContracts.DeployStewardInput({ |
| 77 | + pool: address(AaveV3Ethereum.POOL), |
| 78 | + configEngine: AaveV3Ethereum.CONFIG_ENGINE, |
| 79 | + riskCouncil: predictedStewardsInjector, |
| 80 | + owner: GovernanceV3Ethereum.EXECUTOR_LVL_1 |
| 81 | + }) |
| 82 | + ); |
| 83 | + |
| 84 | + address[] memory whitelistedPendleAssets = new address[](3); |
| 85 | + whitelistedPendleAssets[0] = AaveV3EthereumAssets.PT_sUSDE_31JUL2025_UNDERLYING; |
| 86 | + whitelistedPendleAssets[1] = AaveV3EthereumAssets.PT_USDe_31JUL2025_UNDERLYING; |
| 87 | + whitelistedPendleAssets[2] = AaveV3EthereumAssets.PT_eUSDE_14AUG2025_UNDERLYING; |
| 88 | + |
| 89 | + DeployStewardContracts._deployDiscountRateStewardInjector( |
| 90 | + DeployStewardContracts.DeployInjectorInput({ |
| 91 | + create3Factory: MiscEthereum.CREATE_3_FACTORY, |
| 92 | + salt: salt, |
| 93 | + riskSteward: riskSteward, |
| 94 | + aaveOracle: address(AaveV3Ethereum.ORACLE), |
| 95 | + edgeRiskOracle: EDGE_RISK_ORACLE, |
| 96 | + owner: GovernanceV3Ethereum.EXECUTOR_LVL_1, |
| 97 | + guardian: GUARDIAN, |
| 98 | + whitelistedMarkets: whitelistedPendleAssets |
| 99 | + }) |
| 100 | + ); |
| 101 | + vm.stopBroadcast(); |
| 102 | + } |
| 103 | +} |
0 commit comments