@harvest-finance/harvest-strategy-polygon 0.0.1-security → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @harvest-finance/harvest-strategy-polygon might be problematic. Click here for more details.
- package/README.md +110 -5
- package/contracts/base/Controller.sol +125 -0
- package/contracts/base/ControllerV2.sol +363 -0
- package/contracts/base/FeeRewardForwarder.sol +163 -0
- package/contracts/base/PotPool.sol +360 -0
- package/contracts/base/ProfitSharingReceiver.sol +39 -0
- package/contracts/base/RewardForwarderV2.sol +109 -0
- package/contracts/base/Vault.sol +344 -0
- package/contracts/base/VaultERC4626.sol +113 -0
- package/contracts/base/VaultProxy.sol +35 -0
- package/contracts/base/VaultStorage.sol +199 -0
- package/contracts/base/VaultStorageV2.sol +196 -0
- package/contracts/base/VaultV2.sol +369 -0
- package/contracts/base/ape-base/MiniApeV2Strategy.sol +322 -0
- package/contracts/base/ape-base/interface/IMiniChefV2.sol +31 -0
- package/contracts/base/ape-base/interface/IRewarder.sol +10 -0
- package/contracts/base/factory/MegaFactory.sol +120 -0
- package/contracts/base/factory/interface/IPoolFactory.sol +6 -0
- package/contracts/base/factory/interface/IStrategyFactory.sol +6 -0
- package/contracts/base/factory/interface/IVaultFactory.sol +7 -0
- package/contracts/base/factory/pool/PotPoolFactory.sol +43 -0
- package/contracts/base/factory/strategy/UpgradableStrategyFactory.sol +19 -0
- package/contracts/base/factory/vault/RegularVaultFactory.sol +34 -0
- package/contracts/base/incentives/GlobalIncentivesHelper.sol +167 -0
- package/contracts/base/incentives/NotifyHelperGeneric.sol +61 -0
- package/contracts/base/incentives/NotifyHelperStateful.sol +290 -0
- package/contracts/base/inheritance/Controllable.sol +26 -0
- package/contracts/base/inheritance/ControllableInit.sol +31 -0
- package/contracts/base/inheritance/Governable.sol +29 -0
- package/contracts/base/inheritance/GovernableInit.sol +51 -0
- package/contracts/base/inheritance/IUpgradeSource.sol +8 -0
- package/contracts/base/inheritance/OwnableWhitelist.sol +17 -0
- package/contracts/base/inheritance/RewardTokenProfitNotifier.sol +48 -0
- package/contracts/base/inheritance/Storage.sol +36 -0
- package/contracts/base/interface/IController.sol +30 -0
- package/contracts/base/interface/IControllerV2.sol +135 -0
- package/contracts/base/interface/IERC4626.sol +263 -0
- package/contracts/base/interface/IFeeRewardForwarder.sol +9 -0
- package/contracts/base/interface/IProfitSharingReceiver.sol +10 -0
- package/contracts/base/interface/IRewardForwarder.sol +58 -0
- package/contracts/base/interface/IRewardPool.sol +34 -0
- package/contracts/base/interface/IStrategy.sol +25 -0
- package/contracts/base/interface/IUniversalLiquidator.sol +21 -0
- package/contracts/base/interface/IUniversalLiquidatorRegistry.sol +20 -0
- package/contracts/base/interface/IUpgradeSource.sol +8 -0
- package/contracts/base/interface/IVault.sol +35 -0
- package/contracts/base/interface/aave/DataTypes.sol +266 -0
- package/contracts/base/interface/aave/IAToken.sol +37 -0
- package/contracts/base/interface/aave/IPool.sol +13 -0
- package/contracts/base/interface/balancer/Gauge.sol +22 -0
- package/contracts/base/interface/balancer/IBVault.sol +557 -0
- package/contracts/base/interface/balancer/IBalancerMinter.sol +114 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPool.sol +185 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPoolFactory.sol +16 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPoolRebalancer.sol +8 -0
- package/contracts/base/interface/balancer/linearPool/IPoolSwapStructs.sol +57 -0
- package/contracts/base/interface/caviar/ICaviarChef.sol +16 -0
- package/contracts/base/interface/compound/IComet.sol +114 -0
- package/contracts/base/interface/compound/ICometRewards.sol +17 -0
- package/contracts/base/interface/curve/Gauge.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_2token.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_2token_underlying.sol +31 -0
- package/contracts/base/interface/curve/ICurveDeposit_3token.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_3token_meta.sol +20 -0
- package/contracts/base/interface/curve/ICurveDeposit_3token_underlying.sol +31 -0
- package/contracts/base/interface/curve/ICurveDeposit_4token.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_4token_meta.sol +20 -0
- package/contracts/base/interface/curve/ICurveDeposit_4token_underlying.sol +31 -0
- package/contracts/base/interface/curve/ICurveDeposit_5token.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_5token_meta.sol +20 -0
- package/contracts/base/interface/curve/ICurveDeposit_5token_underlying.sol +31 -0
- package/contracts/base/interface/curve/ICurveDeposit_6token.sol +25 -0
- package/contracts/base/interface/curve/ICurveDeposit_6token_meta.sol +20 -0
- package/contracts/base/interface/gamma/IClearing.sol +8 -0
- package/contracts/base/interface/gamma/IHypervisor.sol +17 -0
- package/contracts/base/interface/gamma/IStakingRewards.sol +35 -0
- package/contracts/base/interface/gamma/IUniProxy.sol +15 -0
- package/contracts/base/interface/kyber/IDMMExchangeRouter.sol +69 -0
- package/contracts/base/interface/kyber/IDMMFactory.sol +35 -0
- package/contracts/base/interface/kyber/IDMMLiquidityRouter.sol +204 -0
- package/contracts/base/interface/kyber/IDMMPool.sol +42 -0
- package/contracts/base/interface/kyber/IDMMRouter01.sol +12 -0
- package/contracts/base/interface/kyber/IDMMRouter02.sol +55 -0
- package/contracts/base/interface/kyber/IKyberZap.sol +7 -0
- package/contracts/base/interface/merkl/IDistributor.sol +6 -0
- package/contracts/base/interface/morpho/IMetaMorpho.sol +7 -0
- package/contracts/base/interface/pearl/IGauge.sol +13 -0
- package/contracts/base/interface/pearl/IPair.sol +44 -0
- package/contracts/base/interface/pearl/IRouter.sol +305 -0
- package/contracts/base/interface/quickswap/IDragonLair.sol +25 -0
- package/contracts/base/interface/quickswap/IMasterChef.sol +13 -0
- package/contracts/base/interface/uniswap/IUniswapV2Factory.sol +15 -0
- package/contracts/base/interface/uniswap/IUniswapV2Migrator.sol +6 -0
- package/contracts/base/interface/uniswap/IUniswapV2Pair.sol +59 -0
- package/contracts/base/interface/uniswap/IUniswapV2Router01.sol +96 -0
- package/contracts/base/interface/uniswap/IUniswapV2Router02.sol +137 -0
- package/contracts/base/interface/uniswap/IUniswapV3Pool.sol +24 -0
- package/contracts/base/interface/uniswap/IUniswapV3Router.sol +64 -0
- package/contracts/base/interface/uniswap/IWETH.sol +8 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolActions.sol +103 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolDerivedState.sol +40 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolEvents.sol +121 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolImmutables.sol +35 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolOwnerActions.sol +23 -0
- package/contracts/base/interface/uniswap/pool/IUniswapV3PoolState.sol +116 -0
- package/contracts/base/masterchef-base/MasterChefHodlStrategy.sol +240 -0
- package/contracts/base/masterchef-base/MasterChefStrategy.sol +364 -0
- package/contracts/base/masterchef-base/interfaces/IMasterChef.sol +12 -0
- package/contracts/base/migration/vaultMigratable_2JPYv2.sol +87 -0
- package/contracts/base/migration/vaultMigratable_bal2EUR_PAR.sol +121 -0
- package/contracts/base/migration/vaultMigratable_bal2EUR_agEUR.sol +121 -0
- package/contracts/base/migration/vaultMigratable_balMaticX.sol +153 -0
- package/contracts/base/migration/vaultMigratable_balStMatic.sol +153 -0
- package/contracts/base/noop/NoopStrategy.sol +89 -0
- package/contracts/base/noop/NoopStrategyUpgradeable.sol +92 -0
- package/contracts/base/sushi-base/MiniChefV2Strategy.sol +380 -0
- package/contracts/base/sushi-base/interface/IMiniChefV2.sol +31 -0
- package/contracts/base/sushi-base/interface/IRewarder.sol +9 -0
- package/contracts/base/sushi-base/lib/BoringERC20.sol +30 -0
- package/contracts/base/upgradability/Address.sol +33 -0
- package/contracts/base/upgradability/BaseUpgradeabilityProxy.sol +61 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategy.sol +111 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategyStorage.sol +176 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategyStorageV2.sol +290 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategyV2.sol +145 -0
- package/contracts/base/upgradability/IUpgradable.sol +7 -0
- package/contracts/base/upgradability/Proxy.sol +71 -0
- package/contracts/base/upgradability/ReentrancyGuard.sol +57 -0
- package/contracts/base/upgradability/ReentrancyGuardUpgradeable.sol +51 -0
- package/contracts/base/upgradability/StrategyProxy.sol +35 -0
- package/contracts/base/wmatic/WMATIC.sol +8 -0
- package/contracts/strategies/aave/AaveSupplyStrategy.sol +213 -0
- package/contracts/strategies/aave/AaveSupplyStrategyMainnet_DAI.sol +23 -0
- package/contracts/strategies/aave/AaveSupplyStrategyMainnet_EURS.sol +23 -0
- package/contracts/strategies/aave/AaveSupplyStrategyMainnet_USDC.sol +23 -0
- package/contracts/strategies/aave/AaveSupplyStrategyMainnet_USDCe.sol +23 -0
- package/contracts/strategies/aave/AaveSupplyStrategyMainnet_USDT.sol +23 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_BANANA_MATIC.sol +36 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_BNB_MATIC.sol +36 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_BTC_MATIC.sol +36 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_DAI_MATIC.sol +36 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_DAI_USDC.sol +37 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_ETH_MATIC.sol +36 -0
- package/contracts/strategies/ape/ApeStrategyMainnet_USDT_MATIC.sol +36 -0
- package/contracts/strategies/aura/AuraStrategy.sol +347 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_jEUR_PAR.sol +30 -0
- package/contracts/strategies/aura/interface/IAuraBaseRewardPool.sol +25 -0
- package/contracts/strategies/aura/interface/IAuraBooster.sol +17 -0
- package/contracts/strategies/aura/interface/IAuraDepositor.sol +7 -0
- package/contracts/strategies/balancer/BalancerStrategyV3.sol +509 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_2BRL.sol +39 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_2BRLUSD.sol +38 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_2EUR_PAR.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_2EUR_PARv2.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_2EUR_agEUR.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_MATIC_USDC_ETH_BAL.sol +32 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_MaticX.sol +37 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_MaticX_amMatic.sol +38 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_SPHERE_MATIC.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_TNGBL_USDC.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_WBTC_ETH_USDC.sol +32 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_bbamusd.sol +36 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_frxETH.sol +32 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_frxETH_amWETH.sol +35 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_stETH.sol +35 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_stMatic.sol +36 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_stMatic_amMatic.sol +39 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_tetuBal.sol +36 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_wUSDR_USDC.sol +34 -0
- package/contracts/strategies/balancer/BalancerStrategyV3Mainnet_wstETH_amWETH.sol +37 -0
- package/contracts/strategies/balancer/interface/Gauge.sol +26 -0
- package/contracts/strategies/balancer/interface/IBVault.sol +557 -0
- package/contracts/strategies/balancer/interface/IBalanceMinter.sol +114 -0
- package/contracts/strategies/complifi/ComplifiDerivStrategy.sol +381 -0
- package/contracts/strategies/complifi/ComplifiDerivStrategyMainnet_ETH5x.sol +35 -0
- package/contracts/strategies/complifi/ComplifiStrategy.sol +362 -0
- package/contracts/strategies/complifi/ComplifiStrategyMainnet_COMFI_WETH.sol +34 -0
- package/contracts/strategies/complifi/interfaces/ILiquidityMining.sol +13 -0
- package/contracts/strategies/complifi/interfaces/ILiquidityPool.sol +63 -0
- package/contracts/strategies/complifi/interfaces/IProxyActions.sol +10 -0
- package/contracts/strategies/complifi/interfaces/IUSDCVault.sol +55 -0
- package/contracts/strategies/compound/CompoundStrategy.sol +296 -0
- package/contracts/strategies/compound/CompoundStrategyMainnet_USDC.sol +28 -0
- package/contracts/strategies/compound/CompoundStrategyMainnet_USDT.sol +28 -0
- package/contracts/strategies/compound-blue/CompoundBlueStrategy.sol +292 -0
- package/contracts/strategies/compound-blue/CompoundBlueStrategyMainnet_ETH.sol +27 -0
- package/contracts/strategies/compound-blue/CompoundBlueStrategyMainnet_USDC.sol +27 -0
- package/contracts/strategies/compound-blue/CompoundBlueStrategyMainnet_USDT.sol +27 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_3CRV.sol +40 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_3CRYPTO.sol +37 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_CRV_3CRYPTO copy.sol +37 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_MATIC_3CRYPTO.sol +37 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_USDR.sol +40 -0
- package/contracts/strategies/convex/ConvexStrategyMainnet_aCRV.sol +38 -0
- package/contracts/strategies/convex/base/ConvexStrategy.sol +480 -0
- package/contracts/strategies/convex/interface/IBaseRewardPool.sol +13 -0
- package/contracts/strategies/convex/interface/IBooster.sol +10 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategy.sol +272 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategyMainnet_QS_ETH_USDC.sol +25 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategyMainnet_QS_ETH_USDT.sol +25 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategyMainnet_QS_MATIC_USDT.sol +25 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategyMainnet_QS_TBTC_ETH.sol +25 -0
- package/contracts/strategies/gamma-merkl/GammaMerklStrategyMainnet_QS_WBTC_ETH_w.sol +25 -0
- package/contracts/strategies/genomes/NoopStrategy_GENE_ETH.sol +23 -0
- package/contracts/strategies/genomes/NoopStrategy_GNOME_ETH.sol +23 -0
- package/contracts/strategies/idle/IdleFinanceStrategy.sol +240 -0
- package/contracts/strategies/idle/IdleStrategyDAIMainnet.sol +33 -0
- package/contracts/strategies/idle/IdleStrategyUSDCMainnet.sol +33 -0
- package/contracts/strategies/idle/IdleStrategyWETHMainnet.sol +30 -0
- package/contracts/strategies/idle/interface/IdleToken.sol +58 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3.sol +351 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2CAD.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2EUR.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2EUR_EURT.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2EUR_EURe.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2EUR_PAR.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2JPY.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2JPYv2.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2NZD.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_2SGD.sol +34 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_jCHF_USDC.sol +35 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_jCHF_WETH.sol +35 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_jEUR_USDC.sol +35 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_jEUR_WETH.sol +35 -0
- package/contracts/strategies/jarvis/JarvisHodlStrategyV3Mainnet_jGBP_USDC.sol +35 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3.sol +281 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_AUR3_USDC.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_AURJUL22_WETH.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_DEN2_4EUR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_DEN3_4EUR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_DEN4_4EUR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTANGLENOV22_2EURagEUR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTANGLE_2EURagEUR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTJUL22_USDC.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTMAY22_USDC.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTMIMONOV22_2EURPAR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTMIMO_2EURPAR.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTNOV22_USDC.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_JRTSEP22_USDC.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_QUI_2CAD.sol +27 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_SES_2JPY.sol +28 -0
- package/contracts/strategies/jarvis/JarvisStrategyV3Mainnet_agDEN_2EUR.sol +27 -0
- package/contracts/strategies/jarvis/interface/IElysianFields.sol +11 -0
- package/contracts/strategies/jarvis/interface/IKyberFairLaunch.sol +13 -0
- package/contracts/strategies/jarvis/interface/IKyberRewardLocker.sol +9 -0
- package/contracts/strategies/meshswap/MeshswapStrategy.sol +304 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_MESH_oMOOI.sol +30 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_MESH_oZEMIT.sol +30 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_USDC_oUSDC.sol +31 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_USDT_oUSDT.sol +31 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_WMATIC_MESH.sol +27 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_WMATIC_USDC.sol +28 -0
- package/contracts/strategies/meshswap/MeshswapStrategyMainnet_WMATIC_USDT.sol +28 -0
- package/contracts/strategies/meshswap/interface/IExchange.sol +9 -0
- package/contracts/strategies/meshswap/interface/IRouter.sol +68 -0
- package/contracts/strategies/pearl/CaviarStrategy.sol +244 -0
- package/contracts/strategies/pearl/CaviarStrategyMainnet_CVR.sol +26 -0
- package/contracts/strategies/pearl/PearlHodlStrategy.sol +254 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_CVR_PEARL.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_DAI_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_ETH_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_MATIC_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_PEARL_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_STAR_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_TNGBL_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_USDC_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_USDT_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_WBTC_USDR.sol +27 -0
- package/contracts/strategies/pearl/PearlHodlStrategyMainnet_wUSDR_USDR.sol +27 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategy.sol +400 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_MATIC_ETH_narrow.sol +31 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_MATIC_ETH_wide.sol +31 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_MATIC_USDC_narrow.sol +31 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_MATIC_USDC_wide.sol +31 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_USDC_ETH_narrow.sol +34 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyMainnet_USDC_ETH_wide.sol +34 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2.sol +348 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_USDC_DAI.sol +28 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_USDC_USDT.sol +29 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_WBTC_ETH_narrow.sol +28 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_WBTC_USDC_narrow.sol +28 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_cbETH_ETH.sol +28 -0
- package/contracts/strategies/quick-gamma/QuickGammaStrategyV2Mainnet_wstETH_ETH.sol +28 -0
- package/contracts/strategies/uniswap-gamma/UniswapGammaStrategy.sol +312 -0
- package/contracts/strategies/uniswap-gamma/UniswapGammaStrategyMainnet_USDC_DAI.sol +28 -0
- package/contracts/strategies/uniswap-gamma/UniswapGammaStrategyMainnet_USDC_USDT.sol +28 -0
- package/contracts/strategies/uniswap-gamma/UniswapGammaStrategyMainnet_USDC_WETH.sol +28 -0
- package/contracts/strategies/uniswap-gamma/UniswapGammaStrategyMainnet_WMATIC_USDC.sol +28 -0
- package/contracts/strategies/yel/YelStrategy.sol +350 -0
- package/contracts/strategies/yel/YelStrategyMainnet_YEL_WETH.sol +29 -0
- package/hardhat.config.js +58 -0
- package/index.js +42 -0
- package/package.json +56 -6
- package/scripts/01-deploy-vault-regular-with-upgradable-strategy.js +41 -0
- package/scripts/02-deploy-vault-regular.js +35 -0
- package/scripts/03-deploy-upgradable-strategy.js +34 -0
- package/scripts/04-deploy-new-implementation.js +24 -0
- package/scripts/README.md +55 -0
- package/scripts/utils.js +42 -0
- package/test/aave/dai.js +207 -0
- package/test/aave/eurs.js +207 -0
- package/test/aave/usdc.js +206 -0
- package/test/aave/usdce.js +206 -0
- package/test/aave/usdt.js +206 -0
- package/test/ape/banana-matic.js +157 -0
- package/test/ape/bnb-matic.js +159 -0
- package/test/ape/btc-matic.js +159 -0
- package/test/ape/dai-matic.js +159 -0
- package/test/ape/dai-usdc.js +163 -0
- package/test/ape/eth-matic.js +158 -0
- package/test/ape/usdt-matic.js +159 -0
- package/test/aura/jeur-par.js +135 -0
- package/test/balancer/2brl_v3.js +123 -0
- package/test/balancer/2brlusd_v3.js +123 -0
- package/test/balancer/2eur_ageur.js +141 -0
- package/test/balancer/2eur_par.js +141 -0
- package/test/balancer/2eur_par_v2.js +123 -0
- package/test/balancer/bbamusd_v3.js +124 -0
- package/test/balancer/btc.js +131 -0
- package/test/balancer/frxETH.js +123 -0
- package/test/balancer/frxeth_amweth.js +123 -0
- package/test/balancer/matic_usdc_eth_bal.js +123 -0
- package/test/balancer/maticx_ammatic.js +123 -0
- package/test/balancer/maticx_v2.js +120 -0
- package/test/balancer/maticx_v3.js +141 -0
- package/test/balancer/polybase.js +131 -0
- package/test/balancer/polybase_v2.js +121 -0
- package/test/balancer/polydefi.js +131 -0
- package/test/balancer/polydefi2.js +131 -0
- package/test/balancer/qipool.js +136 -0
- package/test/balancer/sphere_matic.js +123 -0
- package/test/balancer/stETH.js +123 -0
- package/test/balancer/stable.js +131 -0
- package/test/balancer/stable_v2.js +121 -0
- package/test/balancer/stmatic_ammatic.js +123 -0
- package/test/balancer/stmatic_v2.js +120 -0
- package/test/balancer/stmatic_v3.js +141 -0
- package/test/balancer/tetubal_v3.js +123 -0
- package/test/balancer/tngbl_usdc.js +123 -0
- package/test/balancer/tricrypto.js +131 -0
- package/test/balancer/tusd_stable.js +142 -0
- package/test/balancer/usdc_weth.js +136 -0
- package/test/balancer/usdc_weth_v2.js +123 -0
- package/test/balancer/wbtc_eth_usdc.js +123 -0
- package/test/balancer/wbtc_weth.js +136 -0
- package/test/balancer/wsteth_amweth.js +123 -0
- package/test/balancer/wusdr_usdc.js +123 -0
- package/test/compound/usdc.js +127 -0
- package/test/compound/usdt.js +129 -0
- package/test/compound-blue/eth.js +136 -0
- package/test/compound-blue/usdc.js +136 -0
- package/test/compound-blue/usdt.js +136 -0
- package/test/convex/3crv.js +123 -0
- package/test/convex/3crypto.js +123 -0
- package/test/convex/acrv.js +123 -0
- package/test/convex/crv_3crypto.js +123 -0
- package/test/convex/matic_3crypto.js +123 -0
- package/test/convex/usdr.js +123 -0
- package/test/core/emission-fork.js +197 -0
- package/test/core/emission.js +209 -0
- package/test/core/vault_upgrade.js +129 -0
- package/test/curve/aave.js +132 -0
- package/test/curve/atricrypto3.js +135 -0
- package/test/curve/eurtusd.js +135 -0
- package/test/gamma-merkl/qs-eth-usdc.js +212 -0
- package/test/gamma-merkl/qs-eth-usdt.js +213 -0
- package/test/gamma-merkl/qs-matic-usdt.js +213 -0
- package/test/gamma-merkl/qs-tbtc-eth.js +213 -0
- package/test/gamma-merkl/qs-wbtc-eth-w.js +213 -0
- package/test/genomes/gene-eth.js +115 -0
- package/test/genomes/gnome-eth.js +115 -0
- package/test/idle/dai.js +129 -0
- package/test/idle/usdc.js +128 -0
- package/test/idle/weth.js +128 -0
- package/test/jarvis/2cad-hodl.js +183 -0
- package/test/jarvis/2cad-update-nov22.js +182 -0
- package/test/jarvis/2cad-update.js +177 -0
- package/test/jarvis/2cad-update2.js +182 -0
- package/test/jarvis/2cad-update3.js +182 -0
- package/test/jarvis/2eur-ageur-update-nov22.js +182 -0
- package/test/jarvis/2eur-ageur-update.js +182 -0
- package/test/jarvis/2eur-eure-hodl.js +176 -0
- package/test/jarvis/2eur-eurt-hodl.js +176 -0
- package/test/jarvis/2eur-eurt-update-nov22.js +182 -0
- package/test/jarvis/2eur-hodl.js +176 -0
- package/test/jarvis/2eur-par-hodl.js +176 -0
- package/test/jarvis/2eur-par-update-nov22.js +182 -0
- package/test/jarvis/2jpy-hodl.js +244 -0
- package/test/jarvis/2jpy-update-nov22.js +182 -0
- package/test/jarvis/2jpy-update.js +177 -0
- package/test/jarvis/2jpy-update2.js +182 -0
- package/test/jarvis/2jpyv2-upgrade.js +184 -0
- package/test/jarvis/2nzd-hodl.js +176 -0
- package/test/jarvis/2nzd-update.js +182 -0
- package/test/jarvis/2sgd-hodl.js +176 -0
- package/test/jarvis/2sgd-update-nov22.js +182 -0
- package/test/jarvis/2sgd-update.js +182 -0
- package/test/jarvis/2sgd-update2.js +182 -0
- package/test/jarvis/4eur-hodl-upgrade.js +177 -0
- package/test/jarvis/4eur-hodl.js +183 -0
- package/test/jarvis/4eur-update.js +181 -0
- package/test/jarvis/4eur-update2.js +181 -0
- package/test/jarvis/agden-2eur.js +222 -0
- package/test/jarvis/aur-usdc-v2.js +115 -0
- package/test/jarvis/aur-usdc.js +127 -0
- package/test/jarvis/aur3-usdc.js +115 -0
- package/test/jarvis/aurjul22-weth.js +222 -0
- package/test/jarvis/den-4eur.js +115 -0
- package/test/jarvis/den2-4eur.js +220 -0
- package/test/jarvis/den3-4eur.js +220 -0
- package/test/jarvis/den4-4eur.js +220 -0
- package/test/jarvis/jchf-usdc-hodl-v2.js +184 -0
- package/test/jarvis/jchf-usdc-hodl-v3.js +178 -0
- package/test/jarvis/jchf-usdc-hodl.js +193 -0
- package/test/jarvis/jchf-weth-hodl.js +176 -0
- package/test/jarvis/jeur-usdc-hodl-v2.js +184 -0
- package/test/jarvis/jeur-usdc-hodl-v3.js +178 -0
- package/test/jarvis/jeur-usdc-hodl.js +193 -0
- package/test/jarvis/jeur-weth-hodl.js +176 -0
- package/test/jarvis/jgbp-usdc-hodl-v2.js +184 -0
- package/test/jarvis/jgbp-usdc-hodl-v3.js +178 -0
- package/test/jarvis/jgbp-usdc-hodl.js +193 -0
- package/test/jarvis/jrtangle-2eurageur.js +220 -0
- package/test/jarvis/jrtanglenov22-2eurageur.js +220 -0
- package/test/jarvis/jrtjul22-usdc.js +115 -0
- package/test/jarvis/jrtmay22-usdc.js +115 -0
- package/test/jarvis/jrtmimo-2eurpar.js +220 -0
- package/test/jarvis/jrtmimonov22-2eurpar.js +220 -0
- package/test/jarvis/jrtnov22-usdc.js +220 -0
- package/test/jarvis/jrtsep22-usdc.js +220 -0
- package/test/jarvis/qui-2cad.js +218 -0
- package/test/jarvis/ses-2jpy.js +222 -0
- package/test/meshswap/mesh-omooi.js +197 -0
- package/test/meshswap/mesh-ozemit.js +197 -0
- package/test/meshswap/usdc-ousdc.js +197 -0
- package/test/meshswap/usdt-ousdt.js +197 -0
- package/test/meshswap/wmatic-mesh.js +197 -0
- package/test/meshswap/wmatic-usdc.js +197 -0
- package/test/meshswap/wmatic-usdt.js +197 -0
- package/test/mstable/musd.js +123 -0
- package/test/pearl/cvr-pearl.js +198 -0
- package/test/pearl/cvr.js +133 -0
- package/test/pearl/dai-usdr.js +198 -0
- package/test/pearl/eth-usdr.js +198 -0
- package/test/pearl/matic-usdr.js +198 -0
- package/test/pearl/pearl-usdr.js +198 -0
- package/test/pearl/star-usdr.js +186 -0
- package/test/pearl/tngbl-usdr.js +198 -0
- package/test/pearl/usdc-usdr.js +198 -0
- package/test/pearl/usdt-usdr.js +198 -0
- package/test/pearl/wbtc-usdr.js +198 -0
- package/test/pearl/wusdr-usdr.js +198 -0
- package/test/popsicle/ice-weth.js +128 -0
- package/test/quick/eth-matic.js +132 -0
- package/test/quick/eth-usdt.js +140 -0
- package/test/quick/ifarm-quick.js +147 -0
- package/test/quick/matic-usdc.js +145 -0
- package/test/quick/psp-matic.js +124 -0
- package/test/quick/wbtc-eth.js +145 -0
- package/test/quick-gamma/cbeth-eth.js +207 -0
- package/test/quick-gamma/matic-eth-narrow.js +201 -0
- package/test/quick-gamma/matic-eth-wide.js +197 -0
- package/test/quick-gamma/matic-usdc-narrow.js +197 -0
- package/test/quick-gamma/matic-usdc-wide.js +197 -0
- package/test/quick-gamma/upgrade/matic-eth-narrow.js +204 -0
- package/test/quick-gamma/upgrade/matic-usdc-narrow.js +199 -0
- package/test/quick-gamma/usdc-dai.js +209 -0
- package/test/quick-gamma/usdc-eth-narrow.js +197 -0
- package/test/quick-gamma/usdc-eth-wide.js +197 -0
- package/test/quick-gamma/usdc-usdt.js +209 -0
- package/test/quick-gamma/wbtc-eth-narrow.js +207 -0
- package/test/quick-gamma/wbtc-usdc-narrow.js +209 -0
- package/test/quick-gamma/wsteth-eth.js +207 -0
- package/test/sushi/eth-usdt.js +153 -0
- package/test/sushi/matic-eth.js +138 -0
- package/test/sushi/usdc-eth.js +153 -0
- package/test/test-config.js +24 -0
- package/test/uniswap-gamma/usdc-dai.js +212 -0
- package/test/uniswap-gamma/usdc-usdt.js +212 -0
- package/test/uniswap-gamma/usdc-weth.js +212 -0
- package/test/uniswap-gamma/wmatic-usdc.js +210 -0
- package/test/utilities/Utils.js +96 -0
- package/test/utilities/hh-utils.js +242 -0
- package/test/utilities/make-vault.js +10 -0
- package/test/yel/yel-wmatic.js +129 -0
package/README.md
CHANGED
@@ -1,5 +1,110 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
This
|
4
|
-
|
5
|
-
|
1
|
+
# Polygon Chain: Harvest Strategy Development
|
2
|
+
|
3
|
+
This [Hardhat](https://hardhat.org/) environment is configured to use Mainnet fork by default and provides templates and utilities for strategy development and testing.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
1. Run `npm install` to install all the dependencies.
|
8
|
+
2. Sign up on [Alchemy](https://dashboard.alchemyapi.io/signup/). We recommend using Alchemy over Infura to allow for a reproducible
|
9
|
+
Mainnet fork testing environment as well as efficiency due to caching.
|
10
|
+
3. Create a file `dev-keys.json`:
|
11
|
+
```
|
12
|
+
{
|
13
|
+
"alchemyKey": "<your-alchemy-key>"
|
14
|
+
}
|
15
|
+
```
|
16
|
+
|
17
|
+
## Run
|
18
|
+
|
19
|
+
All tests are located under the `test` folder.
|
20
|
+
|
21
|
+
1. Run `npx hardhat test [test file location]`: `npx hardhat test ./test/curve/aave.js` (if for some reason the NodeJS heap runs out of memory, make sure to explicitly increase its size via `export NODE_OPTIONS=--max_old_space_size=4096`). This will produce the following output:
|
22
|
+
```
|
23
|
+
Polygon Mainnet Curve Aave
|
24
|
+
Impersonating...
|
25
|
+
0xf00dD244228F51547f0563e60bCa65a30FBF5f7f
|
26
|
+
Fetching Underlying at: 0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171
|
27
|
+
New Vault Deployed: 0xF8ce90c2710713552fb564869694B2505Bfc0846
|
28
|
+
Strategy Deployed: 0xDDa0648FA8c9cD593416EC37089C2a2E6060B45c
|
29
|
+
Strategy and vault added to Controller.
|
30
|
+
Happy path
|
31
|
+
loop 0
|
32
|
+
old shareprice: 1000000000000000000
|
33
|
+
new shareprice: 1000000000000000000
|
34
|
+
growth: 1
|
35
|
+
loop 1
|
36
|
+
old shareprice: 1000000000000000000
|
37
|
+
new shareprice: 1000141138681462160
|
38
|
+
growth: 1.000141138681462
|
39
|
+
loop 2
|
40
|
+
old shareprice: 1000141138681462160
|
41
|
+
new shareprice: 1000327782939361291
|
42
|
+
growth: 1.000186617918892
|
43
|
+
loop 3
|
44
|
+
old shareprice: 1000327782939361291
|
45
|
+
new shareprice: 1000514426794411531
|
46
|
+
growth: 1.0001865826964256
|
47
|
+
loop 4
|
48
|
+
old shareprice: 1000514426794411531
|
49
|
+
new shareprice: 1000701097344949064
|
50
|
+
growth: 1.0001865745715788
|
51
|
+
loop 5
|
52
|
+
old shareprice: 1000701097344949064
|
53
|
+
new shareprice: 1000878677026348228
|
54
|
+
growth: 1.0001774552679819
|
55
|
+
loop 6
|
56
|
+
old shareprice: 1000878677026348228
|
57
|
+
new shareprice: 1001019907056855214
|
58
|
+
growth: 1.0001411060438679
|
59
|
+
loop 7
|
60
|
+
old shareprice: 1001019907056855214
|
61
|
+
new shareprice: 1001161152484596161
|
62
|
+
growth: 1.0001411015173078
|
63
|
+
loop 8
|
64
|
+
old shareprice: 1001161152484596161
|
65
|
+
new shareprice: 1001302413308521684
|
66
|
+
growth: 1.0001410969888065
|
67
|
+
loop 9
|
68
|
+
old shareprice: 1001302413308521684
|
69
|
+
new shareprice: 1001443692715028091
|
70
|
+
growth: 1.000141095641665
|
71
|
+
earned!
|
72
|
+
APR: 11.570408862519965 %
|
73
|
+
APY: 12.264303010549993 %
|
74
|
+
√ Farmer should earn money (45307ms)
|
75
|
+
|
76
|
+
|
77
|
+
1 passing (1m)
|
78
|
+
```
|
79
|
+
|
80
|
+
## Develop
|
81
|
+
|
82
|
+
Under `contracts/strategies`, there are plenty of examples to choose from in the repository already, therefore, creating a strategy is no longer a complicated task. Copy-pasting existing strategies with minor modifications is acceptable.
|
83
|
+
|
84
|
+
Under `contracts/base`, there are existing base interfaces and contracts that can speed up development.
|
85
|
+
Base contracts currently exist for developing SNX and MasterChef-based strategies.
|
86
|
+
|
87
|
+
Note that the Universal Liquidator will not be available on BSC until a later stage of this project.
|
88
|
+
|
89
|
+
## Contribute
|
90
|
+
|
91
|
+
When ready, open a pull request with the following information:
|
92
|
+
1. Instructions on how to run the test and at which block number
|
93
|
+
2. A **mainnet fork test output** (like the one above in the README) clearly showing the increases of share price
|
94
|
+
3. Info about the protocol, including:
|
95
|
+
- Live farm page(s)
|
96
|
+
- GitHub link(s)
|
97
|
+
- Etherscan link(s)
|
98
|
+
- Start/end dates for rewards
|
99
|
+
- Any limitations (e.g., maximum pool size)
|
100
|
+
- Current pool sizes used for liquidation (to make sure they are not too shallow)
|
101
|
+
|
102
|
+
The first few items can be omitted for well-known protocols (such as `curve.fi`).
|
103
|
+
|
104
|
+
5. A description of **potential value** for Harvest: why should your strategy be live? High APYs, decent pool sizes, longevity of rewards, well-secured protocols, high-potential collaborations, etc.
|
105
|
+
|
106
|
+
A more extensive checklist for assessing protocols and farming opportunities can be found [here](https://www.notion.so/harvestfinance/Farm-ops-check-list-7cd2e0d9da364252ac465cb8a176f0e0)
|
107
|
+
|
108
|
+
## Deployment
|
109
|
+
|
110
|
+
If your pull request is merged and given a green light for deployment, the Harvest team will take care of on-chain deployment.
|
@@ -0,0 +1,125 @@
|
|
1
|
+
// SPDX-License-Identifier: Unlicense
|
2
|
+
|
3
|
+
pragma solidity 0.6.12;
|
4
|
+
|
5
|
+
|
6
|
+
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
|
7
|
+
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";
|
8
|
+
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
|
9
|
+
|
10
|
+
import "./interface/IController.sol";
|
11
|
+
import "./interface/IStrategy.sol";
|
12
|
+
import "./interface/IVault.sol";
|
13
|
+
import "./FeeRewardForwarder.sol";
|
14
|
+
import "./inheritance/Governable.sol";
|
15
|
+
|
16
|
+
contract Controller is IController, Governable {
|
17
|
+
|
18
|
+
using SafeERC20Upgradeable for IERC20Upgradeable;
|
19
|
+
using Address for address;
|
20
|
+
using SafeMath for uint256;
|
21
|
+
|
22
|
+
// external parties
|
23
|
+
address public override feeRewardForwarder;
|
24
|
+
|
25
|
+
// [Grey list]
|
26
|
+
// An EOA can safely interact with the system no matter what.
|
27
|
+
// If you're using Metamask, you're using an EOA.
|
28
|
+
// Only smart contracts may be affected by this grey list.
|
29
|
+
//
|
30
|
+
// This contract will not be able to ban any EOA from the system
|
31
|
+
// even if an EOA is being added to the greyList, he/she will still be able
|
32
|
+
// to interact with the whole system as if nothing happened.
|
33
|
+
// Only smart contracts will be affected by being added to the greyList.
|
34
|
+
mapping (address => bool) public override greyList;
|
35
|
+
|
36
|
+
uint256 public constant override profitSharingNumerator = 5;
|
37
|
+
uint256 public constant override profitSharingDenominator = 100;
|
38
|
+
|
39
|
+
event SharePriceChangeLog(
|
40
|
+
address indexed vault,
|
41
|
+
address indexed strategy,
|
42
|
+
uint256 oldSharePrice,
|
43
|
+
uint256 newSharePrice,
|
44
|
+
uint256 timestamp
|
45
|
+
);
|
46
|
+
|
47
|
+
mapping (address => bool) public hardWorkers;
|
48
|
+
|
49
|
+
modifier onlyHardWorkerOrGovernance() {
|
50
|
+
require(hardWorkers[msg.sender] || (msg.sender == governance()),
|
51
|
+
"only hard worker can call this");
|
52
|
+
_;
|
53
|
+
}
|
54
|
+
|
55
|
+
constructor(address _storage, address _feeRewardForwarder)
|
56
|
+
Governable(_storage) public {
|
57
|
+
require(_feeRewardForwarder != address(0), "feeRewardForwarder should not be empty");
|
58
|
+
feeRewardForwarder = _feeRewardForwarder;
|
59
|
+
}
|
60
|
+
|
61
|
+
function addHardWorker(address _worker) public onlyGovernance {
|
62
|
+
require(_worker != address(0), "_worker must be defined");
|
63
|
+
hardWorkers[_worker] = true;
|
64
|
+
}
|
65
|
+
|
66
|
+
function removeHardWorker(address _worker) public onlyGovernance {
|
67
|
+
require(_worker != address(0), "_worker must be defined");
|
68
|
+
hardWorkers[_worker] = false;
|
69
|
+
}
|
70
|
+
|
71
|
+
// Only smart contracts will be affected by the greyList.
|
72
|
+
function addToGreyList(address _target) public onlyGovernance {
|
73
|
+
greyList[_target] = true;
|
74
|
+
}
|
75
|
+
|
76
|
+
function removeFromGreyList(address _target) public onlyGovernance {
|
77
|
+
greyList[_target] = false;
|
78
|
+
}
|
79
|
+
|
80
|
+
function setFeeRewardForwarder(address _feeRewardForwarder) public override onlyGovernance {
|
81
|
+
require(_feeRewardForwarder != address(0), "new reward forwarder should not be empty");
|
82
|
+
feeRewardForwarder = _feeRewardForwarder;
|
83
|
+
}
|
84
|
+
|
85
|
+
function addVaultAndStrategy(address _vault, address _strategy) external override onlyGovernance {
|
86
|
+
require(_vault != address(0), "new vault shouldn't be empty");
|
87
|
+
require(_strategy != address(0), "new strategy shouldn't be empty");
|
88
|
+
|
89
|
+
// adding happens while setting
|
90
|
+
IVault(_vault).setStrategy(_strategy);
|
91
|
+
}
|
92
|
+
|
93
|
+
function doHardWork(address _vault) external override onlyHardWorkerOrGovernance {
|
94
|
+
uint256 oldSharePrice = IVault(_vault).getPricePerFullShare();
|
95
|
+
IVault(_vault).doHardWork();
|
96
|
+
emit SharePriceChangeLog(
|
97
|
+
_vault,
|
98
|
+
IVault(_vault).strategy(),
|
99
|
+
oldSharePrice,
|
100
|
+
IVault(_vault).getPricePerFullShare(),
|
101
|
+
block.timestamp
|
102
|
+
);
|
103
|
+
}
|
104
|
+
|
105
|
+
// transfers token in the controller contract to the governance
|
106
|
+
function salvage(address _token, uint256 _amount) external override onlyGovernance {
|
107
|
+
IERC20Upgradeable(_token).safeTransfer(governance(), _amount);
|
108
|
+
}
|
109
|
+
|
110
|
+
function salvageStrategy(address _strategy, address _token, uint256 _amount) external override onlyGovernance {
|
111
|
+
// the strategy is responsible for maintaining the list of
|
112
|
+
// salvagable tokens, to make sure that governance cannot come
|
113
|
+
// in and take away the coins
|
114
|
+
IStrategy(_strategy).salvage(governance(), _token, _amount);
|
115
|
+
}
|
116
|
+
|
117
|
+
function notifyFee(address underlying, uint256 fee) external override {
|
118
|
+
if (fee > 0) {
|
119
|
+
IERC20Upgradeable(underlying).safeTransferFrom(msg.sender, address(this), fee);
|
120
|
+
IERC20Upgradeable(underlying).safeApprove(feeRewardForwarder, 0);
|
121
|
+
IERC20Upgradeable(underlying).safeApprove(feeRewardForwarder, fee);
|
122
|
+
FeeRewardForwarder(feeRewardForwarder).poolNotifyFixedTarget(underlying, fee);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
@@ -0,0 +1,363 @@
|
|
1
|
+
// SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "@openzeppelin/contracts/utils/Address.sol";
|
5
|
+
import "@openzeppelin/contracts/math/SafeMath.sol";
|
6
|
+
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
7
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
8
|
+
|
9
|
+
import "./inheritance/Governable.sol";
|
10
|
+
|
11
|
+
import "./interface/IStrategy.sol";
|
12
|
+
import "./interface/IVault.sol";
|
13
|
+
|
14
|
+
import "./RewardForwarderV2.sol";
|
15
|
+
|
16
|
+
|
17
|
+
contract ControllerV2 is Governable {
|
18
|
+
using SafeERC20 for IERC20;
|
19
|
+
using Address for address;
|
20
|
+
using SafeMath for uint256;
|
21
|
+
|
22
|
+
// ========================= Fields =========================
|
23
|
+
|
24
|
+
// external parties
|
25
|
+
address public targetToken;
|
26
|
+
address public protocolFeeReceiver;
|
27
|
+
address public profitSharingReceiver;
|
28
|
+
address public rewardForwarder;
|
29
|
+
address public universalLiquidator;
|
30
|
+
|
31
|
+
uint256 public nextImplementationDelay;
|
32
|
+
|
33
|
+
/// 15% of fees captured go to iFARM stakers
|
34
|
+
uint256 public profitSharingNumerator = 500;
|
35
|
+
uint256 public nextProfitSharingNumerator = 0;
|
36
|
+
uint256 public nextProfitSharingNumeratorTimestamp = 0;
|
37
|
+
|
38
|
+
/// 5% of fees captured go to strategists
|
39
|
+
uint256 public strategistFeeNumerator = 0;
|
40
|
+
uint256 public nextStrategistFeeNumerator = 0;
|
41
|
+
uint256 public nextStrategistFeeNumeratorTimestamp = 0;
|
42
|
+
|
43
|
+
/// 5% of fees captured go to the devs of the platform
|
44
|
+
uint256 public platformFeeNumerator = 300;
|
45
|
+
uint256 public nextPlatformFeeNumerator = 0;
|
46
|
+
uint256 public nextPlatformFeeNumeratorTimestamp = 0;
|
47
|
+
|
48
|
+
/// used for queuing a new delay
|
49
|
+
uint256 public tempNextImplementationDelay = 0;
|
50
|
+
uint256 public tempNextImplementationDelayTimestamp = 0;
|
51
|
+
|
52
|
+
uint256 public constant MAX_TOTAL_FEE = 3000;
|
53
|
+
uint256 public constant FEE_DENOMINATOR = 10000;
|
54
|
+
|
55
|
+
/// @notice This mapping allows certain contracts to stake on a user's behalf
|
56
|
+
mapping (address => bool) public addressWhitelist;
|
57
|
+
mapping (bytes32 => bool) public codeWhitelist;
|
58
|
+
|
59
|
+
// All eligible hardWorkers that we have
|
60
|
+
mapping (address => bool) public hardWorkers;
|
61
|
+
|
62
|
+
// ========================= Events =========================
|
63
|
+
|
64
|
+
event QueueProfitSharingChange(uint profitSharingNumerator, uint validAtTimestamp);
|
65
|
+
event ConfirmProfitSharingChange(uint profitSharingNumerator);
|
66
|
+
|
67
|
+
event QueueStrategistFeeChange(uint strategistFeeNumerator, uint validAtTimestamp);
|
68
|
+
event ConfirmStrategistFeeChange(uint strategistFeeNumerator);
|
69
|
+
|
70
|
+
event QueuePlatformFeeChange(uint platformFeeNumerator, uint validAtTimestamp);
|
71
|
+
event ConfirmPlatformFeeChange(uint platformFeeNumerator);
|
72
|
+
|
73
|
+
event QueueNextImplementationDelay(uint implementationDelay, uint validAtTimestamp);
|
74
|
+
event ConfirmNextImplementationDelay(uint implementationDelay);
|
75
|
+
|
76
|
+
event AddedAddressToWhitelist(address indexed _address);
|
77
|
+
event RemovedAddressFromWhitelist(address indexed _address);
|
78
|
+
|
79
|
+
event AddedCodeToWhitelist(address indexed _address);
|
80
|
+
event RemovedCodeFromWhitelist(address indexed _address);
|
81
|
+
|
82
|
+
event SharePriceChangeLog(
|
83
|
+
address indexed vault,
|
84
|
+
address indexed strategy,
|
85
|
+
uint256 oldSharePrice,
|
86
|
+
uint256 newSharePrice,
|
87
|
+
uint256 timestamp
|
88
|
+
);
|
89
|
+
|
90
|
+
// ========================= Modifiers =========================
|
91
|
+
|
92
|
+
modifier onlyHardWorkerOrGovernance() {
|
93
|
+
require(hardWorkers[msg.sender] || (msg.sender == governance()),
|
94
|
+
"only hard worker can call this");
|
95
|
+
_;
|
96
|
+
}
|
97
|
+
|
98
|
+
constructor(
|
99
|
+
address _storage,
|
100
|
+
address _targetToken,
|
101
|
+
address _protocolFeeReceiver,
|
102
|
+
address _profitSharingReceiver,
|
103
|
+
address _rewardForwarder,
|
104
|
+
address _universalLiquidator,
|
105
|
+
uint _nextImplementationDelay
|
106
|
+
)
|
107
|
+
Governable(_storage)
|
108
|
+
public {
|
109
|
+
require(_targetToken != address(0), "_targetToken should not be empty");
|
110
|
+
require(_protocolFeeReceiver != address(0), "_protocolFeeReceiver should not be empty");
|
111
|
+
require(_profitSharingReceiver != address(0), "_profitSharingReceiver should not be empty");
|
112
|
+
require(_rewardForwarder != address(0), "_rewardForwarder should not be empty");
|
113
|
+
require(_nextImplementationDelay > 0, "_nextImplementationDelay should be gt 0");
|
114
|
+
|
115
|
+
targetToken = _targetToken;
|
116
|
+
protocolFeeReceiver = _protocolFeeReceiver;
|
117
|
+
profitSharingReceiver = _profitSharingReceiver;
|
118
|
+
rewardForwarder = _rewardForwarder;
|
119
|
+
universalLiquidator = _universalLiquidator;
|
120
|
+
nextImplementationDelay = _nextImplementationDelay;
|
121
|
+
}
|
122
|
+
|
123
|
+
// [Grey list]
|
124
|
+
// An EOA can safely interact with the system no matter what.
|
125
|
+
// If you're using Metamask, you're using an EOA.
|
126
|
+
// Only smart contracts may be affected by this grey list.
|
127
|
+
//
|
128
|
+
// This contract will not be able to ban any EOA from the system
|
129
|
+
// even if an EOA is being added to the greyList, he/she will still be able
|
130
|
+
// to interact with the whole system as if nothing happened.
|
131
|
+
// Only smart contracts will be affected by being added to the greyList.
|
132
|
+
function greyList(address _addr) public view returns (bool) {
|
133
|
+
return !addressWhitelist[_addr] && !codeWhitelist[getContractHash(_addr)];
|
134
|
+
}
|
135
|
+
|
136
|
+
// Only smart contracts will be affected by the whitelist.
|
137
|
+
function addToWhitelist(address _target) public onlyGovernance {
|
138
|
+
addressWhitelist[_target] = true;
|
139
|
+
emit AddedAddressToWhitelist(_target);
|
140
|
+
}
|
141
|
+
|
142
|
+
function addMultipleToWhitelist(address[] memory _targets) public onlyGovernance {
|
143
|
+
for (uint256 i = 0; i < _targets.length; i++) {
|
144
|
+
addressWhitelist[_targets[i]] = true;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
function removeFromWhitelist(address _target) public onlyGovernance {
|
149
|
+
addressWhitelist[_target] = false;
|
150
|
+
emit RemovedAddressFromWhitelist(_target);
|
151
|
+
}
|
152
|
+
|
153
|
+
function removeMultipleFromWhitelist(address[] memory _targets) public onlyGovernance {
|
154
|
+
for (uint256 i = 0; i < _targets.length; i++) {
|
155
|
+
addressWhitelist[_targets[i]] = false;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
function getContractHash(address a) public view returns (bytes32 hash) {
|
160
|
+
assembly {
|
161
|
+
hash := extcodehash(a)
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
function addCodeToWhitelist(address _target) public onlyGovernance {
|
166
|
+
codeWhitelist[getContractHash(_target)] = true;
|
167
|
+
emit AddedCodeToWhitelist(_target);
|
168
|
+
}
|
169
|
+
|
170
|
+
function removeCodeFromWhitelist(address _target) public onlyGovernance {
|
171
|
+
codeWhitelist[getContractHash(_target)] = false;
|
172
|
+
emit RemovedCodeFromWhitelist(_target);
|
173
|
+
}
|
174
|
+
|
175
|
+
function setRewardForwarder(address _rewardForwarder) public onlyGovernance {
|
176
|
+
require(_rewardForwarder != address(0), "new reward forwarder should not be empty");
|
177
|
+
rewardForwarder = _rewardForwarder;
|
178
|
+
}
|
179
|
+
|
180
|
+
function setTargetToken(address _targetToken) public onlyGovernance {
|
181
|
+
require(_targetToken != address(0), "new target token should not be empty");
|
182
|
+
targetToken = _targetToken;
|
183
|
+
}
|
184
|
+
|
185
|
+
function setProfitSharingReceiver(address _profitSharingReceiver) public onlyGovernance {
|
186
|
+
require(_profitSharingReceiver != address(0), "new profit sharing receiver should not be empty");
|
187
|
+
profitSharingReceiver = _profitSharingReceiver;
|
188
|
+
}
|
189
|
+
|
190
|
+
function setProtocolFeeReceiver(address _protocolFeeReceiver) public onlyGovernance {
|
191
|
+
require(_protocolFeeReceiver != address(0), "new protocol fee receiver should not be empty");
|
192
|
+
protocolFeeReceiver = _protocolFeeReceiver;
|
193
|
+
}
|
194
|
+
|
195
|
+
function setUniversalLiquidator(address _universalLiquidator) public onlyGovernance {
|
196
|
+
require(_universalLiquidator != address(0), "new universal liquidator should not be empty");
|
197
|
+
universalLiquidator = _universalLiquidator;
|
198
|
+
}
|
199
|
+
|
200
|
+
function getPricePerFullShare(address _vault) public view returns (uint256) {
|
201
|
+
return IVault(_vault).getPricePerFullShare();
|
202
|
+
}
|
203
|
+
|
204
|
+
function doHardWork(address _vault) external onlyHardWorkerOrGovernance {
|
205
|
+
uint256 oldSharePrice = IVault(_vault).getPricePerFullShare();
|
206
|
+
IVault(_vault).doHardWork();
|
207
|
+
emit SharePriceChangeLog(
|
208
|
+
_vault,
|
209
|
+
IVault(_vault).strategy(),
|
210
|
+
oldSharePrice,
|
211
|
+
IVault(_vault).getPricePerFullShare(),
|
212
|
+
block.timestamp
|
213
|
+
);
|
214
|
+
}
|
215
|
+
|
216
|
+
function notifyFee(address _token, uint256 _feeAmount) external {
|
217
|
+
IERC20(_token).safeTransferFrom(msg.sender, address(this), _feeAmount);
|
218
|
+
uint256 totalFee = profitSharingNumerator.add(strategistFeeNumerator).add(platformFeeNumerator);
|
219
|
+
uint256 profitShareAmount = _feeAmount.mul(profitSharingNumerator).div(totalFee);
|
220
|
+
uint256 strategistAmount = _feeAmount.mul(strategistFeeNumerator).div(totalFee);
|
221
|
+
uint256 platformAmount = _feeAmount.mul(platformFeeNumerator).div(totalFee);
|
222
|
+
|
223
|
+
IERC20(_token).safeApprove(rewardForwarder, 0);
|
224
|
+
IERC20(_token).safeApprove(rewardForwarder, _feeAmount);
|
225
|
+
RewardForwarderV2(rewardForwarder).notifyFee(_token, profitShareAmount, strategistAmount, platformAmount);
|
226
|
+
}
|
227
|
+
|
228
|
+
function addHardWorker(address _worker) public onlyGovernance {
|
229
|
+
require(_worker != address(0), "_worker must be defined");
|
230
|
+
hardWorkers[_worker] = true;
|
231
|
+
}
|
232
|
+
|
233
|
+
function removeHardWorker(address _worker) public onlyGovernance {
|
234
|
+
require(_worker != address(0), "_worker must be defined");
|
235
|
+
hardWorkers[_worker] = false;
|
236
|
+
}
|
237
|
+
|
238
|
+
// transfers token in the controller contract to the governance
|
239
|
+
function salvage(address _token, uint256 _amount) external onlyGovernance {
|
240
|
+
IERC20(_token).safeTransfer(governance(), _amount);
|
241
|
+
}
|
242
|
+
|
243
|
+
function salvageStrategy(address _strategy, address _token, uint256 _amount) external onlyGovernance {
|
244
|
+
// the strategy is responsible for maintaining the list of
|
245
|
+
// salvageable tokens, to make sure that governance cannot come
|
246
|
+
// in and take away the coins
|
247
|
+
IStrategy(_strategy).salvageToken(governance(), _token, _amount);
|
248
|
+
}
|
249
|
+
|
250
|
+
function feeDenominator() public pure returns (uint) {
|
251
|
+
// keep the interface for this function as a `view` for now, in case it changes in the future
|
252
|
+
return FEE_DENOMINATOR;
|
253
|
+
}
|
254
|
+
|
255
|
+
function setProfitSharingNumerator(uint _profitSharingNumerator) public onlyGovernance {
|
256
|
+
require(
|
257
|
+
_profitSharingNumerator + strategistFeeNumerator + platformFeeNumerator <= MAX_TOTAL_FEE,
|
258
|
+
"total fee too high"
|
259
|
+
);
|
260
|
+
|
261
|
+
nextProfitSharingNumerator = _profitSharingNumerator;
|
262
|
+
nextProfitSharingNumeratorTimestamp = block.timestamp + nextImplementationDelay;
|
263
|
+
emit QueueProfitSharingChange(nextProfitSharingNumerator, nextProfitSharingNumeratorTimestamp);
|
264
|
+
}
|
265
|
+
|
266
|
+
function confirmSetProfitSharingNumerator() public onlyGovernance {
|
267
|
+
require(
|
268
|
+
nextProfitSharingNumerator != 0
|
269
|
+
&& nextProfitSharingNumeratorTimestamp != 0
|
270
|
+
&& block.timestamp >= nextProfitSharingNumeratorTimestamp,
|
271
|
+
"invalid timestamp or no new profit sharing numerator confirmed"
|
272
|
+
);
|
273
|
+
require(
|
274
|
+
nextProfitSharingNumerator + strategistFeeNumerator + platformFeeNumerator <= MAX_TOTAL_FEE,
|
275
|
+
"total fee too high"
|
276
|
+
);
|
277
|
+
|
278
|
+
profitSharingNumerator = nextProfitSharingNumerator;
|
279
|
+
nextProfitSharingNumerator = 0;
|
280
|
+
nextProfitSharingNumeratorTimestamp = 0;
|
281
|
+
emit ConfirmProfitSharingChange(profitSharingNumerator);
|
282
|
+
}
|
283
|
+
|
284
|
+
function setStrategistFeeNumerator(uint _strategistFeeNumerator) public onlyGovernance {
|
285
|
+
require(
|
286
|
+
_strategistFeeNumerator + platformFeeNumerator + profitSharingNumerator <= MAX_TOTAL_FEE,
|
287
|
+
"total fee too high"
|
288
|
+
);
|
289
|
+
|
290
|
+
nextStrategistFeeNumerator = _strategistFeeNumerator;
|
291
|
+
nextStrategistFeeNumeratorTimestamp = block.timestamp + nextImplementationDelay;
|
292
|
+
emit QueueStrategistFeeChange(nextStrategistFeeNumerator, nextStrategistFeeNumeratorTimestamp);
|
293
|
+
}
|
294
|
+
|
295
|
+
function confirmSetStrategistFeeNumerator() public onlyGovernance {
|
296
|
+
require(
|
297
|
+
nextStrategistFeeNumerator != 0
|
298
|
+
&& nextStrategistFeeNumeratorTimestamp != 0
|
299
|
+
&& block.timestamp >= nextStrategistFeeNumeratorTimestamp,
|
300
|
+
"invalid timestamp or no new strategist fee numerator confirmed"
|
301
|
+
);
|
302
|
+
require(
|
303
|
+
nextStrategistFeeNumerator + platformFeeNumerator + profitSharingNumerator <= MAX_TOTAL_FEE,
|
304
|
+
"total fee too high"
|
305
|
+
);
|
306
|
+
|
307
|
+
strategistFeeNumerator = nextStrategistFeeNumerator;
|
308
|
+
nextStrategistFeeNumerator = 0;
|
309
|
+
nextStrategistFeeNumeratorTimestamp = 0;
|
310
|
+
emit ConfirmStrategistFeeChange(strategistFeeNumerator);
|
311
|
+
}
|
312
|
+
|
313
|
+
function setPlatformFeeNumerator(uint _platformFeeNumerator) public onlyGovernance {
|
314
|
+
require(
|
315
|
+
_platformFeeNumerator + strategistFeeNumerator + profitSharingNumerator <= MAX_TOTAL_FEE,
|
316
|
+
"total fee too high"
|
317
|
+
);
|
318
|
+
|
319
|
+
nextPlatformFeeNumerator = _platformFeeNumerator;
|
320
|
+
nextPlatformFeeNumeratorTimestamp = block.timestamp + nextImplementationDelay;
|
321
|
+
emit QueuePlatformFeeChange(nextPlatformFeeNumerator, nextPlatformFeeNumeratorTimestamp);
|
322
|
+
}
|
323
|
+
|
324
|
+
function confirmSetPlatformFeeNumerator() public onlyGovernance {
|
325
|
+
require(
|
326
|
+
nextPlatformFeeNumerator != 0
|
327
|
+
&& nextPlatformFeeNumeratorTimestamp != 0
|
328
|
+
&& block.timestamp >= nextPlatformFeeNumeratorTimestamp,
|
329
|
+
"invalid timestamp or no new platform fee numerator confirmed"
|
330
|
+
);
|
331
|
+
require(
|
332
|
+
nextPlatformFeeNumerator + strategistFeeNumerator + profitSharingNumerator <= MAX_TOTAL_FEE,
|
333
|
+
"total fee too high"
|
334
|
+
);
|
335
|
+
|
336
|
+
platformFeeNumerator = nextPlatformFeeNumerator;
|
337
|
+
nextPlatformFeeNumerator = 0;
|
338
|
+
nextPlatformFeeNumeratorTimestamp = 0;
|
339
|
+
emit ConfirmPlatformFeeChange(platformFeeNumerator);
|
340
|
+
}
|
341
|
+
|
342
|
+
function setNextImplementationDelay(uint256 _nextImplementationDelay) public onlyGovernance {
|
343
|
+
require(
|
344
|
+
_nextImplementationDelay > 0,
|
345
|
+
"invalid _nextImplementationDelay"
|
346
|
+
);
|
347
|
+
|
348
|
+
tempNextImplementationDelay = _nextImplementationDelay;
|
349
|
+
tempNextImplementationDelayTimestamp = block.timestamp + nextImplementationDelay;
|
350
|
+
emit QueueNextImplementationDelay(tempNextImplementationDelay, tempNextImplementationDelayTimestamp);
|
351
|
+
}
|
352
|
+
|
353
|
+
function confirmNextImplementationDelay() public onlyGovernance {
|
354
|
+
require(
|
355
|
+
tempNextImplementationDelayTimestamp != 0 && block.timestamp >= tempNextImplementationDelayTimestamp,
|
356
|
+
"invalid timestamp or no new implementation delay confirmed"
|
357
|
+
);
|
358
|
+
nextImplementationDelay = tempNextImplementationDelay;
|
359
|
+
tempNextImplementationDelay = 0;
|
360
|
+
tempNextImplementationDelayTimestamp = 0;
|
361
|
+
emit ConfirmNextImplementationDelay(nextImplementationDelay);
|
362
|
+
}
|
363
|
+
}
|