diff --git a/contracts/contracts/strategies/AaveStrategy.sol b/contracts/contracts/strategies/AaveStrategy.sol index 85f56dc112..e8eb623eaa 100644 --- a/contracts/contracts/strategies/AaveStrategy.sol +++ b/contracts/contracts/strategies/AaveStrategy.sol @@ -22,12 +22,17 @@ contract AaveStrategy is InitializableAbstractStrategy { IAaveIncentivesController public incentivesController; IAaveStakedToken public stkAave; + /** + * @param _stratConfig The platform and OToken vault addresses + */ + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * Initializer for setting up strategy internal state. This overrides the * InitializableAbstractStrategy initializer as AAVE needs several extra * addresses for the rewards program. - * @param _platformAddress Address of the AAVE pool - * @param _vaultAddress Address of the vault * @param _rewardTokenAddresses Address of the AAVE token * @param _assets Addresses of supported assets * @param _pTokens Platform Token corresponding addresses @@ -35,8 +40,6 @@ contract AaveStrategy is InitializableAbstractStrategy { * @param _stkAaveAddress Address of the stkAave contract */ function initialize( - address _platformAddress, // AAVE pool - address _vaultAddress, address[] calldata _rewardTokenAddresses, // AAVE address[] calldata _assets, address[] calldata _pTokens, @@ -46,8 +49,6 @@ contract AaveStrategy is InitializableAbstractStrategy { incentivesController = IAaveIncentivesController(_incentivesAddress); stkAave = IAaveStakedToken(_stkAaveAddress); InitializableAbstractStrategy._initialize( - _platformAddress, - _vaultAddress, _rewardTokenAddresses, _assets, _pTokens diff --git a/contracts/contracts/strategies/BaseConvexMetaStrategy.sol b/contracts/contracts/strategies/BaseConvexMetaStrategy.sol index 87a8f6ce12..ecb5d5b9b0 100644 --- a/contracts/contracts/strategies/BaseConvexMetaStrategy.sol +++ b/contracts/contracts/strategies/BaseConvexMetaStrategy.sol @@ -18,6 +18,7 @@ import { Helpers } from "../utils/Helpers.sol"; abstract contract BaseConvexMetaStrategy is BaseCurveStrategy { using StableMath for uint256; using SafeERC20 for IERC20; + event MaxWithdrawalSlippageUpdated( uint256 _prevMaxSlippagePercentage, uint256 _newMaxSlippagePercentage @@ -25,8 +26,6 @@ abstract contract BaseConvexMetaStrategy is BaseCurveStrategy { // used to circumvent the stack too deep issue struct InitConfig { - address platformAddress; //Address of the Curve 3pool - address vaultAddress; //Address of the vault address cvxDepositorAddress; //Address of the Convex depositor(AKA booster) for this pool address metapoolAddress; //Address of the Curve MetaPool address metapoolMainToken; //Address of Main metapool token @@ -82,13 +81,7 @@ abstract contract BaseConvexMetaStrategy is BaseCurveStrategy { metapoolAssets = [metapool.coins(0), metapool.coins(1)]; crvCoinIndex = _getMetapoolCoinIndex(pTokenAddress); mainCoinIndex = _getMetapoolCoinIndex(initConfig.metapoolMainToken); - super._initialize( - initConfig.platformAddress, - initConfig.vaultAddress, - _rewardTokenAddresses, - _assets, - _pTokens - ); + super._initialize(_rewardTokenAddresses, _assets, _pTokens); _approveBase(); } diff --git a/contracts/contracts/strategies/CompoundStrategy.sol b/contracts/contracts/strategies/CompoundStrategy.sol index e615235954..65f8d46907 100644 --- a/contracts/contracts/strategies/CompoundStrategy.sol +++ b/contracts/contracts/strategies/CompoundStrategy.sol @@ -9,7 +9,7 @@ pragma solidity ^0.8.0; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ICERC20 } from "./ICompound.sol"; -import { BaseCompoundStrategy } from "./BaseCompoundStrategy.sol"; +import { BaseCompoundStrategy, InitializableAbstractStrategy } from "./BaseCompoundStrategy.sol"; import { IComptroller } from "../interfaces/IComptroller.sol"; import { IERC20 } from "../utils/InitializableAbstractStrategy.sol"; @@ -17,6 +17,10 @@ contract CompoundStrategy is BaseCompoundStrategy { using SafeERC20 for IERC20; event SkippedWithdrawal(address asset, uint256 amount); + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * @dev Collect accumulated COMP and send to Harvester. */ diff --git a/contracts/contracts/strategies/ConvexEthMetaStrategy.sol b/contracts/contracts/strategies/ConvexEthMetaStrategy.sol index cf40c66df0..79e4b4eb1e 100644 --- a/contracts/contracts/strategies/ConvexEthMetaStrategy.sol +++ b/contracts/contracts/strategies/ConvexEthMetaStrategy.sol @@ -38,7 +38,6 @@ contract ConvexEthMetaStrategy is InitializableAbstractStrategy { // used to circumvent the stack too deep issue struct InitializeConfig { address curvePoolAddress; //Address of the Curve pool - address vaultAddress; //Address of the vault address cvxDepositorAddress; //Address of the Convex depositor(AKA booster) for this pool address oethAddress; //Address of OETH token address cvxRewardStakerAddress; //Address of the CVX rewards staker @@ -46,6 +45,10 @@ contract ConvexEthMetaStrategy is InitializableAbstractStrategy { uint256 cvxDepositorPTokenId; //Pid of the pool referred to by Depositor and staker } + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * Initializer for setting up strategy internal state. This overrides the * InitializableAbstractStrategy initializer as Curve strategies don't fit @@ -75,13 +78,7 @@ contract ConvexEthMetaStrategy is InitializableAbstractStrategy { ethCoinIndex = uint128(_getCoinIndex(ETH_ADDRESS)); oethCoinIndex = uint128(_getCoinIndex(initConfig.oethAddress)); - super._initialize( - initConfig.curvePoolAddress, - initConfig.vaultAddress, - _rewardTokenAddresses, - _assets, - _pTokens - ); + super._initialize(_rewardTokenAddresses, _assets, _pTokens); /* needs to be called after super._initialize so that the platformAddress * is correctly set diff --git a/contracts/contracts/strategies/ConvexGeneralizedMetaStrategy.sol b/contracts/contracts/strategies/ConvexGeneralizedMetaStrategy.sol index 2dbed89c36..e56aa03aa2 100644 --- a/contracts/contracts/strategies/ConvexGeneralizedMetaStrategy.sol +++ b/contracts/contracts/strategies/ConvexGeneralizedMetaStrategy.sol @@ -12,7 +12,7 @@ import "@openzeppelin/contracts/utils/Strings.sol"; import { IRewardStaking } from "./IRewardStaking.sol"; import { IConvexDeposits } from "./IConvexDeposits.sol"; import { ICurvePool } from "./ICurvePool.sol"; -import { IERC20 } from "./BaseCurveStrategy.sol"; +import { IERC20, InitializableAbstractStrategy } from "./BaseCurveStrategy.sol"; import { BaseConvexMetaStrategy } from "./BaseConvexMetaStrategy.sol"; import { StableMath } from "../utils/StableMath.sol"; @@ -20,6 +20,10 @@ contract ConvexGeneralizedMetaStrategy is BaseConvexMetaStrategy { using StableMath for uint256; using SafeERC20 for IERC20; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /* Take 3pool LP and deposit it to metapool. Take the LP from metapool * and deposit them to Convex. */ diff --git a/contracts/contracts/strategies/ConvexOUSDMetaStrategy.sol b/contracts/contracts/strategies/ConvexOUSDMetaStrategy.sol index 34a1313eb0..742e8050b1 100644 --- a/contracts/contracts/strategies/ConvexOUSDMetaStrategy.sol +++ b/contracts/contracts/strategies/ConvexOUSDMetaStrategy.sol @@ -13,7 +13,7 @@ import "@openzeppelin/contracts/utils/math/Math.sol"; import { IRewardStaking } from "./IRewardStaking.sol"; import { IConvexDeposits } from "./IConvexDeposits.sol"; import { ICurvePool } from "./ICurvePool.sol"; -import { IERC20 } from "./BaseCurveStrategy.sol"; +import { IERC20, InitializableAbstractStrategy } from "./BaseCurveStrategy.sol"; import { BaseConvexMetaStrategy } from "./BaseConvexMetaStrategy.sol"; import { StableMath } from "../utils/StableMath.sol"; import { IVault } from "../interfaces/IVault.sol"; @@ -22,6 +22,10 @@ contract ConvexOUSDMetaStrategy is BaseConvexMetaStrategy { using StableMath for uint256; using SafeERC20 for IERC20; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /* Take 3pool LP and mint the corresponding amount of ousd. Deposit and stake that to * ousd Curve Metapool. Take the LP from metapool and deposit them to Convex. */ diff --git a/contracts/contracts/strategies/ConvexStrategy.sol b/contracts/contracts/strategies/ConvexStrategy.sol index e4f82ca4b9..d8350ed943 100644 --- a/contracts/contracts/strategies/ConvexStrategy.sol +++ b/contracts/contracts/strategies/ConvexStrategy.sol @@ -11,7 +11,7 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s import { ICurvePool } from "./ICurvePool.sol"; import { IRewardStaking } from "./IRewardStaking.sol"; import { IConvexDeposits } from "./IConvexDeposits.sol"; -import { IERC20, BaseCurveStrategy } from "./BaseCurveStrategy.sol"; +import { IERC20, BaseCurveStrategy, InitializableAbstractStrategy } from "./BaseCurveStrategy.sol"; import { StableMath } from "../utils/StableMath.sol"; import { Helpers } from "../utils/Helpers.sol"; @@ -32,12 +32,14 @@ contract ConvexStrategy is BaseCurveStrategy { address public _deprecated_cvxRewardTokenAddress; uint256 internal cvxDepositorPTokenId; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * Initializer for setting up strategy internal state. This overrides the * InitializableAbstractStrategy initializer as Curve strategies don't fit * well within that abstraction. - * @param _platformAddress Address of the Curve 3pool - * @param _vaultAddress Address of the vault * @param _rewardTokenAddresses Address of CRV & CVX * @param _assets Addresses of supported assets. MUST be passed in the same * order as returned by coins on the pool contract, i.e. @@ -48,8 +50,6 @@ contract ConvexStrategy is BaseCurveStrategy { * @param _cvxDepositorPTokenId Pid of the pool referred to by Depositor and staker */ function initialize( - address _platformAddress, // 3Pool address - address _vaultAddress, address[] calldata _rewardTokenAddresses, // CRV + CVX address[] calldata _assets, address[] calldata _pTokens, @@ -65,13 +65,7 @@ contract ConvexStrategy is BaseCurveStrategy { cvxDepositorPTokenId = _cvxDepositorPTokenId; pTokenAddress = _pTokens[0]; - super._initialize( - _platformAddress, - _vaultAddress, - _rewardTokenAddresses, - _assets, - _pTokens - ); + super._initialize(_rewardTokenAddresses, _assets, _pTokens); _approveBase(); } diff --git a/contracts/contracts/strategies/FraxETHStrategy.sol b/contracts/contracts/strategies/FraxETHStrategy.sol index 48b5831268..fc25b1ae74 100644 --- a/contracts/contracts/strategies/FraxETHStrategy.sol +++ b/contracts/contracts/strategies/FraxETHStrategy.sol @@ -8,10 +8,9 @@ pragma solidity ^0.8.0; */ import { IERC4626 } from "../../lib/openzeppelin/interfaces/IERC4626.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { IERC20 } from "../utils/InitializableAbstractStrategy.sol"; import { IWETH9 } from "../interfaces/IWETH9.sol"; import { IFraxETHMinter } from "../interfaces/IFraxETHMinter.sol"; -import { Generalized4626Strategy } from "./Generalized4626Strategy.sol"; +import { Generalized4626Strategy, IERC20 } from "./Generalized4626Strategy.sol"; contract FraxETHStrategy is Generalized4626Strategy { using SafeERC20 for IERC20; @@ -21,6 +20,10 @@ contract FraxETHStrategy is Generalized4626Strategy { IFraxETHMinter public constant fraxETHMinter = IFraxETHMinter(0xbAFA44EFE7901E04E39Dad13167D089C559c1138); + constructor(BaseStrategyConfig memory _stratConfig) + Generalized4626Strategy(_stratConfig) + {} + function _deposit(address _asset, uint256 _amount) internal override { require(_amount > 0, "Must deposit something"); diff --git a/contracts/contracts/strategies/Generalized4626Strategy.sol b/contracts/contracts/strategies/Generalized4626Strategy.sol index eb0fa13257..5388ab82dc 100644 --- a/contracts/contracts/strategies/Generalized4626Strategy.sol +++ b/contracts/contracts/strategies/Generalized4626Strategy.sol @@ -19,6 +19,10 @@ contract Generalized4626Strategy is InitializableAbstractStrategy { // For future use uint256[50] private __gap; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * @dev Deposit assets by converting them to shares * @param _asset Address of asset to deposit diff --git a/contracts/contracts/strategies/MorphoAaveStrategy.sol b/contracts/contracts/strategies/MorphoAaveStrategy.sol index 8961a2ea62..5ec02e2776 100644 --- a/contracts/contracts/strategies/MorphoAaveStrategy.sol +++ b/contracts/contracts/strategies/MorphoAaveStrategy.sol @@ -19,26 +19,22 @@ contract MorphoAaveStrategy is InitializableAbstractStrategy { using SafeERC20 for IERC20; using StableMath for uint256; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * @dev Initialize function, to set up initial internal state - * @param _vaultAddress Address of the Vault * @param _rewardTokenAddresses Address of reward token for platform * @param _assets Addresses of initial supported assets * @param _pTokens Platform Token corresponding addresses */ function initialize( - address _vaultAddress, address[] calldata _rewardTokenAddresses, address[] calldata _assets, address[] calldata _pTokens - ) external onlyGovernor initializer { - super._initialize( - MORPHO, - _vaultAddress, - _rewardTokenAddresses, - _assets, - _pTokens - ); + ) external override onlyGovernor initializer { + super._initialize(_rewardTokenAddresses, _assets, _pTokens); } /** diff --git a/contracts/contracts/strategies/MorphoCompoundStrategy.sol b/contracts/contracts/strategies/MorphoCompoundStrategy.sol index b3ead788e0..46a87ed906 100644 --- a/contracts/contracts/strategies/MorphoCompoundStrategy.sol +++ b/contracts/contracts/strategies/MorphoCompoundStrategy.sol @@ -7,8 +7,7 @@ pragma solidity ^0.8.0; * @author Origin Protocol Inc */ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { BaseCompoundStrategy } from "./BaseCompoundStrategy.sol"; -import { IERC20 } from "../utils/InitializableAbstractStrategy.sol"; +import { IERC20, BaseCompoundStrategy, InitializableAbstractStrategy } from "./BaseCompoundStrategy.sol"; import { IMorpho } from "../interfaces/morpho/IMorpho.sol"; import { ILens } from "../interfaces/morpho/ILens.sol"; import { StableMath } from "../utils/StableMath.sol"; @@ -20,26 +19,22 @@ contract MorphoCompoundStrategy is BaseCompoundStrategy { using SafeERC20 for IERC20; using StableMath for uint256; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * @dev Initialize function, to set up initial internal state - * @param _vaultAddress Address of the Vault * @param _rewardTokenAddresses Address of reward token for platform * @param _assets Addresses of initial supported assets * @param _pTokens Platform Token corresponding addresses */ function initialize( - address _vaultAddress, address[] calldata _rewardTokenAddresses, address[] calldata _assets, address[] calldata _pTokens - ) external onlyGovernor initializer { - super._initialize( - MORPHO, - _vaultAddress, - _rewardTokenAddresses, - _assets, - _pTokens - ); + ) external override onlyGovernor initializer { + super._initialize(_rewardTokenAddresses, _assets, _pTokens); } /** diff --git a/contracts/contracts/strategies/ThreePoolStrategy.sol b/contracts/contracts/strategies/ThreePoolStrategy.sol index fa00b5a4eb..39e36d19ac 100644 --- a/contracts/contracts/strategies/ThreePoolStrategy.sol +++ b/contracts/contracts/strategies/ThreePoolStrategy.sol @@ -11,7 +11,7 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s import { ICurveGauge } from "./ICurveGauge.sol"; import { ICurvePool } from "./ICurvePool.sol"; import { ICRVMinter } from "./ICRVMinter.sol"; -import { IERC20, BaseCurveStrategy } from "./BaseCurveStrategy.sol"; +import { IERC20, BaseCurveStrategy, InitializableAbstractStrategy } from "./BaseCurveStrategy.sol"; import { StableMath } from "../utils/StableMath.sol"; import { Helpers } from "../utils/Helpers.sol"; @@ -29,12 +29,14 @@ contract ThreePoolStrategy is BaseCurveStrategy { address internal crvGaugeAddress; address internal crvMinterAddress; + constructor(BaseStrategyConfig memory _stratConfig) + InitializableAbstractStrategy(_stratConfig) + {} + /** * Initializer for setting up strategy internal state. This overrides the * InitializableAbstractStrategy initializer as Curve strategies don't fit * well within that abstraction. - * @param _platformAddress Address of the Curve 3pool - * @param _vaultAddress Address of the vault * @param _rewardTokenAddress Address of CRV * @param _assets Addresses of supported assets. MUST be passed in the same * order as returned by coins on the pool contract, i.e. @@ -44,8 +46,6 @@ contract ThreePoolStrategy is BaseCurveStrategy { * @param _crvMinterAddress Address of the CRV minter for rewards */ function initialize( - address _platformAddress, // 3Pool address - address _vaultAddress, address[] calldata _rewardTokenAddress, // CRV address[] calldata _assets, address[] calldata _pTokens, @@ -58,13 +58,7 @@ contract ThreePoolStrategy is BaseCurveStrategy { crvGaugeAddress = _crvGaugeAddress; crvMinterAddress = _crvMinterAddress; pTokenAddress = _pTokens[0]; - super._initialize( - _platformAddress, - _vaultAddress, - _rewardTokenAddress, - _assets, - _pTokens - ); + super._initialize(_rewardTokenAddress, _assets, _pTokens); _approveBase(); } diff --git a/contracts/contracts/utils/InitializableAbstractStrategy.sol b/contracts/contracts/utils/InitializableAbstractStrategy.sol index 9606d2ded7..b6ba9d6839 100644 --- a/contracts/contracts/utils/InitializableAbstractStrategy.sol +++ b/contracts/contracts/utils/InitializableAbstractStrategy.sol @@ -29,10 +29,18 @@ abstract contract InitializableAbstractStrategy is Initializable, Governable { address _newHarvesterAddress ); - // Core address for the given platform - address public platformAddress; + /// @notice Address of the underlying platform + address public immutable platformAddress; + /// @notice Address of the OToken vault + address public immutable vaultAddress; - address public vaultAddress; + /// @dev Replaced with an immutable variable + // slither-disable-next-line constable-states + address private _deprecated_platformAddress; + + /// @dev Replaced with an immutable + // slither-disable-next-line constable-states + address private _deprecated_vaultAddress; // asset => pToken (Platform Specific Token Address) mapping(address => address) public assetToPToken; @@ -60,24 +68,31 @@ abstract contract InitializableAbstractStrategy is Initializable, Governable { */ int256[98] private _reserved; + struct BaseStrategyConfig { + address platformAddress; // Address of the underlying platform + address vaultAddress; // Address of the OToken's Vault + } + + /** + * @param _config The platform and OToken vault addresses + */ + constructor(BaseStrategyConfig memory _config) { + platformAddress = _config.platformAddress; + vaultAddress = _config.vaultAddress; + } + /** - * @dev Internal initialize function, to set up initial internal state - * @param _platformAddress Generic platform address - * @param _vaultAddress Address of the Vault + * @notice Internal initialize function, to set up initial internal state * @param _rewardTokenAddresses Address of reward token for platform * @param _assets Addresses of initial supported assets * @param _pTokens Platform Token corresponding addresses */ function initialize( - address _platformAddress, - address _vaultAddress, address[] calldata _rewardTokenAddresses, address[] calldata _assets, address[] calldata _pTokens - ) external onlyGovernor initializer { + ) external virtual onlyGovernor initializer { InitializableAbstractStrategy._initialize( - _platformAddress, - _vaultAddress, _rewardTokenAddresses, _assets, _pTokens @@ -85,14 +100,10 @@ abstract contract InitializableAbstractStrategy is Initializable, Governable { } function _initialize( - address _platformAddress, - address _vaultAddress, address[] calldata _rewardTokenAddresses, address[] memory _assets, address[] memory _pTokens ) internal { - platformAddress = _platformAddress; - vaultAddress = _vaultAddress; rewardTokenAddresses = _rewardTokenAddresses; uint256 assetCount = _assets.length; diff --git a/contracts/deploy/001_core.js b/contracts/deploy/001_core.js index 0afec2904e..1abd822345 100644 --- a/contracts/deploy/001_core.js +++ b/contracts/deploy/001_core.js @@ -37,7 +37,9 @@ const deployAaveStrategy = async () => { "InitializeGovernedUpgradeabilityProxy" ); const cAaveStrategyProxy = await ethers.getContract("AaveStrategyProxy"); - const dAaveStrategy = await deployWithConfirmation("AaveStrategy"); + const dAaveStrategy = await deployWithConfirmation("AaveStrategy", [ + [assetAddresses.AAVE_ADDRESS_PROVIDER, cVaultProxy.address], + ]); const cAaveStrategy = await ethers.getContractAt( "AaveStrategy", dAaveStrategyProxy.address @@ -56,14 +58,12 @@ const deployAaveStrategy = async () => { log("Initialized AaveStrategyProxy"); const initFunctionName = - "initialize(address,address,address[],address[],address[],address,address)"; + "initialize(address[],address[],address[],address,address)"; await withConfirmation( cAaveStrategy .connect(sDeployer) // eslint-disable-next-line no-unexpected-multiline [initFunctionName]( - assetAddresses.AAVE_ADDRESS_PROVIDER, - cVaultProxy.address, [assetAddresses.AAVE_TOKEN], [assetAddresses.DAI], [assetAddresses.aDAI], @@ -112,7 +112,9 @@ const deployCompoundStrategy = async () => { const cCompoundStrategyProxy = await ethers.getContract( "CompoundStrategyProxy" ); - const dCompoundStrategy = await deployWithConfirmation("CompoundStrategy"); + const dCompoundStrategy = await deployWithConfirmation("CompoundStrategy", [ + [addresses.dead, cVaultProxy.address], + ]); const cCompoundStrategy = await ethers.getContractAt( "CompoundStrategy", dCompoundStrategyProxy.address @@ -129,8 +131,6 @@ const deployCompoundStrategy = async () => { cCompoundStrategy .connect(sDeployer) .initialize( - addresses.dead, - cVaultProxy.address, [assetAddresses.COMP], [assetAddresses.DAI], [assetAddresses.cDAI] @@ -167,12 +167,17 @@ const deployThreePoolStrategy = async () => { const sDeployer = await ethers.provider.getSigner(deployerAddr); const sGovernor = await ethers.provider.getSigner(governorAddr); + // Initialize Strategies + const cVaultProxy = await ethers.getContract("VaultProxy"); + await deployWithConfirmation("ThreePoolStrategyProxy"); const cThreePoolStrategyProxy = await ethers.getContract( "ThreePoolStrategyProxy" ); - const dThreePoolStrategy = await deployWithConfirmation("ThreePoolStrategy"); + const dThreePoolStrategy = await deployWithConfirmation("ThreePoolStrategy", [ + [assetAddresses.ThreePool, cVaultProxy.address], + ]); const cThreePoolStrategy = await ethers.getContractAt( "ThreePoolStrategy", cThreePoolStrategyProxy.address @@ -187,13 +192,20 @@ const deployThreePoolStrategy = async () => { ); log("Initialized ThreePoolStrategyProxy"); - // Initialize Strategies - const cVaultProxy = await ethers.getContract("VaultProxy"); await withConfirmation( - cThreePoolStrategy.connect(sDeployer)[ - // eslint-disable-next-line no-unexpected-multiline - "initialize(address,address,address[],address[],address[],address,address)" - ](assetAddresses.ThreePool, cVaultProxy.address, [assetAddresses.CRV], [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], [assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken], assetAddresses.ThreePoolGauge, assetAddresses.CRVMinter) + cThreePoolStrategy + .connect(sDeployer) + ["initialize(address[],address[],address[],address,address)"]( + [assetAddresses.CRV], + [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], + [ + assetAddresses.ThreePoolToken, + assetAddresses.ThreePoolToken, + assetAddresses.ThreePoolToken, + ], + assetAddresses.ThreePoolGauge, + assetAddresses.CRVMinter + ) ); log("Initialized ThreePoolStrategy"); @@ -226,10 +238,14 @@ const deployConvexStrategy = async () => { const sDeployer = await ethers.provider.getSigner(deployerAddr); const sGovernor = await ethers.provider.getSigner(governorAddr); + const cVaultProxy = await ethers.getContract("VaultProxy"); + await deployWithConfirmation("ConvexStrategyProxy"); const cConvexStrategyProxy = await ethers.getContract("ConvexStrategyProxy"); - const dConvexStrategy = await deployWithConfirmation("ConvexStrategy"); + const dConvexStrategy = await deployWithConfirmation("ConvexStrategy", [ + [assetAddresses.ThreePool, cVaultProxy.address], + ]); const cConvexStrategy = await ethers.getContractAt( "ConvexStrategy", cConvexStrategyProxy.address @@ -245,27 +261,23 @@ const deployConvexStrategy = async () => { log("Initialized ConvexStrategyProxy"); // Initialize Strategies - const cVaultProxy = await ethers.getContract("VaultProxy"); const mockBooster = await ethers.getContract("MockBooster"); const mockRewardPool = await ethers.getContract("MockRewardPool"); await withConfirmation( - cConvexStrategy.connect(sDeployer)[ - // eslint-disable-next-line no-unexpected-multiline - "initialize(address,address,address[],address[],address[],address,address,uint256)" - ]( - assetAddresses.ThreePool, - cVaultProxy.address, - [assetAddresses.CRV, assetAddresses.CVX], - [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], - [ - assetAddresses.ThreePoolToken, - assetAddresses.ThreePoolToken, - assetAddresses.ThreePoolToken, - ], - mockBooster.address, // _cvxDepositorAddress, - mockRewardPool.address, // _cvxRewardStakerAddress, - 9 // _cvxDepositorPTokenId - ) + cConvexStrategy + .connect(sDeployer) + ["initialize(address[],address[],address[],address,address,uint256)"]( + [assetAddresses.CRV, assetAddresses.CVX], + [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], + [ + assetAddresses.ThreePoolToken, + assetAddresses.ThreePoolToken, + assetAddresses.ThreePoolToken, + ], + mockBooster.address, // _cvxDepositorAddress, + mockRewardPool.address, // _cvxRewardStakerAddress, + 9 // _cvxDepositorPTokenId + ) ); log("Initialized ConvexStrategy"); @@ -297,13 +309,16 @@ const deployConvexLUSDMetaStrategy = async () => { const sDeployer = await ethers.provider.getSigner(deployerAddr); const sGovernor = await ethers.provider.getSigner(governorAddr); + const cVaultProxy = await ethers.getContract("VaultProxy"); + await deployWithConfirmation("ConvexLUSDMetaStrategyProxy"); const cConvexLUSDMetaStrategyProxy = await ethers.getContract( "ConvexLUSDMetaStrategyProxy" ); const dConvexLUSDMetaStrategy = await deployWithConfirmation( - "ConvexGeneralizedMetaStrategy" + "ConvexGeneralizedMetaStrategy", + [[assetAddresses.ThreePool, cVaultProxy.address]] ); const cConvexLUSDMetaStrategy = await ethers.getContractAt( "ConvexGeneralizedMetaStrategy", @@ -320,7 +335,6 @@ const deployConvexLUSDMetaStrategy = async () => { log("Initialized ConvexLUSDMetaStrategyProxy"); // Initialize Strategies - const cVaultProxy = await ethers.getContract("VaultProxy"); const mockBooster = await ethers.getContract("MockBooster"); const mockRewardPool = await ethers.getContract("MockRewardPool"); @@ -328,7 +342,7 @@ const deployConvexLUSDMetaStrategy = async () => { await withConfirmation( cConvexLUSDMetaStrategy.connect(sDeployer)[ // eslint-disable-next-line no-unexpected-multiline - "initialize(address[],address[],address[],(address,address,address,address,address,address,address,uint256))" + "initialize(address[],address[],address[],(address,address,address,address,address,uint256))" ]( [assetAddresses.CVX, assetAddresses.CRV], [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], @@ -338,8 +352,6 @@ const deployConvexLUSDMetaStrategy = async () => { assetAddresses.ThreePoolToken, ], [ - assetAddresses.ThreePool, - cVaultProxy.address, mockBooster.address, // _cvxDepositorAddress, assetAddresses.ThreePoolLUSDMetapool, // metapool address, LUSD.address, // LUSD @@ -379,13 +391,16 @@ const deployConvexOUSDMetaStrategy = async () => { const sDeployer = await ethers.provider.getSigner(deployerAddr); const sGovernor = await ethers.provider.getSigner(governorAddr); + const cVaultProxy = await ethers.getContract("VaultProxy"); + await deployWithConfirmation("ConvexOUSDMetaStrategyProxy"); const cConvexOUSDMetaStrategyProxy = await ethers.getContract( "ConvexOUSDMetaStrategyProxy" ); const dConvexOUSDMetaStrategy = await deployWithConfirmation( - "ConvexOUSDMetaStrategy" + "ConvexOUSDMetaStrategy", + [[assetAddresses.ThreePool, cVaultProxy.address]] ); const cConvexOUSDMetaStrategy = await ethers.getContractAt( "ConvexOUSDMetaStrategy", @@ -402,7 +417,6 @@ const deployConvexOUSDMetaStrategy = async () => { log("Initialized ConvexOUSDMetaStrategyProxy"); // Initialize Strategies - const cVaultProxy = await ethers.getContract("VaultProxy"); const mockBooster = await ethers.getContract("MockBooster"); const mockRewardPool = await ethers.getContract("MockRewardPool"); const ousd = await ethers.getContract("OUSDProxy"); @@ -410,7 +424,7 @@ const deployConvexOUSDMetaStrategy = async () => { await withConfirmation( cConvexOUSDMetaStrategy.connect(sDeployer)[ // eslint-disable-next-line no-unexpected-multiline - "initialize(address[],address[],address[],(address,address,address,address,address,address,address,uint256))" + "initialize(address[],address[],address[],(address,address,address,address,address,uint256))" ]( [assetAddresses.CVX, assetAddresses.CRV], [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], @@ -420,8 +434,6 @@ const deployConvexOUSDMetaStrategy = async () => { assetAddresses.ThreePoolToken, ], [ - assetAddresses.ThreePool, - cVaultProxy.address, mockBooster.address, // _cvxDepositorAddress, assetAddresses.ThreePoolOUSDMetapool, // metapool address, ousd.address, // _ousdAddress, @@ -751,7 +763,9 @@ const deployFraxEthStrategy = async () => { const cFraxETHStrategyProxy = await ethers.getContract( "FraxETHStrategyProxy" ); - const dFraxETHStrategy = await deployWithConfirmation("FraxETHStrategy"); + const dFraxETHStrategy = await deployWithConfirmation("FraxETHStrategy", [ + [assetAddresses.sfrxETH, cOETHVaultProxy.address], + ]); const cFraxETHStrategy = await ethers.getContractAt( "FraxETHStrategy", dFraxETHStrategyProxy.address @@ -767,13 +781,7 @@ const deployFraxEthStrategy = async () => { await withConfirmation( cFraxETHStrategy .connect(sDeployer) - .initialize( - assetAddresses.sfrxETH, - cOETHVaultProxy.address, - [], - [assetAddresses.frxETH], - [assetAddresses.sfrxETH] - ) + .initialize([], [assetAddresses.frxETH], [assetAddresses.sfrxETH]) ); log("Initialized FraxETHStrategy"); await withConfirmation( diff --git a/contracts/docs/AaveStrategyHierarchy.svg b/contracts/docs/AaveStrategyHierarchy.svg index f075e23abe..ab28c359ed 100644 --- a/contracts/docs/AaveStrategyHierarchy.svg +++ b/contracts/docs/AaveStrategyHierarchy.svg @@ -4,148 +4,218 @@ - - + + UmlClassDiagram - + 7 - -Governable -../contracts/governance/Governable.sol + +Governable +../contracts/governance/Governable.sol - + -35 +40 <<Interface>> IVault ../contracts/interfaces/IVault.sol - + + +180 + +VaultStorage +../contracts/vault/VaultStorage.sol + + + +40->180 + + + + -109 +124 AaveStrategy ../contracts/strategies/AaveStrategy.sol - + -121 +137 <<Interface>> IAaveLendingPool ../contracts/strategies/IAave.sol - - -109->121 + + +124->137 - + -122 +138 <<Interface>> ILendingPoolAddressesProvider ../contracts/strategies/IAave.sol - - -109->122 + + +124->138 - + -123 +139 <<Interface>> IAaveIncentivesController ../contracts/strategies/IAaveIncentivesController.sol - - -109->123 + + +124->139 - + -124 +140 <<Interface>> IAaveStakedToken ../contracts/strategies/IAaveStakeToken.sol - - -109->124 + + +124->140 - - -150 + + +168 <<Abstract>> InitializableAbstractStrategy ../contracts/utils/InitializableAbstractStrategy.sol - - -109->150 + + +124->168 - + -149 - -<<Abstract>> -Initializable -../contracts/utils/Initializable.sol +159 + +OUSD +../contracts/token/OUSD.sol - - -150->7 - - + + +159->7 + + - - -150->35 + + +167 + +<<Abstract>> +Initializable +../contracts/utils/Initializable.sol + + + +159->167 + + + + + +170 + +<<Abstract>> +InitializableERC20Detailed +../contracts/utils/InitializableERC20Detailed.sol + + + +159->170 + + + + + +168->7 + + + + + +168->40 - - -150->149 - - - - - -150->150 - + + +168->167 + + + + + +168->168 + - - -436 - -<<Interface>> -IERC20 -../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol - - - -150->436 - - + + +357 + +<<Interface>> +IERC20 +../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol + + + +168->357 + + + + + +170->357 + + + + + +180->7 + + + + + +180->159 + + + + + +180->167 + + diff --git a/contracts/docs/AaveStrategySquashed.svg b/contracts/docs/AaveStrategySquashed.svg index 36a2873ca9..e7e064544d 100644 --- a/contracts/docs/AaveStrategySquashed.svg +++ b/contracts/docs/AaveStrategySquashed.svg @@ -4,93 +4,96 @@ - - + + UmlClassDiagram - - + + -109 - -AaveStrategy -../contracts/strategies/AaveStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> -   harvesterAddress: address <<InitializableAbstractStrategy>> -   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> -   referralCode: uint16 <<AaveStrategy>> -   incentivesController: IAaveIncentivesController <<AaveStrategy>> -   stkAave: IAaveStakedToken <<AaveStrategy>> - -Internal: -    _governor(): (governorOut: address) <<Governable>> -    _pendingGovernor(): (pendingGovernor: address) <<Governable>> -    _setGovernor(newGovernor: address) <<Governable>> -    _setPendingGovernor(newGovernor: address) <<Governable>> -    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> -    _collectRewardTokens() <<InitializableAbstractStrategy>> -    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    _abstractSetPToken(_asset: address, _aToken: address) <<AaveStrategy>> -    _deposit(_asset: address, _amount: uint256) <<AaveStrategy>> -    _getATokenFor(_asset: address): address <<AaveStrategy>> -    _getLendingPool(): IAaveLendingPool <<AaveStrategy>> -External: -    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> -    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> -    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<AaveStrategy>> -    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> -    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    safeApproveAllTokens() <<onlyGovernor, nonReentrant>> <<AaveStrategy>> -    deposit(_asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<AaveStrategy>> -    depositAll() <<onlyVault, nonReentrant>> <<AaveStrategy>> -    withdraw(_recipient: address, _asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<AaveStrategy>> -    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<AaveStrategy>> -    checkBalance(_asset: address): (balance: uint256) <<AaveStrategy>> -    supportsAsset(_asset: address): bool <<AaveStrategy>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[], _incentivesAddress: address, _stkAaveAddress: address) <<onlyGovernor, initializer>> <<AaveStrategy>> -Public: -    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> -    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> -    <<modifier>> initializer() <<Initializable>> -    <<modifier>> onlyGovernor() <<Governable>> -    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +124 + +AaveStrategy +../contracts/strategies/AaveStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> +   harvesterAddress: address <<InitializableAbstractStrategy>> +   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> +   referralCode: uint16 <<AaveStrategy>> +   incentivesController: IAaveIncentivesController <<AaveStrategy>> +   stkAave: IAaveStakedToken <<AaveStrategy>> + +Internal: +    _governor(): (governorOut: address) <<Governable>> +    _pendingGovernor(): (pendingGovernor: address) <<Governable>> +    _setGovernor(newGovernor: address) <<Governable>> +    _setPendingGovernor(newGovernor: address) <<Governable>> +    _changeGovernor(_newGovernor: address) <<Governable>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _collectRewardTokens() <<InitializableAbstractStrategy>> +    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    _abstractSetPToken(_asset: address, _aToken: address) <<AaveStrategy>> +    _deposit(_asset: address, _amount: uint256) <<AaveStrategy>> +    _getATokenFor(_asset: address): address <<AaveStrategy>> +    _getLendingPool(): IAaveLendingPool <<AaveStrategy>> +External: +    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> +    claimGovernance() <<Governable>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<AaveStrategy>> +    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> +    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    safeApproveAllTokens() <<onlyGovernor, nonReentrant>> <<AaveStrategy>> +    deposit(_asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<AaveStrategy>> +    depositAll() <<onlyVault, nonReentrant>> <<AaveStrategy>> +    withdraw(_recipient: address, _asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<AaveStrategy>> +    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<AaveStrategy>> +    checkBalance(_asset: address): (balance: uint256) <<AaveStrategy>> +    supportsAsset(_asset: address): bool <<AaveStrategy>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[], _incentivesAddress: address, _stkAaveAddress: address) <<onlyGovernor, initializer>> <<AaveStrategy>> +Public: +    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> +    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> +    <<modifier>> initializer() <<Initializable>> +    <<modifier>> onlyGovernor() <<Governable>> +    <<modifier>> nonReentrant() <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<AaveStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> diff --git a/contracts/docs/AaveStrategyStorage.svg b/contracts/docs/AaveStrategyStorage.svg index e9c22bc78b..699aec2198 100644 --- a/contracts/docs/AaveStrategyStorage.svg +++ b/contracts/docs/AaveStrategyStorage.svg @@ -53,13 +53,13 @@ uint256[50]: Initializable.______gap (1600) -unallocated (12) - -address: InitializableAbstractStrategy.platformAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_platformAddress (20) -unallocated (12) - -address: InitializableAbstractStrategy.vaultAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_vaultAddress (20) mapping(address=>address): InitializableAbstractStrategy.assetToPToken (32) diff --git a/contracts/docs/CompStrategyHierarchy.svg b/contracts/docs/CompStrategyHierarchy.svg index b5fb24d399..ca83249a08 100644 --- a/contracts/docs/CompStrategyHierarchy.svg +++ b/contracts/docs/CompStrategyHierarchy.svg @@ -4,17 +4,17 @@ - - + + UmlClassDiagram - + 7 - -Governable -../contracts/governance/Governable.sol + +Governable +../contracts/governance/Governable.sol @@ -24,120 +24,190 @@ IComptroller ../contracts/interfaces/IComptroller.sol - + -35 +40 <<Interface>> IVault ../contracts/interfaces/IVault.sol - + + +180 + +VaultStorage +../contracts/vault/VaultStorage.sol + + + +40->180 + + + + -110 +125 <<Abstract>> BaseCompoundStrategy ../contracts/strategies/BaseCompoundStrategy.sol - + -126 +142 <<Interface>> ICERC20 ../contracts/strategies/ICompound.sol - - -110->126 + + +125->142 - - -150 + + +168 <<Abstract>> InitializableAbstractStrategy ../contracts/utils/InitializableAbstractStrategy.sol - - -110->150 + + +125->168 - + -114 +129 CompoundStrategy ../contracts/strategies/CompoundStrategy.sol - - -114->22 + + +129->22 - - -114->110 + + +129->125 - - -114->126 + + +129->142 - + -149 - -<<Abstract>> -Initializable -../contracts/utils/Initializable.sol +159 + +OUSD +../contracts/token/OUSD.sol - - -150->7 - - + + +159->7 + + - - -150->35 + + +167 + +<<Abstract>> +Initializable +../contracts/utils/Initializable.sol + + + +159->167 + + + + + +170 + +<<Abstract>> +InitializableERC20Detailed +../contracts/utils/InitializableERC20Detailed.sol + + + +159->170 + + + + + +168->7 + + + + + +168->40 - - -150->149 - - + + +168->167 + + - - -150->150 + + +168->168 - - -436 - -<<Interface>> -IERC20 -../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol - - - -150->436 - - + + +357 + +<<Interface>> +IERC20 +../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol + + + +168->357 + + + + + +170->357 + + + + + +180->7 + + + + + +180->159 + + + + + +180->167 + + diff --git a/contracts/docs/CompStrategySquashed.svg b/contracts/docs/CompStrategySquashed.svg index 2a30c81e05..83a54ad35d 100644 --- a/contracts/docs/CompStrategySquashed.svg +++ b/contracts/docs/CompStrategySquashed.svg @@ -4,92 +4,95 @@ - - + + UmlClassDiagram - - + + -114 - -CompoundStrategy -../contracts/strategies/CompoundStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -   __reserved: int256[50] <<BaseCompoundStrategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> -   harvesterAddress: address <<InitializableAbstractStrategy>> -   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> - -Internal: -    _governor(): (governorOut: address) <<Governable>> -    _pendingGovernor(): (pendingGovernor: address) <<Governable>> -    _setGovernor(newGovernor: address) <<Governable>> -    _setPendingGovernor(newGovernor: address) <<Governable>> -    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> -    _collectRewardTokens() <<InitializableAbstractStrategy>> -    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    _abstractSetPToken(_asset: address, _pToken: address) <<CompoundStrategy>> -    _getCTokenFor(_asset: address): ICERC20 <<BaseCompoundStrategy>> -    _convertUnderlyingToCToken(_cToken: ICERC20, _underlying: uint256): (amount: uint256) <<BaseCompoundStrategy>> -    _deposit(_asset: address, _amount: uint256) <<CompoundStrategy>> -    _checkBalance(_cToken: ICERC20): (balance: uint256) <<CompoundStrategy>> -External: -    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> -    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> -    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<CompoundStrategy>> -    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> -    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    safeApproveAllTokens() <<CompoundStrategy>> -    deposit(_asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<CompoundStrategy>> -    depositAll() <<onlyVault, nonReentrant>> <<CompoundStrategy>> -    withdraw(_recipient: address, _asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<CompoundStrategy>> -    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<CompoundStrategy>> -    checkBalance(_asset: address): (balance: uint256) <<CompoundStrategy>> -    supportsAsset(_asset: address): bool <<BaseCompoundStrategy>> -Public: -    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> -    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> -    <<event>> SkippedWithdrawal(asset: address, amount: uint256) <<CompoundStrategy>> -    <<modifier>> initializer() <<Initializable>> -    <<modifier>> onlyGovernor() <<Governable>> -    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +129 + +CompoundStrategy +../contracts/strategies/CompoundStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +   __reserved: int256[50] <<BaseCompoundStrategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> +   harvesterAddress: address <<InitializableAbstractStrategy>> +   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> + +Internal: +    _governor(): (governorOut: address) <<Governable>> +    _pendingGovernor(): (pendingGovernor: address) <<Governable>> +    _setGovernor(newGovernor: address) <<Governable>> +    _setPendingGovernor(newGovernor: address) <<Governable>> +    _changeGovernor(_newGovernor: address) <<Governable>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _collectRewardTokens() <<InitializableAbstractStrategy>> +    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    _abstractSetPToken(_asset: address, _pToken: address) <<CompoundStrategy>> +    _getCTokenFor(_asset: address): ICERC20 <<BaseCompoundStrategy>> +    _convertUnderlyingToCToken(_cToken: ICERC20, _underlying: uint256): (amount: uint256) <<BaseCompoundStrategy>> +    _deposit(_asset: address, _amount: uint256) <<CompoundStrategy>> +    _checkBalance(_cToken: ICERC20): (balance: uint256) <<CompoundStrategy>> +External: +    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> +    claimGovernance() <<Governable>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<CompoundStrategy>> +    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> +    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    safeApproveAllTokens() <<CompoundStrategy>> +    deposit(_asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<CompoundStrategy>> +    depositAll() <<onlyVault, nonReentrant>> <<CompoundStrategy>> +    withdraw(_recipient: address, _asset: address, _amount: uint256) <<onlyVault, nonReentrant>> <<CompoundStrategy>> +    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<CompoundStrategy>> +    checkBalance(_asset: address): (balance: uint256) <<CompoundStrategy>> +    supportsAsset(_asset: address): bool <<BaseCompoundStrategy>> +Public: +    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> +    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> +    <<event>> SkippedWithdrawal(asset: address, amount: uint256) <<CompoundStrategy>> +    <<modifier>> initializer() <<Initializable>> +    <<modifier>> onlyGovernor() <<Governable>> +    <<modifier>> nonReentrant() <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<CompoundStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> diff --git a/contracts/docs/CompStrategyStorage.svg b/contracts/docs/CompStrategyStorage.svg index 9c80d88fb4..c8cfbe3378 100644 --- a/contracts/docs/CompStrategyStorage.svg +++ b/contracts/docs/CompStrategyStorage.svg @@ -51,13 +51,13 @@ uint256[50]: Initializable.______gap (1600) -unallocated (12) - -address: InitializableAbstractStrategy.platformAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_platformAddress (20) -unallocated (12) - -address: InitializableAbstractStrategy.vaultAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_vaultAddress (20) mapping(address=>address): InitializableAbstractStrategy.assetToPToken (32) diff --git a/contracts/docs/ConvexEthMetaStrategyHierarchy.svg b/contracts/docs/ConvexEthMetaStrategyHierarchy.svg index 61eda47fd4..0a74529fe9 100644 --- a/contracts/docs/ConvexEthMetaStrategyHierarchy.svg +++ b/contracts/docs/ConvexEthMetaStrategyHierarchy.svg @@ -4,154 +4,224 @@ - - + + UmlClassDiagram - + 7 - -Governable -../contracts/governance/Governable.sol + +Governable +../contracts/governance/Governable.sol - + -35 - -<<Interface>> -IVault -../contracts/interfaces/IVault.sol +40 + +<<Interface>> +IVault +../contracts/interfaces/IVault.sol + + + +180 + +VaultStorage +../contracts/vault/VaultStorage.sol + + + +40->180 + + - + -36 - -<<Interface>> -IWETH9 -../contracts/interfaces/IWETH9.sol +41 + +<<Interface>> +IWETH9 +../contracts/interfaces/IWETH9.sol - + -115 - -ConvexEthMetaStrategy -../contracts/strategies/ConvexEthMetaStrategy.sol +130 + +ConvexEthMetaStrategy +../contracts/strategies/ConvexEthMetaStrategy.sol - - -115->35 - - + + +130->40 + + - - -115->36 - - + + +130->41 + + - + -127 - -<<Interface>> -IConvexDeposits -../contracts/strategies/IConvexDeposits.sol +143 + +<<Interface>> +IConvexDeposits +../contracts/strategies/IConvexDeposits.sol - - -115->127 - - + + +130->143 + + - + -129 - -<<Interface>> -ICurveETHPoolV1 -../contracts/strategies/ICurveETHPoolV1.sol +144 + +<<Interface>> +ICurveETHPoolV1 +../contracts/strategies/ICurveETHPoolV1.sol - - -115->129 - - + + +130->144 + + - + -133 - -<<Interface>> -IRewardStaking -../contracts/strategies/IRewardStaking.sol +148 + +<<Interface>> +IRewardStaking +../contracts/strategies/IRewardStaking.sol - - -115->133 - - + + +130->148 + + - - -150 - -<<Abstract>> -InitializableAbstractStrategy -../contracts/utils/InitializableAbstractStrategy.sol + + +168 + +<<Abstract>> +InitializableAbstractStrategy +../contracts/utils/InitializableAbstractStrategy.sol - - -115->150 - - + + +130->168 + + - + -149 - -<<Abstract>> -Initializable -../contracts/utils/Initializable.sol - - - -150->7 - - +159 + +OUSD +../contracts/token/OUSD.sol - - -150->35 - - + + +159->7 + + - - -150->149 - - + + +167 + +<<Abstract>> +Initializable +../contracts/utils/Initializable.sol - + + +159->167 + + + + + +170 + +<<Abstract>> +InitializableERC20Detailed +../contracts/utils/InitializableERC20Detailed.sol + + -150->150 - - - - - -436 - -<<Interface>> -IERC20 -../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol - - - -150->436 - - +159->170 + + + + + +168->7 + + + + + +168->40 + + + + + +168->167 + + + + + +168->168 + + + + + +357 + +<<Interface>> +IERC20 +../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol + + + +168->357 + + + + + +170->357 + + + + + +180->7 + + + + + +180->159 + + + + + +180->167 + + diff --git a/contracts/docs/ConvexEthMetaStrategySquashed.svg b/contracts/docs/ConvexEthMetaStrategySquashed.svg index 379ac1ac15..3a964662b3 100644 --- a/contracts/docs/ConvexEthMetaStrategySquashed.svg +++ b/contracts/docs/ConvexEthMetaStrategySquashed.svg @@ -4,105 +4,108 @@ - - + + UmlClassDiagram - - + + -115 - -ConvexEthMetaStrategy -../contracts/strategies/ConvexEthMetaStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -   MAX_SLIPPAGE: uint256 <<ConvexEthMetaStrategy>> -   ETH_ADDRESS: address <<ConvexEthMetaStrategy>> -   cvxDepositorAddress: address <<ConvexEthMetaStrategy>> -   cvxDepositorPTokenId: uint256 <<ConvexEthMetaStrategy>> -   curvePool: ICurveETHPoolV1 <<ConvexEthMetaStrategy>> -   lpToken: IERC20 <<ConvexEthMetaStrategy>> -   oeth: IERC20 <<ConvexEthMetaStrategy>> -   weth: IWETH9 <<ConvexEthMetaStrategy>> -   oethCoinIndex: uint128 <<ConvexEthMetaStrategy>> -   ethCoinIndex: uint128 <<ConvexEthMetaStrategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> -   harvesterAddress: address <<InitializableAbstractStrategy>> -   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> -   cvxRewardStaker: IRewardStaking <<ConvexEthMetaStrategy>> - -Internal: -    _governor(): (governorOut: address) <<Governable>> -    _pendingGovernor(): (pendingGovernor: address) <<Governable>> -    _setGovernor(newGovernor: address) <<Governable>> -    _setPendingGovernor(newGovernor: address) <<Governable>> -    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> -    _collectRewardTokens() <<InitializableAbstractStrategy>> -    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    _abstractSetPToken(_asset: address, _pToken: address) <<ConvexEthMetaStrategy>> -    _deposit(_weth: address, _wethAmount: uint256) <<ConvexEthMetaStrategy>> -    calcTokenToBurn(_wethAmount: uint256): (lpToBurn: uint256) <<ConvexEthMetaStrategy>> -    _lpWithdraw(_wethAmount: uint256) <<ConvexEthMetaStrategy>> -    _approveAsset(_asset: address) <<ConvexEthMetaStrategy>> -    _approveBase() <<ConvexEthMetaStrategy>> -    _getCoinIndex(_asset: address): uint256 <<ConvexEthMetaStrategy>> -    _max(a: int256, b: int256): int256 <<ConvexEthMetaStrategy>> -External: -    <<payable>> null() <<ConvexEthMetaStrategy>> -    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> -    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> -    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<ConvexEthMetaStrategy>> -    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> -    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> -    safeApproveAllTokens() <<onlyGovernor, nonReentrant>> <<ConvexEthMetaStrategy>> -    deposit(_weth: address, _amount: uint256) <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> -    depositAll() <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> -    withdraw(_recipient: address, _weth: address, _amount: uint256) <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> -    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<ConvexEthMetaStrategy>> -    supportsAsset(_asset: address): bool <<ConvexEthMetaStrategy>> -    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[], initConfig: InitialiseConfig) <<onlyGovernor, initializer>> <<ConvexEthMetaStrategy>> -Public: -    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> -    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> -    <<modifier>> initializer() <<Initializable>> -    <<modifier>> onlyGovernor() <<Governable>> -    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +130 + +ConvexEthMetaStrategy +../contracts/strategies/ConvexEthMetaStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +   MAX_SLIPPAGE: uint256 <<ConvexEthMetaStrategy>> +   ETH_ADDRESS: address <<ConvexEthMetaStrategy>> +   cvxDepositorAddress: address <<ConvexEthMetaStrategy>> +   cvxDepositorPTokenId: uint256 <<ConvexEthMetaStrategy>> +   curvePool: ICurveETHPoolV1 <<ConvexEthMetaStrategy>> +   lpToken: IERC20 <<ConvexEthMetaStrategy>> +   oeth: IERC20 <<ConvexEthMetaStrategy>> +   weth: IWETH9 <<ConvexEthMetaStrategy>> +   oethCoinIndex: uint128 <<ConvexEthMetaStrategy>> +   ethCoinIndex: uint128 <<ConvexEthMetaStrategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> +   harvesterAddress: address <<InitializableAbstractStrategy>> +   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>> +   cvxRewardStaker: IRewardStaking <<ConvexEthMetaStrategy>> + +Internal: +    _governor(): (governorOut: address) <<Governable>> +    _pendingGovernor(): (pendingGovernor: address) <<Governable>> +    _setGovernor(newGovernor: address) <<Governable>> +    _setPendingGovernor(newGovernor: address) <<Governable>> +    _changeGovernor(_newGovernor: address) <<Governable>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _collectRewardTokens() <<InitializableAbstractStrategy>> +    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    _abstractSetPToken(_asset: address, _pToken: address) <<ConvexEthMetaStrategy>> +    _deposit(_weth: address, _wethAmount: uint256) <<ConvexEthMetaStrategy>> +    calcTokenToBurn(_wethAmount: uint256): (lpToBurn: uint256) <<ConvexEthMetaStrategy>> +    _lpWithdraw(_wethAmount: uint256) <<ConvexEthMetaStrategy>> +    _approveAsset(_asset: address) <<ConvexEthMetaStrategy>> +    _approveBase() <<ConvexEthMetaStrategy>> +    _getCoinIndex(_asset: address): uint256 <<ConvexEthMetaStrategy>> +    _max(a: int256, b: int256): int256 <<ConvexEthMetaStrategy>> +External: +    <<payable>> null() <<ConvexEthMetaStrategy>> +    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>> +    claimGovernance() <<Governable>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<ConvexEthMetaStrategy>> +    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> +    setPTokenAddress(_asset: address, _pToken: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    removePToken(_assetIndex: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    setHarvesterAddress(_harvesterAddress: address) <<onlyGovernor>> <<InitializableAbstractStrategy>> +    safeApproveAllTokens() <<onlyGovernor, nonReentrant>> <<ConvexEthMetaStrategy>> +    deposit(_weth: address, _amount: uint256) <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> +    depositAll() <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> +    withdraw(_recipient: address, _weth: address, _amount: uint256) <<onlyVault, nonReentrant>> <<ConvexEthMetaStrategy>> +    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<ConvexEthMetaStrategy>> +    supportsAsset(_asset: address): bool <<ConvexEthMetaStrategy>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[], initConfig: InitializeConfig) <<onlyGovernor, initializer>> <<ConvexEthMetaStrategy>> +Public: +    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> +    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> +    <<modifier>> initializer() <<Initializable>> +    <<modifier>> onlyGovernor() <<Governable>> +    <<modifier>> nonReentrant() <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<ConvexEthMetaStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>>    checkBalance(_asset: address): (balance: uint256) <<ConvexEthMetaStrategy>> diff --git a/contracts/docs/FraxETHStrategyHierarchy.svg b/contracts/docs/FraxETHStrategyHierarchy.svg index 096d417846..8db2a381c3 100644 --- a/contracts/docs/FraxETHStrategyHierarchy.svg +++ b/contracts/docs/FraxETHStrategyHierarchy.svg @@ -24,227 +24,227 @@ IFraxETHMinter ../contracts/interfaces/IFraxETHMinter.sol - + -36 +40 <<Interface>> IVault ../contracts/interfaces/IVault.sol - + -169 +180 VaultStorage ../contracts/vault/VaultStorage.sol - + -36->169 +40->180 - + -37 +41 <<Interface>> IWETH9 ../contracts/interfaces/IWETH9.sol - + -127 +135 FraxETHStrategy ../contracts/strategies/FraxETHStrategy.sol - + -127->25 +135->25 - + -127->37 +135->41 - + -128 +136 Generalized4626Strategy ../contracts/strategies/Generalized4626Strategy.sol - + -127->128 +135->136 - + -206 +233 <<Interface>> IERC4626 ../lib/openzeppelin/interfaces/IERC4626.sol - + -127->206 +135->233 - + -158 +168 <<Abstract>> InitializableAbstractStrategy ../contracts/utils/InitializableAbstractStrategy.sol - + -128->158 +136->168 - + -128->206 +136->233 - + -150 +159 OUSD ../contracts/token/OUSD.sol - + -150->7 +159->7 - + -157 +167 <<Abstract>> Initializable ../contracts/utils/Initializable.sol - + -150->157 +159->167 - + -159 +170 <<Abstract>> InitializableERC20Detailed ../contracts/utils/InitializableERC20Detailed.sol - + -150->159 +159->170 - + -158->7 +168->7 - + -158->36 +168->40 - + -158->157 +168->167 - + -158->158 +168->168 - + -359 +357 <<Interface>> IERC20 ../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol - + -158->359 +168->357 - + -159->359 +170->357 - + -169->7 +180->7 - + -169->150 +180->159 - + -169->157 +180->167 - + -206->359 +233->357 - + -731 +728 <<Interface>> IERC20Metadata ../node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol - + -206->731 +233->728 - + -731->359 +728->357 diff --git a/contracts/docs/FraxETHStrategySquashed.svg b/contracts/docs/FraxETHStrategySquashed.svg index 3225cf2e64..45637c3fc7 100644 --- a/contracts/docs/FraxETHStrategySquashed.svg +++ b/contracts/docs/FraxETHStrategySquashed.svg @@ -4,51 +4,53 @@ - - + + UmlClassDiagram - - + + -127 - -FraxETHStrategy -../contracts/strategies/FraxETHStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -   __gap: uint256[50] <<Generalized4626Strategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -   shareToken: IERC20 <<Generalized4626Strategy>> -   assetToken: IERC20 <<Generalized4626Strategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +135 + +FraxETHStrategy +../contracts/strategies/FraxETHStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +   __gap: uint256[50] <<Generalized4626Strategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +   shareToken: IERC20 <<Generalized4626Strategy>> +   assetToken: IERC20 <<Generalized4626Strategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>>   harvesterAddress: address <<InitializableAbstractStrategy>>   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>>   weth: address <<FraxETHStrategy>>   fraxETHMinter: IFraxETHMinter <<FraxETHStrategy>> - + Internal:    _governor(): (governorOut: address) <<Governable>>    _pendingGovernor(): (pendingGovernor: address) <<Governable>>    _setGovernor(newGovernor: address) <<Governable>>    _setPendingGovernor(newGovernor: address) <<Governable>>    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>>    _collectRewardTokens() <<InitializableAbstractStrategy>>    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>>    _abstractSetPToken(_asset: address, _pToken: address) <<Generalized4626Strategy>> @@ -57,7 +59,7 @@    <<payable>> null() <<FraxETHStrategy>>    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>>    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>>    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<InitializableAbstractStrategy>>    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>>    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> @@ -84,14 +86,14 @@    <<modifier>> initializer() <<Initializable>>    <<modifier>> onlyGovernor() <<Governable>>    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> nonReentrantView() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<FraxETHStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> diff --git a/contracts/docs/MorphoAaveStrategyHierarchy.svg b/contracts/docs/MorphoAaveStrategyHierarchy.svg index 69e3e55c41..e9cbf32eb3 100644 --- a/contracts/docs/MorphoAaveStrategyHierarchy.svg +++ b/contracts/docs/MorphoAaveStrategyHierarchy.svg @@ -4,160 +4,230 @@ - - + + UmlClassDiagram - + 7 - -Governable -../contracts/governance/Governable.sol + +Governable +../contracts/governance/Governable.sol 22 - + <<Interface>> IComptroller ../contracts/interfaces/IComptroller.sol - + -35 - -<<Interface>> -IVault -../contracts/interfaces/IVault.sol +40 + +<<Interface>> +IVault +../contracts/interfaces/IVault.sol + + + +180 + +VaultStorage +../contracts/vault/VaultStorage.sol + + + +40->180 + + - + -168 - -<<Interface>> -ILens -../contracts/interfaces/morpho/ILens.sol +197 + +<<Interface>> +ILens +../contracts/interfaces/morpho/ILens.sol - - -168->22 - - + + +197->22 + + - + -169 +198 <<Interface>> IMorpho ../contracts/interfaces/morpho/IMorpho.sol - - -168->169 - - + + +197->198 + + - + -296 - +234 + <<Interface>> ICompoundOracle ../contracts/interfaces/morpho/compound/ICompoundOracle.sol - - -168->296 - - - - + -169->22 - - +197->234 + + - - -134 - -MorphoAaveStrategy -../contracts/strategies/MorphoAaveStrategy.sol - - - -134->168 - - - - - -134->169 - - - - - -150 - -<<Abstract>> -InitializableAbstractStrategy -../contracts/utils/InitializableAbstractStrategy.sol - - + -134->150 - - +198->22 + + - + 149 - -<<Abstract>> -Initializable -../contracts/utils/Initializable.sol + +MorphoAaveStrategy +../contracts/strategies/MorphoAaveStrategy.sol - - -150->7 - - - - - -150->35 - - - - + -150->149 - - +149->197 + + - - -150->150 - - + + +149->198 + + - + -436 - -<<Interface>> -IERC20 -../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol +168 + +<<Abstract>> +InitializableAbstractStrategy +../contracts/utils/InitializableAbstractStrategy.sol + + + +149->168 + + + + + +159 + +OUSD +../contracts/token/OUSD.sol - + -150->436 - - +159->7 + + + + + +167 + +<<Abstract>> +Initializable +../contracts/utils/Initializable.sol + + + +159->167 + + + + + +170 + +<<Abstract>> +InitializableERC20Detailed +../contracts/utils/InitializableERC20Detailed.sol + + + +159->170 + + + + + +168->7 + + + + + +168->40 + + + + + +168->167 + + + + + +168->168 + + + + + +357 + +<<Interface>> +IERC20 +../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol + + + +168->357 + + + + + +170->357 + + + + + +180->7 + + + + + +180->159 + + + + + +180->167 + + diff --git a/contracts/docs/MorphoAaveStrategySquashed.svg b/contracts/docs/MorphoAaveStrategySquashed.svg index e87915427c..494c855937 100644 --- a/contracts/docs/MorphoAaveStrategySquashed.svg +++ b/contracts/docs/MorphoAaveStrategySquashed.svg @@ -4,48 +4,50 @@ - - + + UmlClassDiagram - - + + -134 - -MorphoAaveStrategy -../contracts/strategies/MorphoAaveStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +149 + +MorphoAaveStrategy +../contracts/strategies/MorphoAaveStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>>   harvesterAddress: address <<InitializableAbstractStrategy>>   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>>   MORPHO: address <<MorphoAaveStrategy>>   LENS: address <<MorphoAaveStrategy>> - + Internal:    _governor(): (governorOut: address) <<Governable>>    _pendingGovernor(): (pendingGovernor: address) <<Governable>>    _setGovernor(newGovernor: address) <<Governable>>    _setPendingGovernor(newGovernor: address) <<Governable>>    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>>    _collectRewardTokens() <<InitializableAbstractStrategy>>    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>>    _abstractSetPToken(_asset: address, _pToken: address) <<MorphoAaveStrategy>> @@ -56,7 +58,7 @@ External:    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>>    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<MorphoAaveStrategy>>    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<MorphoAaveStrategy>>    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>>    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> @@ -70,28 +72,28 @@    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<MorphoAaveStrategy>>    checkBalance(_asset: address): (balance: uint256) <<MorphoAaveStrategy>>    supportsAsset(_asset: address): bool <<MorphoAaveStrategy>> -    initialize(_vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<MorphoAaveStrategy>> -    getPendingRewards(): (balance: uint256) <<MorphoAaveStrategy>> -Public: -    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> -    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> -    <<modifier>> initializer() <<Initializable>> -    <<modifier>> onlyGovernor() <<Governable>> -    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +    getPendingRewards(): (balance: uint256) <<MorphoAaveStrategy>> +Public: +    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> +    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> +    <<modifier>> initializer() <<Initializable>> +    <<modifier>> onlyGovernor() <<Governable>> +    <<modifier>> nonReentrant() <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<MorphoAaveStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> diff --git a/contracts/docs/MorphoAaveStrategyStorage.svg b/contracts/docs/MorphoAaveStrategyStorage.svg index f733fc4730..3ac3ef41cf 100644 --- a/contracts/docs/MorphoAaveStrategyStorage.svg +++ b/contracts/docs/MorphoAaveStrategyStorage.svg @@ -49,13 +49,13 @@ uint256[50]: Initializable.______gap (1600) -unallocated (12) - -address: InitializableAbstractStrategy.platformAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_platformAddress (20) -unallocated (12) - -address: InitializableAbstractStrategy.vaultAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_vaultAddress (20) mapping(address=>address): InitializableAbstractStrategy.assetToPToken (32) diff --git a/contracts/docs/MorphoCompStrategyHierarchy.svg b/contracts/docs/MorphoCompStrategyHierarchy.svg index 87e4039d5a..8f6c6ad879 100644 --- a/contracts/docs/MorphoCompStrategyHierarchy.svg +++ b/contracts/docs/MorphoCompStrategyHierarchy.svg @@ -4,17 +4,17 @@ - - + + UmlClassDiagram - + 7 - -Governable -../contracts/governance/Governable.sol + +Governable +../contracts/governance/Governable.sol @@ -24,168 +24,238 @@ IComptroller ../contracts/interfaces/IComptroller.sol - + -35 +40 <<Interface>> IVault ../contracts/interfaces/IVault.sol - + + +180 + +VaultStorage +../contracts/vault/VaultStorage.sol + + + +40->180 + + + + -168 +197 <<Interface>> ILens ../contracts/interfaces/morpho/ILens.sol - - -168->22 + + +197->22 - + -169 +198 <<Interface>> IMorpho ../contracts/interfaces/morpho/IMorpho.sol - - -168->169 + + +197->198 - + -296 +234 <<Interface>> ICompoundOracle ../contracts/interfaces/morpho/compound/ICompoundOracle.sol - - -168->296 + + +197->234 - - -169->22 + + +198->22 - + -110 +125 <<Abstract>> BaseCompoundStrategy ../contracts/strategies/BaseCompoundStrategy.sol - + -126 +142 <<Interface>> ICERC20 ../contracts/strategies/ICompound.sol - - -110->126 + + +125->142 - - -150 + + +168 <<Abstract>> InitializableAbstractStrategy ../contracts/utils/InitializableAbstractStrategy.sol - - -110->150 + + +125->168 - + -135 +150 MorphoCompoundStrategy ../contracts/strategies/MorphoCompoundStrategy.sol - - -135->168 + + +150->197 - - -135->169 + + +150->198 - - -135->110 + + +150->125 - + -149 - -<<Abstract>> -Initializable -../contracts/utils/Initializable.sol +159 + +OUSD +../contracts/token/OUSD.sol - + + +159->7 + + + + + +167 + +<<Abstract>> +Initializable +../contracts/utils/Initializable.sol + + -150->7 - - +159->167 + + - - -150->35 + + +170 + +<<Abstract>> +InitializableERC20Detailed +../contracts/utils/InitializableERC20Detailed.sol + + + +159->170 + + + + + +168->7 + + + + + +168->40 - - -150->149 - - + + +168->167 + + - - -150->150 + + +168->168 - - -436 - -<<Interface>> -IERC20 -../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol + + +357 + +<<Interface>> +IERC20 +../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol - - -150->436 - - + + +168->357 + + + + + +170->357 + + + + + +180->7 + + + + + +180->159 + + + + + +180->167 + + diff --git a/contracts/docs/MorphoCompStrategySquashed.svg b/contracts/docs/MorphoCompStrategySquashed.svg index eb9d5fba89..d57dac3609 100644 --- a/contracts/docs/MorphoCompStrategySquashed.svg +++ b/contracts/docs/MorphoCompStrategySquashed.svg @@ -4,49 +4,51 @@ - - + + UmlClassDiagram - - + + -135 - -MorphoCompoundStrategy -../contracts/strategies/MorphoCompoundStrategy.sol - -Private: -   initialized: bool <<Initializable>> -   initializing: bool <<Initializable>> -   ______gap: uint256[50] <<Initializable>> -   governorPosition: bytes32 <<Governable>> -   pendingGovernorPosition: bytes32 <<Governable>> -   reentryStatusPosition: bytes32 <<Governable>> -   _reserved: int256[98] <<InitializableAbstractStrategy>> -   __reserved: int256[50] <<BaseCompoundStrategy>> -Internal: -   assetsMapped: address[] <<InitializableAbstractStrategy>> -Public: -   _NOT_ENTERED: uint256 <<Governable>> -   _ENTERED: uint256 <<Governable>> -   platformAddress: address <<InitializableAbstractStrategy>> -   vaultAddress: address <<InitializableAbstractStrategy>> -   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>> -   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> -   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +150 + +MorphoCompoundStrategy +../contracts/strategies/MorphoCompoundStrategy.sol + +Private: +   initialized: bool <<Initializable>> +   initializing: bool <<Initializable>> +   ______gap: uint256[50] <<Initializable>> +   governorPosition: bytes32 <<Governable>> +   pendingGovernorPosition: bytes32 <<Governable>> +   reentryStatusPosition: bytes32 <<Governable>> +   _deprecated_platformAddress: address <<InitializableAbstractStrategy>> +   _deprecated_vaultAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardTokenAddress: address <<InitializableAbstractStrategy>> +   _deprecated_rewardLiquidationThreshold: uint256 <<InitializableAbstractStrategy>> +   _reserved: int256[98] <<InitializableAbstractStrategy>> +   __reserved: int256[50] <<BaseCompoundStrategy>> +Internal: +   assetsMapped: address[] <<InitializableAbstractStrategy>> +Public: +   _NOT_ENTERED: uint256 <<Governable>> +   _ENTERED: uint256 <<Governable>> +   platformAddress: address <<InitializableAbstractStrategy>> +   vaultAddress: address <<InitializableAbstractStrategy>> +   assetToPToken: mapping(address=>address) <<InitializableAbstractStrategy>>   harvesterAddress: address <<InitializableAbstractStrategy>>   rewardTokenAddresses: address[] <<InitializableAbstractStrategy>>   MORPHO: address <<MorphoCompoundStrategy>>   LENS: address <<MorphoCompoundStrategy>> - + Internal:    _governor(): (governorOut: address) <<Governable>>    _pendingGovernor(): (pendingGovernor: address) <<Governable>>    _setGovernor(newGovernor: address) <<Governable>>    _setPendingGovernor(newGovernor: address) <<Governable>>    _changeGovernor(_newGovernor: address) <<Governable>> -    _initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>> +    _initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<InitializableAbstractStrategy>>    _collectRewardTokens() <<InitializableAbstractStrategy>>    _setPTokenAddress(_asset: address, _pToken: address) <<InitializableAbstractStrategy>>    _abstractSetPToken(_asset: address, _pToken: address) <<MorphoCompoundStrategy>> @@ -58,7 +60,7 @@ External:    transferGovernance(_newGovernor: address) <<onlyGovernor>> <<Governable>>    claimGovernance() <<Governable>> -    initialize(_platformAddress: address, _vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<InitializableAbstractStrategy>> +    initialize(_rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<MorphoCompoundStrategy>>    collectRewardTokens() <<onlyHarvester, nonReentrant>> <<MorphoCompoundStrategy>>    setRewardTokenAddresses(_rewardTokenAddresses: address[]) <<onlyGovernor>> <<InitializableAbstractStrategy>>    getRewardTokenAddresses(): address[] <<InitializableAbstractStrategy>> @@ -72,28 +74,28 @@    withdrawAll() <<onlyVaultOrGovernor, nonReentrant>> <<MorphoCompoundStrategy>>    checkBalance(_asset: address): (balance: uint256) <<MorphoCompoundStrategy>>    supportsAsset(_asset: address): bool <<BaseCompoundStrategy>> -    initialize(_vaultAddress: address, _rewardTokenAddresses: address[], _assets: address[], _pTokens: address[]) <<onlyGovernor, initializer>> <<MorphoCompoundStrategy>> -    getPendingRewards(): (balance: uint256) <<MorphoCompoundStrategy>> -Public: -    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> -    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> -    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> -    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> -    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> -    <<modifier>> initializer() <<Initializable>> -    <<modifier>> onlyGovernor() <<Governable>> -    <<modifier>> nonReentrant() <<Governable>> -    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> -    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> -    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> -    constructor() <<Governable>> -    governor(): address <<Governable>> -    isGovernor(): bool <<Governable>> +    getPendingRewards(): (balance: uint256) <<MorphoCompoundStrategy>> +Public: +    <<event>> PendingGovernorshipTransfer(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> GovernorshipTransferred(previousGovernor: address, newGovernor: address) <<Governable>> +    <<event>> PTokenAdded(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> PTokenRemoved(_asset: address, _pToken: address) <<InitializableAbstractStrategy>> +    <<event>> Deposit(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> Withdrawal(_asset: address, _pToken: address, _amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenCollected(recipient: address, rewardToken: address, amount: uint256) <<InitializableAbstractStrategy>> +    <<event>> RewardTokenAddressesUpdated(_oldAddresses: address[], _newAddresses: address[]) <<InitializableAbstractStrategy>> +    <<event>> HarvesterAddressesUpdated(_oldHarvesterAddress: address, _newHarvesterAddress: address) <<InitializableAbstractStrategy>> +    <<modifier>> initializer() <<Initializable>> +    <<modifier>> onlyGovernor() <<Governable>> +    <<modifier>> nonReentrant() <<Governable>> +    <<modifier>> onlyVault() <<InitializableAbstractStrategy>> +    <<modifier>> onlyHarvester() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernor() <<InitializableAbstractStrategy>> +    <<modifier>> onlyVaultOrGovernorOrStrategist() <<InitializableAbstractStrategy>> +    constructor() <<Governable>> +    governor(): address <<Governable>> +    isGovernor(): bool <<Governable>> +    constructor(_stratConfig: BaseStrategyConfig) <<MorphoCompoundStrategy>>    transferToken(_asset: address, _amount: uint256) <<onlyGovernor>> <<InitializableAbstractStrategy>> diff --git a/contracts/docs/MorphoCompStrategyStorage.svg b/contracts/docs/MorphoCompStrategyStorage.svg index 7ad57fe083..47d580b6b8 100644 --- a/contracts/docs/MorphoCompStrategyStorage.svg +++ b/contracts/docs/MorphoCompStrategyStorage.svg @@ -51,13 +51,13 @@ uint256[50]: Initializable.______gap (1600) -unallocated (12) - -address: InitializableAbstractStrategy.platformAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_platformAddress (20) -unallocated (12) - -address: InitializableAbstractStrategy.vaultAddress (20) +unallocated (12) + +address: InitializableAbstractStrategy._deprecated_vaultAddress (20) mapping(address=>address): InitializableAbstractStrategy.assetToPToken (32) diff --git a/contracts/test/_fixture.js b/contracts/test/_fixture.js index 7427f5b04d..8c240a2046 100644 --- a/contracts/test/_fixture.js +++ b/contracts/test/_fixture.js @@ -1369,18 +1369,24 @@ async function compoundFixture() { await deploy("StandaloneCompound", { from: governorAddr, contract: "CompoundStrategy", + args: [ + [ + addresses.dead, + governorAddr, // Using Governor in place of Vault here + ], + ], }); fixture.cStandalone = await ethers.getContract("StandaloneCompound"); // Set governor as vault - await fixture.cStandalone.connect(sGovernor).initialize( - addresses.dead, - governorAddr, // Using Governor in place of Vault here - [assetAddresses.COMP], - [assetAddresses.DAI, assetAddresses.USDC], - [assetAddresses.cDAI, assetAddresses.cUSDC] - ); + await fixture.cStandalone + .connect(sGovernor) + .initialize( + [assetAddresses.COMP], + [assetAddresses.DAI, assetAddresses.USDC], + [assetAddresses.cDAI, assetAddresses.cUSDC] + ); await fixture.cStandalone .connect(sGovernor) @@ -1407,6 +1413,12 @@ async function threepoolFixture() { await deploy("StandaloneThreePool", { from: governorAddr, contract: "ThreePoolStrategy", + args: [ + [ + assetAddresses.ThreePool, + governorAddr, // Using Governor in place of Vault here + ], + ], }); fixture.tpStandalone = await ethers.getContract("StandaloneThreePool"); @@ -1414,20 +1426,8 @@ async function threepoolFixture() { // Set governor as vault await fixture.tpStandalone.connect(sGovernor)[ // eslint-disable-next-line - "initialize(address,address,address[],address[],address[],address,address)" - ]( - assetAddresses.ThreePool, - governorAddr, // Using Governor in place of Vault here - [assetAddresses.CRV], - [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], - [ - assetAddresses.ThreePoolToken, - assetAddresses.ThreePoolToken, - assetAddresses.ThreePoolToken, - ], - assetAddresses.ThreePoolGauge, - assetAddresses.CRVMinter - ); + "initialize(address[],address[],address[],address,address)" + ]([assetAddresses.CRV], [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], [assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken], assetAddresses.ThreePoolGauge, assetAddresses.CRVMinter); return fixture; }