@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
@@ -0,0 +1,364 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
|
3
|
+
pragma solidity 0.6.12;
|
4
|
+
|
5
|
+
import "@openzeppelin/contracts/math/Math.sol";
|
6
|
+
import "@openzeppelin/contracts/math/SafeMath.sol";
|
7
|
+
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
8
|
+
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
|
9
|
+
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
|
10
|
+
import "../interface/IVault.sol";
|
11
|
+
import "../upgradability/BaseUpgradeableStrategy.sol";
|
12
|
+
import "./interfaces/IMasterChef.sol";
|
13
|
+
import "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";
|
14
|
+
|
15
|
+
|
16
|
+
contract MasterChefStrategy is BaseUpgradeableStrategy {
|
17
|
+
|
18
|
+
using SafeMath for uint256;
|
19
|
+
using SafeERC20 for IERC20;
|
20
|
+
|
21
|
+
address public constant quickswapRouterV2 = address(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
|
22
|
+
address public constant sushiswapRouterV2 = address(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);
|
23
|
+
|
24
|
+
// additional storage slots (on top of BaseUpgradeableStrategy ones) are defined here
|
25
|
+
bytes32 internal constant _POOLID_SLOT = 0x3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b;
|
26
|
+
bytes32 internal constant _USE_QUICK_SLOT = 0x189f8e6d384b6a451390d61330a1995a733994439125cd881a1bdac25fe65ea2;
|
27
|
+
bytes32 internal constant _IS_LP_ASSET_SLOT = 0xc2f3dabf55b1bdda20d5cf5fcba9ba765dfc7c9dbaf28674ce46d43d60d58768;
|
28
|
+
|
29
|
+
// this would be reset on each upgrade
|
30
|
+
mapping (address => address[]) public swapRoutes;
|
31
|
+
|
32
|
+
constructor() public BaseUpgradeableStrategy() {
|
33
|
+
assert(_POOLID_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.poolId")) - 1));
|
34
|
+
assert(_USE_QUICK_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.useQuick")) - 1));
|
35
|
+
assert(_IS_LP_ASSET_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.isLpAsset")) - 1));
|
36
|
+
}
|
37
|
+
|
38
|
+
function initializeStrategy(
|
39
|
+
address _storage,
|
40
|
+
address _underlying,
|
41
|
+
address _vault,
|
42
|
+
address _rewardPool,
|
43
|
+
address _rewardToken,
|
44
|
+
uint256 _poolID,
|
45
|
+
bool _isLpAsset,
|
46
|
+
bool _useQuick
|
47
|
+
) public initializer {
|
48
|
+
|
49
|
+
BaseUpgradeableStrategy.initialize(
|
50
|
+
_storage,
|
51
|
+
_underlying,
|
52
|
+
_vault,
|
53
|
+
_rewardPool,
|
54
|
+
_rewardToken,
|
55
|
+
80, // profit sharing numerator
|
56
|
+
1000, // profit sharing denominator
|
57
|
+
true, // sell
|
58
|
+
1e18, // sell floor
|
59
|
+
12 hours // implementation change delay
|
60
|
+
);
|
61
|
+
|
62
|
+
address _lpt;
|
63
|
+
(_lpt,,,) = IMasterChef(rewardPool()).poolInfo(_poolID);
|
64
|
+
require(_lpt == underlying(), "Pool Info does not match underlying");
|
65
|
+
_setPoolId(_poolID);
|
66
|
+
|
67
|
+
if (_isLpAsset) {
|
68
|
+
address LPComponentToken0 = IUniswapV2Pair(underlying()).token0();
|
69
|
+
address LPComponentToken1 = IUniswapV2Pair(underlying()).token1();
|
70
|
+
|
71
|
+
// these would be required to be initialized separately by governance
|
72
|
+
swapRoutes[LPComponentToken0] = new address[](0);
|
73
|
+
swapRoutes[LPComponentToken1] = new address[](0);
|
74
|
+
} else {
|
75
|
+
swapRoutes[underlying()] = new address[](0);
|
76
|
+
}
|
77
|
+
|
78
|
+
setBoolean(_USE_QUICK_SLOT, _useQuick);
|
79
|
+
setBoolean(_IS_LP_ASSET_SLOT, _isLpAsset);
|
80
|
+
}
|
81
|
+
|
82
|
+
function depositArbCheck() public pure returns(bool) {
|
83
|
+
return true;
|
84
|
+
}
|
85
|
+
|
86
|
+
function rewardPoolBalance() internal view returns (uint256 bal) {
|
87
|
+
(bal,) = IMasterChef(rewardPool()).userInfo(poolId(), address(this));
|
88
|
+
}
|
89
|
+
|
90
|
+
function exitRewardPool() internal {
|
91
|
+
uint256 bal = rewardPoolBalance();
|
92
|
+
if (bal != 0) {
|
93
|
+
IMasterChef(rewardPool()).withdraw(poolId(), bal);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
function emergencyExitRewardPool() internal {
|
98
|
+
uint256 bal = rewardPoolBalance();
|
99
|
+
if (bal != 0) {
|
100
|
+
IMasterChef(rewardPool()).emergencyWithdraw(poolId());
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
function unsalvagableTokens(address token) public view returns (bool) {
|
105
|
+
return (token == rewardToken() || token == underlying());
|
106
|
+
}
|
107
|
+
|
108
|
+
function enterRewardPool() internal {
|
109
|
+
uint256 entireBalance = IERC20(underlying()).balanceOf(address(this));
|
110
|
+
IERC20(underlying()).safeApprove(rewardPool(), 0);
|
111
|
+
IERC20(underlying()).safeApprove(rewardPool(), entireBalance);
|
112
|
+
IMasterChef(rewardPool()).deposit(poolId(), entireBalance);
|
113
|
+
}
|
114
|
+
|
115
|
+
/*
|
116
|
+
* In case there are some issues discovered about the pool or underlying asset
|
117
|
+
* Governance can exit the pool properly
|
118
|
+
* The function is only used for emergency to exit the pool
|
119
|
+
*/
|
120
|
+
function emergencyExit() public onlyGovernance {
|
121
|
+
emergencyExitRewardPool();
|
122
|
+
_setPausedInvesting(true);
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* Resumes the ability to invest into the underlying reward pools
|
127
|
+
*/
|
128
|
+
|
129
|
+
function continueInvesting() public onlyGovernance {
|
130
|
+
_setPausedInvesting(false);
|
131
|
+
}
|
132
|
+
|
133
|
+
function setLiquidationPath(address _token, address [] memory _route) public onlyGovernance {
|
134
|
+
swapRoutes[_token] = _route;
|
135
|
+
}
|
136
|
+
|
137
|
+
// We assume that all the tradings can be done on Uniswap
|
138
|
+
function _liquidateReward() internal {
|
139
|
+
uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this));
|
140
|
+
if (!sell() || rewardBalance < sellFloor()) {
|
141
|
+
// Profits can be disabled for possible simplified and rapid exit
|
142
|
+
emit ProfitsNotCollected(sell(), rewardBalance < sellFloor());
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
notifyProfitInRewardToken(rewardBalance);
|
147
|
+
uint256 remainingRewardBalance = IERC20(rewardToken()).balanceOf(address(this));
|
148
|
+
|
149
|
+
if (remainingRewardBalance == 0) {
|
150
|
+
return;
|
151
|
+
}
|
152
|
+
|
153
|
+
address routerV2;
|
154
|
+
if(useQuick()) {
|
155
|
+
routerV2 = quickswapRouterV2;
|
156
|
+
} else {
|
157
|
+
routerV2 = sushiswapRouterV2;
|
158
|
+
}
|
159
|
+
|
160
|
+
// allow Uniswap to sell our reward
|
161
|
+
IERC20(rewardToken()).safeApprove(routerV2, 0);
|
162
|
+
IERC20(rewardToken()).safeApprove(routerV2, remainingRewardBalance);
|
163
|
+
|
164
|
+
// we can accept 1 as minimum because this is called only by a trusted role
|
165
|
+
uint256 amountOutMin = 1;
|
166
|
+
|
167
|
+
if (isLpAsset()) {
|
168
|
+
address LPComponentToken0 = IUniswapV2Pair(underlying()).token0();
|
169
|
+
address LPComponentToken1 = IUniswapV2Pair(underlying()).token1();
|
170
|
+
|
171
|
+
uint256 toToken0 = remainingRewardBalance.div(2);
|
172
|
+
uint256 toToken1 = remainingRewardBalance.sub(toToken0);
|
173
|
+
|
174
|
+
uint256 token0Amount;
|
175
|
+
|
176
|
+
if (swapRoutes[LPComponentToken0].length > 1) {
|
177
|
+
// if we need to liquidate the token0
|
178
|
+
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
|
179
|
+
toToken0,
|
180
|
+
amountOutMin,
|
181
|
+
swapRoutes[LPComponentToken0],
|
182
|
+
address(this),
|
183
|
+
block.timestamp
|
184
|
+
);
|
185
|
+
token0Amount = IERC20(LPComponentToken0).balanceOf(address(this));
|
186
|
+
} else {
|
187
|
+
// otherwise we assme token0 is the reward token itself
|
188
|
+
token0Amount = toToken0;
|
189
|
+
}
|
190
|
+
|
191
|
+
uint256 token1Amount;
|
192
|
+
|
193
|
+
if (swapRoutes[LPComponentToken1].length > 1) {
|
194
|
+
// sell reward token to token1
|
195
|
+
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
|
196
|
+
toToken1,
|
197
|
+
amountOutMin,
|
198
|
+
swapRoutes[LPComponentToken1],
|
199
|
+
address(this),
|
200
|
+
block.timestamp
|
201
|
+
);
|
202
|
+
token1Amount = IERC20(LPComponentToken1).balanceOf(address(this));
|
203
|
+
} else {
|
204
|
+
token1Amount = toToken1;
|
205
|
+
}
|
206
|
+
|
207
|
+
// provide token1 and token2 to SUSHI
|
208
|
+
IERC20(LPComponentToken0).safeApprove(routerV2, 0);
|
209
|
+
IERC20(LPComponentToken0).safeApprove(routerV2, token0Amount);
|
210
|
+
|
211
|
+
IERC20(LPComponentToken1).safeApprove(routerV2, 0);
|
212
|
+
IERC20(LPComponentToken1).safeApprove(routerV2, token1Amount);
|
213
|
+
|
214
|
+
// we provide liquidity to sushi
|
215
|
+
uint256 liquidity;
|
216
|
+
(,,liquidity) = IUniswapV2Router02(routerV2).addLiquidity(
|
217
|
+
LPComponentToken0,
|
218
|
+
LPComponentToken1,
|
219
|
+
token0Amount,
|
220
|
+
token1Amount,
|
221
|
+
1, // we are willing to take whatever the pair gives us
|
222
|
+
1, // we are willing to take whatever the pair gives us
|
223
|
+
address(this),
|
224
|
+
block.timestamp
|
225
|
+
);
|
226
|
+
} else {
|
227
|
+
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
|
228
|
+
remainingRewardBalance,
|
229
|
+
amountOutMin,
|
230
|
+
swapRoutes[underlying()],
|
231
|
+
address(this),
|
232
|
+
block.timestamp
|
233
|
+
);
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
/*
|
238
|
+
* Stakes everything the strategy holds into the reward pool
|
239
|
+
*/
|
240
|
+
function investAllUnderlying() internal onlyNotPausedInvesting {
|
241
|
+
// this check is needed, because most of the SNX reward pools will revert if
|
242
|
+
// you try to stake(0).
|
243
|
+
if(IERC20(underlying()).balanceOf(address(this)) > 0) {
|
244
|
+
enterRewardPool();
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
/*
|
249
|
+
* Withdraws all the asset to the vault
|
250
|
+
*/
|
251
|
+
function withdrawAllToVault() public restricted {
|
252
|
+
if (address(rewardPool()) != address(0)) {
|
253
|
+
exitRewardPool();
|
254
|
+
}
|
255
|
+
_liquidateReward();
|
256
|
+
IERC20(underlying()).safeTransfer(vault(), IERC20(underlying()).balanceOf(address(this)));
|
257
|
+
}
|
258
|
+
|
259
|
+
/*
|
260
|
+
* Withdraws all the asset to the vault
|
261
|
+
*/
|
262
|
+
function withdrawToVault(uint256 amount) public restricted {
|
263
|
+
// Typically there wouldn't be any amount here
|
264
|
+
// however, it is possible because of the emergencyExit
|
265
|
+
uint256 entireBalance = IERC20(underlying()).balanceOf(address(this));
|
266
|
+
|
267
|
+
if(amount > entireBalance){
|
268
|
+
// While we have the check above, we still using SafeMath below
|
269
|
+
// for the peace of mind (in case something gets changed in between)
|
270
|
+
uint256 needToWithdraw = amount.sub(entireBalance);
|
271
|
+
uint256 toWithdraw = Math.min(rewardPoolBalance(), needToWithdraw);
|
272
|
+
IMasterChef(rewardPool()).withdraw(poolId(), toWithdraw);
|
273
|
+
}
|
274
|
+
|
275
|
+
IERC20(underlying()).safeTransfer(vault(), amount);
|
276
|
+
}
|
277
|
+
|
278
|
+
/*
|
279
|
+
* Note that we currently do not have a mechanism here to include the
|
280
|
+
* amount of reward that is accrued.
|
281
|
+
*/
|
282
|
+
function investedUnderlyingBalance() external view returns (uint256) {
|
283
|
+
if (rewardPool() == address(0)) {
|
284
|
+
return IERC20(underlying()).balanceOf(address(this));
|
285
|
+
}
|
286
|
+
// Adding the amount locked in the reward pool and the amount that is somehow in this contract
|
287
|
+
// both are in the units of "underlying"
|
288
|
+
// The second part is needed because there is the emergency exit mechanism
|
289
|
+
// which would break the assumption that all the funds are always inside of the reward pool
|
290
|
+
return rewardPoolBalance().add(IERC20(underlying()).balanceOf(address(this)));
|
291
|
+
}
|
292
|
+
|
293
|
+
/*
|
294
|
+
* Governance or Controller can claim coins that are somehow transferred into the contract
|
295
|
+
* Note that they cannot come in take away coins that are used and defined in the strategy itself
|
296
|
+
*/
|
297
|
+
function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance {
|
298
|
+
// To make sure that governance cannot come in and take away the coins
|
299
|
+
require(!unsalvagableTokens(token), "token is defined as not salvagable");
|
300
|
+
IERC20(token).safeTransfer(recipient, amount);
|
301
|
+
}
|
302
|
+
|
303
|
+
/*
|
304
|
+
* Get the reward, sell it in exchange for underlying, invest what you got.
|
305
|
+
* It's not much, but it's honest work.
|
306
|
+
*
|
307
|
+
* Note that although `onlyNotPausedInvesting` is not added here,
|
308
|
+
* calling `investAllUnderlying()` affectively blocks the usage of `doHardWork`
|
309
|
+
* when the investing is being paused by governance.
|
310
|
+
*/
|
311
|
+
function doHardWork() external onlyNotPausedInvesting restricted {
|
312
|
+
exitRewardPool();
|
313
|
+
_liquidateReward();
|
314
|
+
investAllUnderlying();
|
315
|
+
}
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Can completely disable claiming rewards and selling. Good for emergency withdraw in the
|
319
|
+
* simplest possible way.
|
320
|
+
*/
|
321
|
+
function setSell(bool s) public onlyGovernance {
|
322
|
+
_setSell(s);
|
323
|
+
}
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Sets the minimum amount of CRV needed to trigger a sale.
|
327
|
+
*/
|
328
|
+
function setSellFloor(uint256 floor) public onlyGovernance {
|
329
|
+
_setSellFloor(floor);
|
330
|
+
}
|
331
|
+
|
332
|
+
// masterchef rewards pool ID
|
333
|
+
function _setPoolId(uint256 _value) internal {
|
334
|
+
setUint256(_POOLID_SLOT, _value);
|
335
|
+
}
|
336
|
+
|
337
|
+
function poolId() public view returns (uint256) {
|
338
|
+
return getUint256(_POOLID_SLOT);
|
339
|
+
}
|
340
|
+
|
341
|
+
function setUseQuick(bool _value) public onlyGovernance {
|
342
|
+
setBoolean(_USE_QUICK_SLOT, _value);
|
343
|
+
}
|
344
|
+
|
345
|
+
function useQuick() public view returns (bool) {
|
346
|
+
return getBoolean(_USE_QUICK_SLOT);
|
347
|
+
}
|
348
|
+
|
349
|
+
function isLpAsset() public view returns (bool) {
|
350
|
+
return getBoolean(_IS_LP_ASSET_SLOT);
|
351
|
+
}
|
352
|
+
|
353
|
+
function finalizeUpgrade() external onlyGovernance {
|
354
|
+
_finalizeUpgrade();
|
355
|
+
// reset the liquidation paths
|
356
|
+
// they need to be re-set manually
|
357
|
+
if (isLpAsset()) {
|
358
|
+
swapRoutes[IUniswapV2Pair(underlying()).token0()] = new address[](0);
|
359
|
+
swapRoutes[IUniswapV2Pair(underlying()).token1()] = new address[](0);
|
360
|
+
} else {
|
361
|
+
swapRoutes[underlying()] = new address[](0);
|
362
|
+
}
|
363
|
+
}
|
364
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
|
3
|
+
pragma solidity 0.6.12;
|
4
|
+
|
5
|
+
interface IMasterChef {
|
6
|
+
function deposit(uint256 _pid, uint256 _amount) external;
|
7
|
+
function withdraw(uint256 _pid, uint256 _amount) external;
|
8
|
+
function emergencyWithdraw(uint256 _pid) external;
|
9
|
+
function userInfo(uint256 _pid, address _user) external view returns (uint256 amount, uint256 rewardDebt);
|
10
|
+
function poolInfo(uint256 _pid) external view returns (address lpToken, uint256, uint256, uint256);
|
11
|
+
function massUpdatePools() external;
|
12
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "../Vault.sol";
|
5
|
+
import "../interface/curve/ICurveDeposit_2token.sol";
|
6
|
+
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
7
|
+
|
8
|
+
interface IJPYCSwap {
|
9
|
+
function swap() external;
|
10
|
+
}
|
11
|
+
|
12
|
+
contract VaultMigratable_2JPYv2 is Vault {
|
13
|
+
using SafeERC20 for IERC20;
|
14
|
+
|
15
|
+
address public constant __jjpy = address(0x8343091F2499FD4b6174A46D067A920a3b851FF9);
|
16
|
+
address public constant __jpyc = address(0x6AE7Dfc73E0dDE2aa99ac063DcF7e8A63265108c);
|
17
|
+
address public constant __jpycv2 = address(0x431D5dfF03120AFA4bDf332c61A6e1766eF37BDB);
|
18
|
+
address public constant __2jpy = address(0xE8dCeA7Fb2Baf7a9F4d9af608F06d78a687F8d9A);
|
19
|
+
address public constant __2jpyv2 = address(0xaA91CDD7abb47F821Cf07a2d38Cc8668DEAf1bdc);
|
20
|
+
address public constant __2jpyv2_strategy = address(0x45257F1c56bE3D381f49371b47c3EEb1E8358431);
|
21
|
+
address public constant __governance = address(0xf00dD244228F51547f0563e60bCa65a30FBF5f7f);
|
22
|
+
|
23
|
+
address public constant __jpyc_swap = address(0x382d78E8BcEa98fA04b63C19Fe97D8138C3bfC5D);
|
24
|
+
|
25
|
+
event Migrated(uint256 v1Liquidity, uint256 v2Liquidity);
|
26
|
+
event LiquidityRemoved(uint256 v1Liquidity, uint256 amountJJPY, uint256 amountJPYC);
|
27
|
+
event LiquidityProvided(uint256 JPYCv2Contributed, uint256 JJPYContributed, uint256 v2Liquidity);
|
28
|
+
|
29
|
+
constructor() public {
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Migrates the vault from the 2JPY underlying to 2JPYv2 underlying
|
34
|
+
*/
|
35
|
+
function migrateUnderlying(
|
36
|
+
uint256 minJJPYOut, uint256 minJPYCOut,
|
37
|
+
uint256 min2JPYv2Mint
|
38
|
+
) public onlyControllerOrGovernance {
|
39
|
+
require(underlying() == __2jpy, "Can only migrate if the underlying is 2JPY");
|
40
|
+
withdrawAll();
|
41
|
+
|
42
|
+
uint256 v1Liquidity = IERC20(__2jpy).balanceOf(address(this));
|
43
|
+
|
44
|
+
ICurveDeposit_2token(__2jpy).remove_liquidity(v1Liquidity, [minJJPYOut, minJPYCOut]);
|
45
|
+
uint256 amountJJPY = IERC20(__jjpy).balanceOf(address(this));
|
46
|
+
uint256 amountJPYC = IERC20(__jpyc).balanceOf(address(this));
|
47
|
+
|
48
|
+
emit LiquidityRemoved(v1Liquidity, amountJJPY, amountJPYC);
|
49
|
+
|
50
|
+
require(IERC20(__2jpy).balanceOf(address(this)) == 0, "Not all underlying was converted");
|
51
|
+
|
52
|
+
IERC20(__jpyc).safeApprove(__jpyc_swap, 0);
|
53
|
+
IERC20(__jpyc).safeApprove(__jpyc_swap, uint256(-1));
|
54
|
+
IJPYCSwap(__jpyc_swap).swap();
|
55
|
+
uint256 jpycv2Balance = IERC20(__jpycv2).balanceOf(address(this));
|
56
|
+
|
57
|
+
IERC20(__jpycv2).safeApprove(__2jpyv2, 0);
|
58
|
+
IERC20(__jpycv2).safeApprove(__2jpyv2, jpycv2Balance);
|
59
|
+
IERC20(__jjpy).safeApprove(__2jpyv2, 0);
|
60
|
+
IERC20(__jjpy).safeApprove(__2jpyv2, amountJJPY);
|
61
|
+
|
62
|
+
ICurveDeposit_2token(__2jpyv2).add_liquidity([amountJJPY, jpycv2Balance], min2JPYv2Mint);
|
63
|
+
uint256 v2Liquidity = IERC20(__2jpyv2).balanceOf(address(this));
|
64
|
+
|
65
|
+
emit LiquidityProvided(jpycv2Balance, amountJJPY, v2Liquidity);
|
66
|
+
|
67
|
+
_setUnderlying(__2jpyv2);
|
68
|
+
require(underlying() == __2jpyv2, "underlying switch failed");
|
69
|
+
_setStrategy(__2jpyv2_strategy);
|
70
|
+
require(strategy() == __2jpyv2_strategy, "strategy switch failed");
|
71
|
+
|
72
|
+
// some steps that regular setStrategy does
|
73
|
+
IERC20(underlying()).safeApprove(address(strategy()), 0);
|
74
|
+
IERC20(underlying()).safeApprove(address(strategy()), uint256(~0));
|
75
|
+
|
76
|
+
uint256 jjpyLeft = IERC20(__jjpy).balanceOf(address(this));
|
77
|
+
if (jjpyLeft > 0) {
|
78
|
+
IERC20(__jjpy).transfer(__governance, jjpyLeft);
|
79
|
+
}
|
80
|
+
uint256 jpycv2Left = IERC20(__jpycv2).balanceOf(address(this));
|
81
|
+
if (jpycv2Left > 0) {
|
82
|
+
IERC20(__jpycv2).transfer(strategy(), jpycv2Left);
|
83
|
+
}
|
84
|
+
|
85
|
+
emit Migrated(v1Liquidity, v2Liquidity);
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
pragma experimental ABIEncoderV2;
|
4
|
+
|
5
|
+
import "../Vault.sol";
|
6
|
+
import "../interface/curve/ICurveDeposit_2token.sol";
|
7
|
+
import "../../strategies/balancer/interface/IBVault.sol";
|
8
|
+
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
9
|
+
|
10
|
+
import "hardhat/console.sol";
|
11
|
+
|
12
|
+
contract VaultMigratable_bal2EUR_PAR is Vault {
|
13
|
+
using SafeERC20 for IERC20;
|
14
|
+
|
15
|
+
address public constant __token0 = address(0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c);
|
16
|
+
address public constant __token1 = address(0xE2Aa7db6dA1dAE97C5f5C6914d285fBfCC32A128);
|
17
|
+
address public constant __lpOld = address(0x0f110c55EfE62c16D553A3d3464B77e1853d0e97);
|
18
|
+
address public constant __lpNew = address(0x7d60a4Cb5cA92E2Da965637025122296ea6854f9);
|
19
|
+
address public constant __governance = address(0xf00dD244228F51547f0563e60bCa65a30FBF5f7f);
|
20
|
+
address public constant __bVault = address(0xBA12222222228d8Ba445958a75a0704d566BF2C8);
|
21
|
+
address public constant __newStrategy = address(0x222E14Dc2f82d1d903e539C39B0C578B7353be7E);
|
22
|
+
|
23
|
+
bytes32 public constant __poolIdNew = 0x7d60a4cb5ca92e2da965637025122296ea6854f900000000000000000000085e;
|
24
|
+
|
25
|
+
event Migrated(uint256 v1Liquidity, uint256 v2Liquidity);
|
26
|
+
event LiquidityRemoved(uint256 v1Liquidity, uint256 amountToken0, uint256 amountToken1);
|
27
|
+
event LiquidityProvided(uint256 amountToken0, uint256 amountToken1, uint256 v2Liquidity);
|
28
|
+
|
29
|
+
constructor() public {
|
30
|
+
}
|
31
|
+
|
32
|
+
function _approveIfNeed(address token, address spender, uint256 amount) internal {
|
33
|
+
uint256 allowance = IERC20(token).allowance(address(this), spender);
|
34
|
+
if (amount > allowance) {
|
35
|
+
IERC20(token).safeApprove(spender, 0);
|
36
|
+
IERC20(token).safeApprove(spender, amount);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
function _balancerSwap(
|
41
|
+
address sellToken,
|
42
|
+
address buyToken,
|
43
|
+
bytes32 poolId,
|
44
|
+
uint256 amountIn,
|
45
|
+
uint256 minAmountOut
|
46
|
+
) internal {
|
47
|
+
IBVault.SingleSwap memory singleSwap;
|
48
|
+
IBVault.SwapKind swapKind = IBVault.SwapKind.GIVEN_IN;
|
49
|
+
|
50
|
+
singleSwap.poolId = poolId;
|
51
|
+
singleSwap.kind = swapKind;
|
52
|
+
singleSwap.assetIn = IAsset(sellToken);
|
53
|
+
singleSwap.assetOut = IAsset(buyToken);
|
54
|
+
singleSwap.amount = amountIn;
|
55
|
+
singleSwap.userData = abi.encode(0);
|
56
|
+
|
57
|
+
IBVault.FundManagement memory funds;
|
58
|
+
funds.sender = address(this);
|
59
|
+
funds.fromInternalBalance = false;
|
60
|
+
funds.recipient = payable(address(this));
|
61
|
+
funds.toInternalBalance = false;
|
62
|
+
|
63
|
+
_approveIfNeed(sellToken, __bVault, amountIn);
|
64
|
+
IBVault(__bVault).swap(singleSwap, funds, minAmountOut, block.timestamp);
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Migrates the vault from the old Curve LP underlying to new Balancer LP underlying
|
69
|
+
*/
|
70
|
+
function migrateUnderlying(
|
71
|
+
uint256 minToken0Out,
|
72
|
+
uint256 minToken1Out,
|
73
|
+
uint256 minLPNewOut
|
74
|
+
) public onlyControllerOrGovernance {
|
75
|
+
require(underlying() == __lpOld, "Can only migrate if the underlying is lpOld");
|
76
|
+
withdrawAll();
|
77
|
+
|
78
|
+
uint256 v1Liquidity = IERC20(__lpOld).balanceOf(address(this));
|
79
|
+
console.log("V1Liquidity: ", v1Liquidity);
|
80
|
+
|
81
|
+
ICurveDeposit_2token(__lpOld).remove_liquidity(v1Liquidity, [minToken0Out, minToken1Out]);
|
82
|
+
uint256 amount0 = IERC20(__token0).balanceOf(address(this));
|
83
|
+
uint256 amount1 = IERC20(__token1).balanceOf(address(this));
|
84
|
+
console.log("token0 out: ", amount0);
|
85
|
+
console.log("token1 out: ", amount1);
|
86
|
+
|
87
|
+
emit LiquidityRemoved(v1Liquidity, amount0, amount1);
|
88
|
+
|
89
|
+
require(IERC20(__lpOld).balanceOf(address(this)) == 0, "Not all underlying was converted");
|
90
|
+
|
91
|
+
_balancerSwap(__token0, __lpNew, __poolIdNew, amount0, 1);
|
92
|
+
_balancerSwap(__token1, __lpNew, __poolIdNew, amount1, 1);
|
93
|
+
uint256 v2Liquidity = IERC20(__lpNew).balanceOf(address(this));
|
94
|
+
require(v2Liquidity >= minLPNewOut, "Output amount too low");
|
95
|
+
console.log("V2Liquidity: ", v2Liquidity);
|
96
|
+
|
97
|
+
emit LiquidityProvided(amount0, amount1, v2Liquidity);
|
98
|
+
|
99
|
+
_setUnderlying(__lpNew);
|
100
|
+
require(underlying() == __lpNew, "underlying switch failed");
|
101
|
+
console.log("New underlying: ", underlying());
|
102
|
+
_setStrategy(__newStrategy);
|
103
|
+
require(strategy() == __newStrategy, "strategy switch failed");
|
104
|
+
console.log("New strategy: ", strategy());
|
105
|
+
|
106
|
+
// some steps that regular setStrategy does
|
107
|
+
IERC20(underlying()).safeApprove(address(strategy()), 0);
|
108
|
+
IERC20(underlying()).safeApprove(address(strategy()), uint256(~0));
|
109
|
+
|
110
|
+
uint256 token0Left = IERC20(__token0).balanceOf(address(this));
|
111
|
+
if (token0Left > 0) {
|
112
|
+
IERC20(__token0).transfer(strategy(), token0Left);
|
113
|
+
}
|
114
|
+
uint256 token1Left = IERC20(__token1).balanceOf(address(this));
|
115
|
+
if (token1Left > 0) {
|
116
|
+
IERC20(__token1).transfer(__governance, token1Left);
|
117
|
+
}
|
118
|
+
|
119
|
+
emit Migrated(v1Liquidity, v2Liquidity);
|
120
|
+
}
|
121
|
+
}
|