generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: no same updates or all keep current * fix: no same update for capo * feat: add edge risk steward * chore: fix lint * chore: add risk oracle contract * feat: add stewards injector and fix remappings * test: stewards injector * test: isUpdatedIdExecuted * test: expiredUpdate * test: some more injector tests * test: edge risk steward * refactor: rename method * feat: add writeup * test: add missing tests * fix: script for coverage * chore: deploy scripts * fix: deploy script * feat: simplify injector * fix: update contracts to v3.2 and adjust imports and remappings * chore: update readme * fix: certora remapping * chore: update readme from suggestion Co-authored-by: Ernesto Boado <[email protected]> * chore: update readme from suggestion Co-authored-by: Ernesto Boado <[email protected]> * chore: update readme from suggestion Co-authored-by: Ernesto Boado <[email protected]> * fix: remove revert on sameUpdate and all keepCurrent * chore: fix lint * chore: fix typo in writeup * fix: generator imports and update address book * fix: stewards base * chore: add risk oracle to deploy script --------- Co-authored-by: Ernesto Boado <[email protected]>
- Loading branch information
1 parent
3fd7b75
commit 650d51e
Showing
42 changed files
with
1,544 additions
and
132 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Submodule aave-helpers
updated
77 files
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,9 +1,8 @@ | ||
aave-helpers/=lib/aave-helpers/ | ||
forge-std/=lib/aave-helpers/lib/forge-std/src/ | ||
aave-address-book/=lib/aave-helpers/lib/aave-address-book/src/ | ||
solidity-utils/=lib/aave-helpers/lib/solidity-utils/src/ | ||
aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/ | ||
aave-v3-core/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/core | ||
aave-v3-periphery/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/periphery | ||
solidity-utils/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/src/ | ||
lib/aave-helpers:aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src | ||
aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/ | ||
aave-capo/=lib/aave-capo/src | ||
lib/aave-capo:cl-synchronicity-price-adapter/=lib/aave-capo/lib/cl-synchronicity-price-adapter/src/ |
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import 'solidity-utils/contracts/utils/ScriptUtils.sol'; | ||
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; | ||
import {AaveV3EthereumLido, AaveV3EthereumLidoAssets} from 'aave-address-book/AaveV3EthereumLido.sol'; | ||
import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; | ||
import {ICreate3Factory} from 'solidity-utils/contracts/create3/interfaces/ICreate3Factory.sol'; | ||
import {IOwnable} from 'aave-address-book/common/IOwnable.sol'; | ||
import {EdgeRiskSteward, IRiskSteward, IPoolDataProvider, IEngine} from '../../src/contracts/EdgeRiskSteward.sol'; | ||
import {AaveStewardInjector, IAaveStewardInjector} from '../../src/contracts/AaveStewardInjector.sol'; | ||
|
||
library DeployStewardContracts { | ||
address constant EDGE_RISK_ORACLE = 0x7ABB46C690C52E919687D19ebF89C81A6136C1F2; | ||
|
||
function _deployRiskStewards( | ||
address poolDataProvider, | ||
address configEngine, | ||
address riskCouncil, | ||
address governance | ||
) internal returns (address) { | ||
address riskSteward = address(new EdgeRiskSteward( | ||
IPoolDataProvider(poolDataProvider), | ||
IEngine(configEngine), | ||
riskCouncil, | ||
_getRiskConfig() | ||
)); | ||
IOwnable(riskSteward).transferOwnership(governance); | ||
return riskSteward; | ||
} | ||
|
||
function _deployStewardsInjector( | ||
bytes32 salt, | ||
address riskSteward, | ||
address guardian, | ||
address whitelistedAsset | ||
) internal returns (address) { | ||
address stewardInjector = ICreate3Factory(MiscEthereum.CREATE_3_FACTORY).create( | ||
salt, | ||
abi.encodePacked( | ||
type(AaveStewardInjector).creationCode, | ||
abi.encode( | ||
EDGE_RISK_ORACLE, | ||
riskSteward, | ||
guardian, | ||
whitelistedAsset | ||
) | ||
) | ||
); | ||
return stewardInjector; | ||
} | ||
|
||
function _getRiskConfig() internal pure returns (IRiskSteward.Config memory) { | ||
return IRiskSteward.Config({ | ||
ltv: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 25}), | ||
liquidationThreshold: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 25}), | ||
liquidationBonus: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 50}), | ||
supplyCap: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 100_00}), | ||
borrowCap: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 100_00}), | ||
debtCeiling: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 20_00}), | ||
baseVariableBorrowRate: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 50}), | ||
variableRateSlope1: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 50}), | ||
variableRateSlope2: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 5_00}), | ||
optimalUsageRatio: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 3_00}), | ||
priceCapLst: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 5_00}), | ||
priceCapStable: IRiskSteward.RiskParamConfig({minDelay: 1 days, maxPercentChange: 50}) | ||
}); | ||
} | ||
} | ||
|
||
// make deploy-ledger contract=scripts/deploy/DeployInjector.s.sol:DeployEthereumLido chain=mainnet | ||
contract DeployEthereumLido is EthereumScript { | ||
address constant GUARDIAN = 0xff37939808EcF199A2D599ef91D699Fb13dab7F7; | ||
|
||
function run() external { | ||
vm.startBroadcast(); | ||
bytes32 salt = 'StewardInjector'; | ||
address predictedStewardsInjector = ICreate3Factory(MiscEthereum.CREATE_3_FACTORY).predictAddress(msg.sender, salt); | ||
|
||
address riskSteward = DeployStewardContracts._deployRiskStewards( | ||
address(AaveV3EthereumLido.AAVE_PROTOCOL_DATA_PROVIDER), | ||
AaveV3EthereumLido.CONFIG_ENGINE, | ||
predictedStewardsInjector, | ||
GovernanceV3Ethereum.EXECUTOR_LVL_1 | ||
); | ||
|
||
DeployStewardContracts._deployStewardsInjector(salt, riskSteward, GUARDIAN, AaveV3EthereumLidoAssets.WETH_UNDERLYING); | ||
vm.stopBroadcast(); | ||
} | ||
} |
Oops, something went wrong.