@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,272 @@
|
|
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 "../../base/upgradability/BaseUpgradeableStrategyV2.sol";
|
9
|
+
import "../../base/interface/IUniversalLiquidator.sol";
|
10
|
+
import "../../base/interface/gamma/IHypervisor.sol";
|
11
|
+
import "../../base/interface/gamma/IUniProxy.sol";
|
12
|
+
import "../../base/interface/quickswap/IDragonLair.sol";
|
13
|
+
import "../../base/interface/gamma/IClearing.sol";
|
14
|
+
|
15
|
+
contract GammaMerklStrategy is BaseUpgradeableStrategyV2 {
|
16
|
+
|
17
|
+
using SafeMath for uint256;
|
18
|
+
using SafeERC20 for IERC20;
|
19
|
+
|
20
|
+
address public constant dQuick = address(0x958d208Cdf087843e9AD98d23823d32E17d723A1);
|
21
|
+
address public constant quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
22
|
+
address public constant harvestMSIG = address(0x39cC360806b385C96969ce9ff26c23476017F652);
|
23
|
+
|
24
|
+
// additional storage slots (on top of BaseUpgradeableStrategy ones) are defined here
|
25
|
+
bytes32 internal constant _UNIPROXY_SLOT = 0x09ff9720152edb4fad4ed05a0b77258f0fce17715f9397342eb08c8d7f965234;
|
26
|
+
|
27
|
+
// this would be reset on each upgrade
|
28
|
+
address[] public rewardTokens;
|
29
|
+
|
30
|
+
constructor() public BaseUpgradeableStrategyV2() {
|
31
|
+
assert(_UNIPROXY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.uniProxy")) - 1));
|
32
|
+
}
|
33
|
+
|
34
|
+
function initializeBaseStrategy(
|
35
|
+
address _storage,
|
36
|
+
address _underlying,
|
37
|
+
address _vault,
|
38
|
+
address _rewardToken,
|
39
|
+
address _uniProxy
|
40
|
+
) public initializer {
|
41
|
+
|
42
|
+
BaseUpgradeableStrategyV2.initialize(
|
43
|
+
_storage,
|
44
|
+
_underlying,
|
45
|
+
_vault,
|
46
|
+
address(0),
|
47
|
+
_rewardToken,
|
48
|
+
harvestMSIG
|
49
|
+
);
|
50
|
+
|
51
|
+
setAddress(_UNIPROXY_SLOT, _uniProxy);
|
52
|
+
}
|
53
|
+
|
54
|
+
function depositArbCheck() public pure returns(bool) {
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
|
58
|
+
function unsalvagableTokens(address token) public view returns (bool) {
|
59
|
+
return (token == rewardToken() || token == underlying());
|
60
|
+
}
|
61
|
+
|
62
|
+
/*
|
63
|
+
* In case there are some issues discovered about the pool or underlying asset
|
64
|
+
* Governance can exit the pool properly
|
65
|
+
* The function is only used for emergency to exit the pool
|
66
|
+
*/
|
67
|
+
function emergencyExit() public onlyGovernance {
|
68
|
+
_setPausedInvesting(true);
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
* Resumes the ability to invest into the underlying reward pools
|
73
|
+
*/
|
74
|
+
function continueInvesting() public onlyGovernance {
|
75
|
+
_setPausedInvesting(false);
|
76
|
+
}
|
77
|
+
|
78
|
+
function addRewardToken(address _token) public onlyGovernance {
|
79
|
+
rewardTokens.push(_token);
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* if the pool gets dQuick as reward token it has to first be converted to QUICK
|
84
|
+
* by leaving the dragonLair
|
85
|
+
*/
|
86
|
+
function convertDQuickToQuick() internal {
|
87
|
+
uint256 dQuickBalance = IERC20(dQuick).balanceOf(address(this));
|
88
|
+
if (dQuickBalance > 0){
|
89
|
+
IDragonLair(dQuick).leave(dQuickBalance);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
// We assume that all the tradings can be done on Uniswap
|
94
|
+
function _liquidateReward() internal {
|
95
|
+
if (!sell()) {
|
96
|
+
// Profits can be disabled for possible simplified and rapid exit
|
97
|
+
emit ProfitsNotCollected(sell(), false);
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
|
101
|
+
address _rewardToken = rewardToken();
|
102
|
+
address _universalLiquidator = universalLiquidator();
|
103
|
+
for(uint256 i = 0; i < rewardTokens.length; i++){
|
104
|
+
address token = rewardTokens[i];
|
105
|
+
if (token == quick){
|
106
|
+
convertDQuickToQuick();
|
107
|
+
}
|
108
|
+
uint256 rewardBalance = IERC20(token).balanceOf(address(this));
|
109
|
+
if (rewardBalance == 0) {
|
110
|
+
continue;
|
111
|
+
}
|
112
|
+
if (token != _rewardToken){
|
113
|
+
IERC20(token).safeApprove(_universalLiquidator, 0);
|
114
|
+
IERC20(token).safeApprove(_universalLiquidator, rewardBalance);
|
115
|
+
IUniversalLiquidator(_universalLiquidator).swap(token, _rewardToken, rewardBalance, 1, address(this));
|
116
|
+
}
|
117
|
+
}
|
118
|
+
uint256 rewardBalance = IERC20(_rewardToken).balanceOf(address(this));
|
119
|
+
_notifyProfitInRewardToken(_rewardToken, rewardBalance);
|
120
|
+
uint256 remainingRewardBalance = IERC20(_rewardToken).balanceOf(address(this));
|
121
|
+
|
122
|
+
if (remainingRewardBalance < 1e15) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
|
126
|
+
_depositToGamma();
|
127
|
+
}
|
128
|
+
|
129
|
+
function _depositToGamma() internal {
|
130
|
+
address _underlying = underlying();
|
131
|
+
address _clearing = IUniProxy(uniProxy()).clearance();
|
132
|
+
address _token0 = IHypervisor(_underlying).token0();
|
133
|
+
address _token1 = IHypervisor(_underlying).token1();
|
134
|
+
(uint256 toToken0, uint256 toToken1) = _calculateToTokenAmounts();
|
135
|
+
(uint256 amount0, uint256 amount1) = _swapToTokens(_token0, _token1, toToken0, toToken1);
|
136
|
+
(uint256 min1, uint256 max1) = IClearing(_clearing).getDepositAmount(_underlying, _token0, amount0);
|
137
|
+
if (amount1 < min1) {
|
138
|
+
(,uint256 max0) = IClearing(_clearing).getDepositAmount(_underlying, _token1, amount1);
|
139
|
+
if (amount0 > max0) {
|
140
|
+
amount0 = max0;
|
141
|
+
}
|
142
|
+
} else if (amount1 > max1) {
|
143
|
+
amount1 = max1;
|
144
|
+
}
|
145
|
+
uint256[4] memory minIn = [uint(0), uint(0), uint(0), uint(0)];
|
146
|
+
|
147
|
+
IERC20(_token0).safeApprove(_underlying, 0);
|
148
|
+
IERC20(_token0).safeApprove(_underlying, amount0);
|
149
|
+
IERC20(_token1).safeApprove(_underlying, 0);
|
150
|
+
IERC20(_token1).safeApprove(_underlying, amount1);
|
151
|
+
IUniProxy(uniProxy()).deposit(amount0, amount1, address(this), _underlying, minIn);
|
152
|
+
}
|
153
|
+
|
154
|
+
function _calculateToTokenAmounts() internal view returns(uint256, uint256){
|
155
|
+
address pool = underlying();
|
156
|
+
(uint256 poolBalance0, uint256 poolBalance1) = IHypervisor(pool).getTotalAmounts();
|
157
|
+
address clearing = IUniProxy(uniProxy()).clearance();
|
158
|
+
uint256 sqrtPrice0In1 = uint256(IClearing(clearing).getSqrtTwapX96(pool, 1));
|
159
|
+
uint256 price0In1 = sqrtPrice0In1.mul(sqrtPrice0In1).div(uint(2**(96 * 2)).div(1e18));
|
160
|
+
uint256 totalPoolBalanceIn1 = poolBalance0.mul(price0In1).div(1e18).add(poolBalance1);
|
161
|
+
uint256 poolWeight0 = poolBalance0.mul(price0In1).div(totalPoolBalanceIn1);
|
162
|
+
|
163
|
+
uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this));
|
164
|
+
uint256 toToken0 = rewardBalance.mul(poolWeight0).div(1e18);
|
165
|
+
uint256 toToken1 = rewardBalance.sub(toToken0);
|
166
|
+
return (toToken0, toToken1);
|
167
|
+
}
|
168
|
+
|
169
|
+
function _swapToTokens(
|
170
|
+
address tokenOut0,
|
171
|
+
address tokenOut1,
|
172
|
+
uint256 toToken0,
|
173
|
+
uint256 toToken1
|
174
|
+
) internal returns(uint256, uint256){
|
175
|
+
address tokenIn = rewardToken();
|
176
|
+
address _universalLiquidator = universalLiquidator();
|
177
|
+
uint256 token0Amount;
|
178
|
+
if (tokenIn != tokenOut0){
|
179
|
+
IERC20(tokenIn).safeApprove(_universalLiquidator, 0);
|
180
|
+
IERC20(tokenIn).safeApprove(_universalLiquidator, toToken0);
|
181
|
+
IUniversalLiquidator(_universalLiquidator).swap(tokenIn, tokenOut0, toToken0, 1, address(this));
|
182
|
+
token0Amount = IERC20(tokenOut0).balanceOf(address(this));
|
183
|
+
} else {
|
184
|
+
// otherwise we assme token0 is the reward token itself
|
185
|
+
token0Amount = toToken0;
|
186
|
+
}
|
187
|
+
|
188
|
+
uint256 token1Amount;
|
189
|
+
if (tokenIn != tokenOut1){
|
190
|
+
IERC20(tokenIn).safeApprove(_universalLiquidator, 0);
|
191
|
+
IERC20(tokenIn).safeApprove(_universalLiquidator, toToken1);
|
192
|
+
IUniversalLiquidator(_universalLiquidator).swap(tokenIn, tokenOut1, toToken1, 1, address(this));
|
193
|
+
token1Amount = IERC20(tokenOut1).balanceOf(address(this));
|
194
|
+
} else {
|
195
|
+
// otherwise we assme token0 is the reward token itself
|
196
|
+
token1Amount = toToken1;
|
197
|
+
}
|
198
|
+
return (token0Amount, token1Amount);
|
199
|
+
}
|
200
|
+
|
201
|
+
/*
|
202
|
+
* Withdraws all the asset to the vault
|
203
|
+
*/
|
204
|
+
function withdrawAllToVault() public restricted {
|
205
|
+
address _underlying = underlying();
|
206
|
+
_liquidateReward();
|
207
|
+
IERC20(_underlying).safeTransfer(vault(), IERC20(_underlying).balanceOf(address(this)));
|
208
|
+
}
|
209
|
+
|
210
|
+
/*
|
211
|
+
* Withdraws all the asset to the vault
|
212
|
+
*/
|
213
|
+
function withdrawToVault(uint256 amount) public restricted {
|
214
|
+
// Typically there wouldn't be any amount here
|
215
|
+
// however, it is possible because of the emergencyExit
|
216
|
+
IERC20(underlying()).safeTransfer(vault(), amount);
|
217
|
+
}
|
218
|
+
|
219
|
+
/*
|
220
|
+
* Note that we currently do not have a mechanism here to include the
|
221
|
+
* amount of reward that is accrued.
|
222
|
+
*/
|
223
|
+
function investedUnderlyingBalance() external view returns (uint256) {
|
224
|
+
// Adding the amount locked in the reward pool and the amount that is somehow in this contract
|
225
|
+
// both are in the units of "underlying"
|
226
|
+
// The second part is needed because there is the emergency exit mechanism
|
227
|
+
// which would break the assumption that all the funds are always inside of the reward pool
|
228
|
+
return IERC20(underlying()).balanceOf(address(this));
|
229
|
+
}
|
230
|
+
|
231
|
+
/*
|
232
|
+
* Governance or Controller can claim coins that are somehow transferred into the contract
|
233
|
+
* Note that they cannot come in take away coins that are used and defined in the strategy itself
|
234
|
+
*/
|
235
|
+
function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance {
|
236
|
+
// To make sure that governance cannot come in and take away the coins
|
237
|
+
require(!unsalvagableTokens(token), "token is defined as not salvagable");
|
238
|
+
IERC20(token).safeTransfer(recipient, amount);
|
239
|
+
}
|
240
|
+
|
241
|
+
/*
|
242
|
+
* Get the reward, sell it in exchange for underlying, invest what you got.
|
243
|
+
* It's not much, but it's honest work.
|
244
|
+
*
|
245
|
+
* Note that although `onlyNotPausedInvesting` is not added here,
|
246
|
+
* calling `investAllUnderlying()` affectively blocks the usage of `doHardWork`
|
247
|
+
* when the investing is being paused by governance.
|
248
|
+
*/
|
249
|
+
function doHardWork() external onlyNotPausedInvesting restricted {
|
250
|
+
_liquidateReward();
|
251
|
+
}
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Can completely disable claiming rewards and selling. Good for emergency withdraw in the
|
255
|
+
* simplest possible way.
|
256
|
+
*/
|
257
|
+
function setSell(bool s) public onlyGovernance {
|
258
|
+
_setSell(s);
|
259
|
+
}
|
260
|
+
|
261
|
+
function _setUniProxy(address _value) public onlyGovernance {
|
262
|
+
setAddress(_UNIPROXY_SLOT, _value);
|
263
|
+
}
|
264
|
+
|
265
|
+
function uniProxy() public view returns (address) {
|
266
|
+
return getAddress(_UNIPROXY_SLOT);
|
267
|
+
}
|
268
|
+
|
269
|
+
function finalizeUpgrade() external onlyGovernance {
|
270
|
+
_finalizeUpgrade();
|
271
|
+
}
|
272
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "./GammaMerklStrategy.sol";
|
5
|
+
|
6
|
+
contract GammaMerklStrategyMainnet_QS_ETH_USDC is GammaMerklStrategy {
|
7
|
+
|
8
|
+
constructor() public {}
|
9
|
+
|
10
|
+
function initializeStrategy(
|
11
|
+
address _storage,
|
12
|
+
address _vault
|
13
|
+
) public initializer {
|
14
|
+
address underlying = address(0x3974FbDC22741A1632E024192111107b202F214f);
|
15
|
+
address quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
16
|
+
GammaMerklStrategy.initializeBaseStrategy(
|
17
|
+
_storage,
|
18
|
+
underlying,
|
19
|
+
_vault,
|
20
|
+
quick,
|
21
|
+
address(0xA42d55074869491D60Ac05490376B74cF19B00e6) //UniProxy
|
22
|
+
);
|
23
|
+
rewardTokens = [quick];
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "./GammaMerklStrategy.sol";
|
5
|
+
|
6
|
+
contract GammaMerklStrategyMainnet_QS_ETH_USDT is GammaMerklStrategy {
|
7
|
+
|
8
|
+
constructor() public {}
|
9
|
+
|
10
|
+
function initializeStrategy(
|
11
|
+
address _storage,
|
12
|
+
address _vault
|
13
|
+
) public initializer {
|
14
|
+
address underlying = address(0x5928f9f61902b139e1c40cBa59077516734ff09f);
|
15
|
+
address quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
16
|
+
GammaMerklStrategy.initializeBaseStrategy(
|
17
|
+
_storage,
|
18
|
+
underlying,
|
19
|
+
_vault,
|
20
|
+
quick,
|
21
|
+
address(0xA42d55074869491D60Ac05490376B74cF19B00e6) //UniProxy
|
22
|
+
);
|
23
|
+
rewardTokens = [quick];
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "./GammaMerklStrategy.sol";
|
5
|
+
|
6
|
+
contract GammaMerklStrategyMainnet_QS_MATIC_USDT is GammaMerklStrategy {
|
7
|
+
|
8
|
+
constructor() public {}
|
9
|
+
|
10
|
+
function initializeStrategy(
|
11
|
+
address _storage,
|
12
|
+
address _vault
|
13
|
+
) public initializer {
|
14
|
+
address underlying = address(0x598cA33b7F5FAB560ddC8E76D94A4b4AA52566d7);
|
15
|
+
address quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
16
|
+
GammaMerklStrategy.initializeBaseStrategy(
|
17
|
+
_storage,
|
18
|
+
underlying,
|
19
|
+
_vault,
|
20
|
+
quick,
|
21
|
+
address(0xA42d55074869491D60Ac05490376B74cF19B00e6) //UniProxy
|
22
|
+
);
|
23
|
+
rewardTokens = [quick];
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "./GammaMerklStrategy.sol";
|
5
|
+
|
6
|
+
contract GammaMerklStrategyMainnet_QS_TBTC_ETH is GammaMerklStrategy {
|
7
|
+
|
8
|
+
constructor() public {}
|
9
|
+
|
10
|
+
function initializeStrategy(
|
11
|
+
address _storage,
|
12
|
+
address _vault
|
13
|
+
) public initializer {
|
14
|
+
address underlying = address(0xadFC52D48d68B235B6b9453eF5130fc6dFD2513E);
|
15
|
+
address quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
16
|
+
GammaMerklStrategy.initializeBaseStrategy(
|
17
|
+
_storage,
|
18
|
+
underlying,
|
19
|
+
_vault,
|
20
|
+
quick,
|
21
|
+
address(0xA42d55074869491D60Ac05490376B74cF19B00e6) //UniProxy
|
22
|
+
);
|
23
|
+
rewardTokens = [quick];
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "./GammaMerklStrategy.sol";
|
5
|
+
|
6
|
+
contract GammaMerklStrategyMainnet_QS_WBTC_ETH_w is GammaMerklStrategy {
|
7
|
+
|
8
|
+
constructor() public {}
|
9
|
+
|
10
|
+
function initializeStrategy(
|
11
|
+
address _storage,
|
12
|
+
address _vault
|
13
|
+
) public initializer {
|
14
|
+
address underlying = address(0xadc7B4096C3059Ec578585Df36E6E1286d345367);
|
15
|
+
address quick = address(0xB5C064F955D8e7F38fE0460C556a72987494eE17);
|
16
|
+
GammaMerklStrategy.initializeBaseStrategy(
|
17
|
+
_storage,
|
18
|
+
underlying,
|
19
|
+
_vault,
|
20
|
+
quick,
|
21
|
+
address(0xA42d55074869491D60Ac05490376B74cF19B00e6) //UniProxy
|
22
|
+
);
|
23
|
+
rewardTokens = [quick];
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "../../base/noop/NoopStrategyUpgradeable.sol";
|
5
|
+
|
6
|
+
contract NoopStrategy_GENE_ETH is NoopStrategyUpgradeable {
|
7
|
+
|
8
|
+
address public gene_eth_unused; // just a differentiator for the bytecode
|
9
|
+
|
10
|
+
constructor() public {}
|
11
|
+
|
12
|
+
function initializeStrategy(
|
13
|
+
address _storage,
|
14
|
+
address _vault
|
15
|
+
) public initializer {
|
16
|
+
address underlying = address(0x3d4219987fBb25C3DcF73FbD9AA85FbE3C7411D9);
|
17
|
+
NoopStrategyUpgradeable.initializeBaseStrategy(
|
18
|
+
_storage,
|
19
|
+
underlying,
|
20
|
+
_vault
|
21
|
+
);
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "../../base/noop/NoopStrategyUpgradeable.sol";
|
5
|
+
|
6
|
+
contract NoopStrategy_GNOME_ETH is NoopStrategyUpgradeable {
|
7
|
+
|
8
|
+
address public gnome_eth_unused; // just a differentiator for the bytecode
|
9
|
+
|
10
|
+
constructor() public {}
|
11
|
+
|
12
|
+
function initializeStrategy(
|
13
|
+
address _storage,
|
14
|
+
address _vault
|
15
|
+
) public initializer {
|
16
|
+
address underlying = address(0xc1214b61965594b3e08Ea4950747d5A077Cd1886);
|
17
|
+
NoopStrategyUpgradeable.initializeBaseStrategy(
|
18
|
+
_storage,
|
19
|
+
underlying,
|
20
|
+
_vault
|
21
|
+
);
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,240 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.6.12;
|
3
|
+
|
4
|
+
import "@openzeppelin/contracts/math/Math.sol";
|
5
|
+
import "@openzeppelin/contracts/math/SafeMath.sol";
|
6
|
+
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
7
|
+
import "../../base/inheritance/RewardTokenProfitNotifier.sol";
|
8
|
+
import "../../base/interface/IStrategy.sol";
|
9
|
+
import "../../base/interface/IVault.sol";
|
10
|
+
import "../../base/interface/uniswap/IUniswapV2Router02.sol";
|
11
|
+
import "./interface/IdleToken.sol";
|
12
|
+
|
13
|
+
contract IdleFinanceStrategy is RewardTokenProfitNotifier {
|
14
|
+
|
15
|
+
using SafeMath for uint256;
|
16
|
+
using SafeERC20 for IERC20;
|
17
|
+
|
18
|
+
event ProfitsNotCollected(address);
|
19
|
+
event Liquidating(address, uint256);
|
20
|
+
|
21
|
+
address public referral;
|
22
|
+
IERC20 public underlying;
|
23
|
+
address public idleUnderlying;
|
24
|
+
uint256 public virtualPrice;
|
25
|
+
|
26
|
+
address public vault;
|
27
|
+
|
28
|
+
address[] public rewardTokens;
|
29
|
+
mapping(address => address[]) public reward2WETH;
|
30
|
+
address[] public WETH2underlying;
|
31
|
+
mapping(address => bool) public sell;
|
32
|
+
mapping(address => bool) public useQuick;
|
33
|
+
|
34
|
+
address public constant quickswapRouterV2 = address(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
|
35
|
+
address public constant sushiswapRouterV2 = address(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);
|
36
|
+
address public constant weth = address(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619);
|
37
|
+
|
38
|
+
bool public claimAllowed;
|
39
|
+
bool public protected;
|
40
|
+
|
41
|
+
// These tokens cannot be claimed by the controller
|
42
|
+
mapping (address => bool) public unsalvagableTokens;
|
43
|
+
|
44
|
+
modifier restricted() {
|
45
|
+
require(msg.sender == vault || msg.sender == address(controller()) || msg.sender == address(governance()),
|
46
|
+
"The sender has to be the controller or vault or governance");
|
47
|
+
_;
|
48
|
+
}
|
49
|
+
|
50
|
+
modifier updateVirtualPrice() {
|
51
|
+
if (protected) {
|
52
|
+
require(virtualPrice <= IIdleTokenV3_1(idleUnderlying).tokenPriceWithFee(address(this)), "virtual price is higher than needed");
|
53
|
+
}
|
54
|
+
_;
|
55
|
+
virtualPrice = IIdleTokenV3_1(idleUnderlying).tokenPriceWithFee(address(this));
|
56
|
+
}
|
57
|
+
|
58
|
+
constructor(
|
59
|
+
address _storage,
|
60
|
+
address _underlying,
|
61
|
+
address _idleUnderlying,
|
62
|
+
address _vault
|
63
|
+
) RewardTokenProfitNotifier(_storage, weth) public {
|
64
|
+
underlying = IERC20(_underlying);
|
65
|
+
idleUnderlying = _idleUnderlying;
|
66
|
+
vault = _vault;
|
67
|
+
protected = true;
|
68
|
+
|
69
|
+
// set these tokens to be not salvagable
|
70
|
+
unsalvagableTokens[_underlying] = true;
|
71
|
+
unsalvagableTokens[_idleUnderlying] = true;
|
72
|
+
for (uint256 i = 0; i < rewardTokens.length; i++) {
|
73
|
+
address token = rewardTokens[i];
|
74
|
+
unsalvagableTokens[token] = true;
|
75
|
+
}
|
76
|
+
referral = address(0xf00dD244228F51547f0563e60bCa65a30FBF5f7f);
|
77
|
+
claimAllowed = true;
|
78
|
+
|
79
|
+
virtualPrice = IIdleTokenV3_1(idleUnderlying).tokenPriceWithFee(address(this));
|
80
|
+
}
|
81
|
+
|
82
|
+
function depositArbCheck() public pure returns(bool) {
|
83
|
+
return true;
|
84
|
+
}
|
85
|
+
|
86
|
+
function setReferral(address _newRef) public onlyGovernance {
|
87
|
+
referral = _newRef;
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* The strategy invests by supplying the underlying token into IDLE.
|
92
|
+
*/
|
93
|
+
function investAllUnderlying() public restricted updateVirtualPrice {
|
94
|
+
uint256 balance = underlying.balanceOf(address(this));
|
95
|
+
underlying.safeApprove(address(idleUnderlying), 0);
|
96
|
+
underlying.safeApprove(address(idleUnderlying), balance);
|
97
|
+
IIdleTokenV3_1(idleUnderlying).mintIdleToken(balance, true, referral);
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Exits IDLE and transfers everything to the vault.
|
102
|
+
*/
|
103
|
+
function withdrawAllToVault() external restricted updateVirtualPrice {
|
104
|
+
withdrawAll();
|
105
|
+
IERC20(address(underlying)).safeTransfer(vault, underlying.balanceOf(address(this)));
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Withdraws all from IDLE
|
110
|
+
*/
|
111
|
+
function withdrawAll() internal {
|
112
|
+
uint256 balance = IERC20(idleUnderlying).balanceOf(address(this));
|
113
|
+
uint256 underlyingBalanceInvested = balance.mul(virtualPrice).div(1e18);
|
114
|
+
uint256 underlyingBalanceBefore = underlying.balanceOf(address(this));
|
115
|
+
// this automatically claims the crops
|
116
|
+
IIdleTokenV3_1(idleUnderlying).redeemIdleToken(balance);
|
117
|
+
uint256 underlyingBalanceAfter = underlying.balanceOf(address(this));
|
118
|
+
require(underlyingBalanceAfter >= (underlyingBalanceBefore + underlyingBalanceInvested), "withdrawal output too low");
|
119
|
+
|
120
|
+
liquidateRewards();
|
121
|
+
}
|
122
|
+
|
123
|
+
function withdrawToVault(uint256 amountUnderlying) public restricted {
|
124
|
+
// this method is called when the vault is missing funds
|
125
|
+
// we will calculate the proportion of idle LP tokens that matches
|
126
|
+
// the underlying amount requested
|
127
|
+
uint256 balanceBefore = underlying.balanceOf(address(this));
|
128
|
+
uint256 totalIdleLpTokens = IERC20(idleUnderlying).balanceOf(address(this));
|
129
|
+
uint256 totalUnderlyingBalance = totalIdleLpTokens.mul(virtualPrice).div(1e18);
|
130
|
+
uint256 ratio = amountUnderlying.mul(1e18).div(totalUnderlyingBalance);
|
131
|
+
uint256 toRedeem = totalIdleLpTokens.mul(ratio).div(1e18);
|
132
|
+
IIdleTokenV3_1(idleUnderlying).redeemIdleToken(toRedeem);
|
133
|
+
uint256 balanceAfter = underlying.balanceOf(address(this));
|
134
|
+
require(balanceAfter >= (balanceBefore + amountUnderlying), "withdrawal output too low");
|
135
|
+
underlying.safeTransfer(vault, balanceAfter.sub(balanceBefore));
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Withdraws all assets, liquidates COMP, and invests again in the required ratio.
|
140
|
+
*/
|
141
|
+
function doHardWork() public restricted updateVirtualPrice {
|
142
|
+
if (claimAllowed) {
|
143
|
+
claim();
|
144
|
+
}
|
145
|
+
liquidateRewards();
|
146
|
+
|
147
|
+
// this updates the virtual price
|
148
|
+
investAllUnderlying();
|
149
|
+
|
150
|
+
// state of supply/loan will be updated by the modifier
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Salvages a token.
|
155
|
+
*/
|
156
|
+
function salvage(address recipient, address token, uint256 amount) public onlyGovernance {
|
157
|
+
// To make sure that governance cannot come in and take away the coins
|
158
|
+
require(!unsalvagableTokens[token], "token is defined as not salvagable");
|
159
|
+
IERC20(token).safeTransfer(recipient, amount);
|
160
|
+
}
|
161
|
+
|
162
|
+
function claim() internal {
|
163
|
+
IIdleTokenV3_1(idleUnderlying).redeemIdleToken(0);
|
164
|
+
}
|
165
|
+
|
166
|
+
function liquidateRewards() internal {
|
167
|
+
uint256 wethBalanceBeforeClaim = IERC20(weth).balanceOf(address(this));
|
168
|
+
for (uint256 i=0;i<rewardTokens.length;i++) {
|
169
|
+
address token = rewardTokens[i];
|
170
|
+
if (!sell[token]) {
|
171
|
+
// Profits can be disabled for possible simplified and rapid exit
|
172
|
+
emit ProfitsNotCollected(token);
|
173
|
+
continue;
|
174
|
+
}
|
175
|
+
uint256 balance = IERC20(token).balanceOf(address(this));
|
176
|
+
if (balance > 0) {
|
177
|
+
emit Liquidating(token, balance);
|
178
|
+
address routerV2;
|
179
|
+
if(useQuick[token]) {
|
180
|
+
routerV2 = quickswapRouterV2;
|
181
|
+
} else {
|
182
|
+
routerV2 = sushiswapRouterV2;
|
183
|
+
}
|
184
|
+
IERC20(token).safeApprove(routerV2, 0);
|
185
|
+
IERC20(token).safeApprove(routerV2, balance);
|
186
|
+
// we can accept 1 as the minimum because this will be called only by a trusted worker
|
187
|
+
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
|
188
|
+
balance, 1, reward2WETH[token], address(this), block.timestamp
|
189
|
+
);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
uint256 wethBalanceAfterClaim = IERC20(weth).balanceOf(address(this));
|
194
|
+
notifyProfitInRewardToken(wethBalanceAfterClaim.sub(wethBalanceBeforeClaim));
|
195
|
+
|
196
|
+
uint256 remainingWethBalance = IERC20(weth).balanceOf(address(this));
|
197
|
+
|
198
|
+
if (remainingWethBalance > 0 && WETH2underlying.length > 1) {
|
199
|
+
emit Liquidating(weth, remainingWethBalance);
|
200
|
+
address routerV2;
|
201
|
+
if(useQuick[address(underlying)]) {
|
202
|
+
routerV2 = quickswapRouterV2;
|
203
|
+
} else {
|
204
|
+
routerV2 = sushiswapRouterV2;
|
205
|
+
}
|
206
|
+
IERC20(weth).safeApprove(routerV2, 0);
|
207
|
+
IERC20(weth).safeApprove(routerV2, remainingWethBalance);
|
208
|
+
// we can accept 1 as the minimum because this will be called only by a trusted worker
|
209
|
+
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
|
210
|
+
remainingWethBalance, 1, WETH2underlying, address(this), block.timestamp
|
211
|
+
);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Returns the current balance. Ignores COMP that was not liquidated and invested.
|
217
|
+
*/
|
218
|
+
function investedUnderlyingBalance() public view returns (uint256) {
|
219
|
+
// NOTE: The use of virtual price is okay for appreciating assets inside IDLE,
|
220
|
+
// but would be wrong and exploitable if funds were lost by IDLE, indicated by
|
221
|
+
// the virtualPrice being greater than the token price.
|
222
|
+
if (protected) {
|
223
|
+
require(virtualPrice <= IIdleTokenV3_1(idleUnderlying).tokenPriceWithFee(address(this)), "virtual price is higher than needed");
|
224
|
+
}
|
225
|
+
uint256 invested = IERC20(idleUnderlying).balanceOf(address(this)).mul(virtualPrice).div(1e18);
|
226
|
+
return invested.add(IERC20(underlying).balanceOf(address(this)));
|
227
|
+
}
|
228
|
+
|
229
|
+
function setLiquidation(address _token, bool _sell) public onlyGovernance {
|
230
|
+
sell[_token] = _sell;
|
231
|
+
}
|
232
|
+
|
233
|
+
function setClaimAllowed(bool _claimAllowed) public onlyGovernance {
|
234
|
+
claimAllowed = _claimAllowed;
|
235
|
+
}
|
236
|
+
|
237
|
+
function setProtected(bool _protected) public onlyGovernance {
|
238
|
+
protected = _protected;
|
239
|
+
}
|
240
|
+
}
|