@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,176 @@
|
|
1
|
+
// Utilities
|
2
|
+
const Utils = require("../utilities/Utils.js");
|
3
|
+
const { impersonates, setupCoreProtocol, depositVault } = require("../utilities/hh-utils.js");
|
4
|
+
|
5
|
+
const addresses = require("../test-config.js");
|
6
|
+
const { send } = require("@openzeppelin/test-helpers");
|
7
|
+
const BigNumber = require("bignumber.js");
|
8
|
+
const IERC20 = artifacts.require("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20");
|
9
|
+
const Vault = artifacts.require("Vault");
|
10
|
+
|
11
|
+
const Strategy = artifacts.require("JarvisHodlStrategyV3Mainnet_2EUR_PAR");
|
12
|
+
|
13
|
+
const D18 = new BigNumber(Math.pow(10, 18));
|
14
|
+
|
15
|
+
//This test was developed at blockNumber 31158250
|
16
|
+
|
17
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
18
|
+
describe("Mainnet Jarvis 2EUR-PAR HODL in LP", function() {
|
19
|
+
let accounts;
|
20
|
+
|
21
|
+
// external contracts
|
22
|
+
let underlying;
|
23
|
+
let hodlVault;
|
24
|
+
|
25
|
+
// external setup
|
26
|
+
let underlyingWhale = "0xc31249BA48763dF46388BA5C4E7565d62ed4801C";
|
27
|
+
let hodlVaultAddr = "0x173ce98897F7c846d7282555B52362B4233d2196";
|
28
|
+
|
29
|
+
// parties in the protocol
|
30
|
+
let governance;
|
31
|
+
let farmer1;
|
32
|
+
|
33
|
+
// numbers used in tests
|
34
|
+
let farmerBalance;
|
35
|
+
|
36
|
+
// Core protocol contracts
|
37
|
+
let controller;
|
38
|
+
let vault;
|
39
|
+
let strategy;
|
40
|
+
|
41
|
+
async function setupExternalContracts() {
|
42
|
+
underlying = await IERC20.at("0x0f110c55EfE62c16D553A3d3464B77e1853d0e97");
|
43
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
44
|
+
hodlVault = await Vault.at(hodlVaultAddr);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
// Give whale some ether to make sure the following actions are good
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 1e18});
|
51
|
+
|
52
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
53
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
54
|
+
}
|
55
|
+
|
56
|
+
before(async function() {
|
57
|
+
governance = "0xf00dD244228F51547f0563e60bCa65a30FBF5f7f";
|
58
|
+
accounts = await web3.eth.getAccounts();
|
59
|
+
|
60
|
+
farmer1 = accounts[1];
|
61
|
+
|
62
|
+
// impersonate accounts
|
63
|
+
await impersonates([governance, underlyingWhale]);
|
64
|
+
|
65
|
+
await setupExternalContracts();
|
66
|
+
[controller, vault, strategy, potPool] = await setupCoreProtocol({
|
67
|
+
"existingVaultAddress": null,
|
68
|
+
"strategyArtifact": Strategy,
|
69
|
+
"strategyArtifactIsUpgradable": true,
|
70
|
+
"underlying": underlying,
|
71
|
+
"governance": governance,
|
72
|
+
"rewardPool" : true,
|
73
|
+
"rewardPoolConfig": {
|
74
|
+
type: 'PotPool',
|
75
|
+
rewardTokens: [
|
76
|
+
hodlVaultAddr // fJRTMAY22-USDC
|
77
|
+
]
|
78
|
+
},
|
79
|
+
});
|
80
|
+
|
81
|
+
await strategy.setPotPool(potPool.address, {from: governance});
|
82
|
+
await potPool.setRewardDistribution([strategy.address], true, {from: governance});
|
83
|
+
|
84
|
+
// whale send underlying to farmers
|
85
|
+
await setupBalance();
|
86
|
+
});
|
87
|
+
|
88
|
+
describe("Happy path", function() {
|
89
|
+
it("Farmer should earn money", async function() {
|
90
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
91
|
+
let farmerOldHodlBalance = new BigNumber(await hodlVault.balanceOf(farmer1));
|
92
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
93
|
+
let fTokenBalance = new BigNumber(await vault.balanceOf(farmer1));
|
94
|
+
|
95
|
+
let erc20Vault = await IERC20.at(vault.address);
|
96
|
+
await erc20Vault.approve(potPool.address, fTokenBalance, {from: farmer1});
|
97
|
+
await potPool.stake(fTokenBalance, {from: farmer1});
|
98
|
+
|
99
|
+
// Using half days is to simulate how we doHardwork in the real world
|
100
|
+
let hours = 10;
|
101
|
+
let blocksPerHour = 1565*5;
|
102
|
+
let oldSharePrice;
|
103
|
+
let newSharePrice;
|
104
|
+
let oldHodlSharePrice;
|
105
|
+
let newHodlSharePrice;
|
106
|
+
let oldPotPoolBalance;
|
107
|
+
let newPotPoolBalance;
|
108
|
+
let hodlPrice;
|
109
|
+
let lpPrice;
|
110
|
+
let oldValue;
|
111
|
+
let newValue;
|
112
|
+
for (let i = 0; i < hours; i++) {
|
113
|
+
console.log("loop ", i);
|
114
|
+
|
115
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
116
|
+
oldHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
117
|
+
oldPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
118
|
+
await controller.doHardWork(vault.address, {from: governance});
|
119
|
+
await controller.doHardWork(hodlVault.address, {from: governance});
|
120
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
121
|
+
newHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
122
|
+
newPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
123
|
+
|
124
|
+
hodlPrice = new BigNumber(17.36).times(D18);
|
125
|
+
lpPrice = new BigNumber(1.02).times(D18);
|
126
|
+
console.log("Hodl price:", hodlPrice.toFixed()/D18.toFixed());
|
127
|
+
console.log("LP price:", lpPrice.toFixed()/D18.toFixed());
|
128
|
+
|
129
|
+
oldValue = (fTokenBalance.times(oldSharePrice).times(lpPrice)).div(1e36).plus((oldPotPoolBalance.times(oldHodlSharePrice).times(hodlPrice)).div(1e36));
|
130
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((newPotPoolBalance.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
131
|
+
|
132
|
+
console.log("old value: ", oldValue.toFixed()/D18.toFixed());
|
133
|
+
console.log("new value: ", newValue.toFixed()/D18.toFixed());
|
134
|
+
console.log("growth: ", newValue.toFixed() / oldValue.toFixed());
|
135
|
+
|
136
|
+
console.log("HodlToken in potpool: ", newPotPoolBalance.toFixed());
|
137
|
+
|
138
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))*365;
|
139
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))+1)**365;
|
140
|
+
|
141
|
+
console.log("instant APR:", apr*100, "%");
|
142
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
143
|
+
|
144
|
+
await Utils.advanceNBlock(blocksPerHour);
|
145
|
+
}
|
146
|
+
// withdrawAll to make sure no doHardwork is called when we do withdraw later.
|
147
|
+
await vault.withdrawAll({ from: governance });
|
148
|
+
|
149
|
+
// wait until all reward can be claimed by the farmer
|
150
|
+
await Utils.waitTime(86400 * 30 * 1000);
|
151
|
+
console.log("vaultBalance: ", fTokenBalance.toFixed());
|
152
|
+
await potPool.exit({from: farmer1});
|
153
|
+
await vault.withdraw(fTokenBalance.toFixed(), { from: farmer1 });
|
154
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
155
|
+
let farmerNewHodlBalance = new BigNumber(await hodlVault.balanceOf(farmer1));
|
156
|
+
Utils.assertBNGte(farmerNewBalance, farmerOldBalance);
|
157
|
+
Utils.assertBNGt(farmerNewHodlBalance, farmerOldHodlBalance);
|
158
|
+
|
159
|
+
oldValue = (fTokenBalance.times(1e18).times(lpPrice)).div(1e36);
|
160
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((farmerNewHodlBalance.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
161
|
+
|
162
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))*365;
|
163
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))+1)**365;
|
164
|
+
|
165
|
+
console.log("Overall APR:", apr*100, "%");
|
166
|
+
console.log("Overall APY:", (apy-1)*100, "%");
|
167
|
+
|
168
|
+
console.log("potpool totalShare: ", (new BigNumber(await potPool.totalSupply())).toFixed());
|
169
|
+
console.log("hodlToken in potpool: ", (new BigNumber(await hodlVault.balanceOf(potPool.address))).toFixed() );
|
170
|
+
console.log("Farmer got HodlToken from potpool: ", farmerNewHodlBalance.toFixed());
|
171
|
+
console.log("earned!");
|
172
|
+
|
173
|
+
await strategy.withdrawAllToVault({ from: governance }); // making sure can withdraw all for a next switch
|
174
|
+
});
|
175
|
+
});
|
176
|
+
});
|
@@ -0,0 +1,182 @@
|
|
1
|
+
// Utilities
|
2
|
+
const Utils = require("../utilities/Utils.js");
|
3
|
+
const { impersonates, setupCoreProtocol, depositVault } = require("../utilities/hh-utils.js");
|
4
|
+
|
5
|
+
const addresses = require("../test-config.js");
|
6
|
+
const { send } = require("@openzeppelin/test-helpers");
|
7
|
+
const BigNumber = require("bignumber.js");
|
8
|
+
const IERC20 = artifacts.require("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20");
|
9
|
+
const IController = artifacts.require("IController");
|
10
|
+
const Vault = artifacts.require("Vault");
|
11
|
+
const PotPool = artifacts.require("PotPool");
|
12
|
+
|
13
|
+
const Strategy = artifacts.require("JarvisHodlStrategyV3Mainnet_2EUR_PAR");
|
14
|
+
|
15
|
+
const D18 = new BigNumber(Math.pow(10, 18));
|
16
|
+
|
17
|
+
//This test was developed at blockNumber 33307200
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Mainnet Jarvis 2EUR-PAR HODL in LP - Update rewardPool", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0xaa8A19d6bF655Bfa3C448248ad2482D05BAb6f98";
|
28
|
+
let vaultAddr = "0x023E85B8415b460C56377525ED159aF9935E3370";
|
29
|
+
let potPoolAddr = "0x2892FA6e9D7Fc9bc8C8e62BBe79AdDff41314d03";
|
30
|
+
let hodlVaultAddr = "0xF67d5e775C76E1631ea33D9977A02EccD7316a4C";
|
31
|
+
|
32
|
+
let rewardPoolAddr = "0xeA9871A9451c281cc1180100FC074D7F28402288";
|
33
|
+
let rewardTokenAddr = "0x4Fd52587194a0bfd3AC5b8096D15e1a7230bA2eb";
|
34
|
+
let rewardLPAddr = "0x946bE3eCAebaA3fe2eBb73864ab555A8cfdF49Fd";
|
35
|
+
let pid = 0;
|
36
|
+
|
37
|
+
// parties in the protocol
|
38
|
+
let governance;
|
39
|
+
let farmer1;
|
40
|
+
|
41
|
+
// numbers used in tests
|
42
|
+
let farmerBalance;
|
43
|
+
|
44
|
+
// Core protocol contracts
|
45
|
+
let controller;
|
46
|
+
let vault;
|
47
|
+
let strategy;
|
48
|
+
|
49
|
+
async function setupExternalContracts() {
|
50
|
+
underlying = await IERC20.at("0x0f110c55EfE62c16D553A3d3464B77e1853d0e97");
|
51
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
52
|
+
}
|
53
|
+
|
54
|
+
async function setupBalance(){
|
55
|
+
let etherGiver = accounts[9];
|
56
|
+
// Give whale some ether to make sure the following actions are good
|
57
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 1e18});
|
58
|
+
|
59
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
60
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
61
|
+
}
|
62
|
+
|
63
|
+
before(async function() {
|
64
|
+
governance = "0xf00dD244228F51547f0563e60bCa65a30FBF5f7f";
|
65
|
+
accounts = await web3.eth.getAccounts();
|
66
|
+
|
67
|
+
farmer1 = accounts[1];
|
68
|
+
|
69
|
+
// impersonate accounts
|
70
|
+
await impersonates([governance, underlyingWhale]);
|
71
|
+
|
72
|
+
await setupExternalContracts();
|
73
|
+
|
74
|
+
controller = await IController.at(addresses.Controller);
|
75
|
+
vault = await Vault.at(vaultAddr);
|
76
|
+
hodlVault = await Vault.at(hodlVaultAddr);
|
77
|
+
strategy = await Strategy.at(await vault.strategy());
|
78
|
+
potPool = await PotPool.at(potPoolAddr);
|
79
|
+
|
80
|
+
await strategy.updateRewardPool(
|
81
|
+
rewardPoolAddr,
|
82
|
+
rewardTokenAddr,
|
83
|
+
rewardLPAddr,
|
84
|
+
pid,
|
85
|
+
hodlVaultAddr,
|
86
|
+
{from: governance});
|
87
|
+
|
88
|
+
await potPool.addRewardToken(hodlVaultAddr, {from: governance});
|
89
|
+
|
90
|
+
// whale send underlying to farmers
|
91
|
+
await setupBalance();
|
92
|
+
});
|
93
|
+
|
94
|
+
describe("Happy path", function() {
|
95
|
+
it("Farmer should earn money", async function() {
|
96
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
97
|
+
let farmerOldHodlBalance = new BigNumber(await hodlVault.balanceOf(farmer1));
|
98
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
99
|
+
let fTokenBalance = new BigNumber(await vault.balanceOf(farmer1));
|
100
|
+
|
101
|
+
let erc20Vault = await IERC20.at(vault.address);
|
102
|
+
await erc20Vault.approve(potPool.address, fTokenBalance, {from: farmer1});
|
103
|
+
await potPool.stake(fTokenBalance, {from: farmer1});
|
104
|
+
|
105
|
+
// Using half days is to simulate how we doHardwork in the real world
|
106
|
+
let hours = 10;
|
107
|
+
let blocksPerHour = 1565*5;
|
108
|
+
let oldSharePrice;
|
109
|
+
let newSharePrice;
|
110
|
+
let oldHodlSharePrice;
|
111
|
+
let newHodlSharePrice;
|
112
|
+
let oldPotPoolBalance;
|
113
|
+
let newPotPoolBalance;
|
114
|
+
let hodlPrice;
|
115
|
+
let lpPrice;
|
116
|
+
let oldValue;
|
117
|
+
let newValue;
|
118
|
+
for (let i = 0; i < hours; i++) {
|
119
|
+
console.log("loop ", i);
|
120
|
+
|
121
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
122
|
+
oldHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
123
|
+
oldPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
124
|
+
await controller.doHardWork(vault.address, {from: governance});
|
125
|
+
await controller.doHardWork(hodlVault.address, {from: governance});
|
126
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
127
|
+
newHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
128
|
+
newPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
129
|
+
|
130
|
+
hodlPrice = new BigNumber(17.407).times(D18);
|
131
|
+
lpPrice = new BigNumber(1.02).times(D18);
|
132
|
+
console.log("Hodl price:", hodlPrice.toFixed()/D18.toFixed());
|
133
|
+
console.log("LP price:", lpPrice.toFixed()/D18.toFixed());
|
134
|
+
|
135
|
+
oldValue = (fTokenBalance.times(oldSharePrice).times(lpPrice)).div(1e36).plus((oldPotPoolBalance.times(oldHodlSharePrice).times(hodlPrice)).div(1e36));
|
136
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((newPotPoolBalance.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
137
|
+
|
138
|
+
console.log("old value: ", oldValue.toFixed()/D18.toFixed());
|
139
|
+
console.log("new value: ", newValue.toFixed()/D18.toFixed());
|
140
|
+
console.log("growth: ", newValue.toFixed() / oldValue.toFixed());
|
141
|
+
|
142
|
+
console.log("HodlToken in potpool: ", newPotPoolBalance.toFixed());
|
143
|
+
|
144
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))*365;
|
145
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))+1)**365;
|
146
|
+
|
147
|
+
console.log("instant APR:", apr*100, "%");
|
148
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
149
|
+
|
150
|
+
await Utils.advanceNBlock(blocksPerHour);
|
151
|
+
}
|
152
|
+
// withdrawAll to make sure no doHardwork is called when we do withdraw later.
|
153
|
+
await vault.withdrawAll({ from: governance });
|
154
|
+
|
155
|
+
// wait until all reward can be claimed by the farmer
|
156
|
+
await Utils.waitTime(86400 * 30 * 1000);
|
157
|
+
console.log("vaultBalance: ", fTokenBalance.toFixed());
|
158
|
+
await potPool.exit({from: farmer1});
|
159
|
+
await vault.withdraw(fTokenBalance.toFixed(), { from: farmer1 });
|
160
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
161
|
+
let farmerNewHodlBalance = new BigNumber(await hodlVault.balanceOf(farmer1));
|
162
|
+
Utils.assertBNGte(farmerNewBalance, farmerOldBalance);
|
163
|
+
Utils.assertBNGt(farmerNewHodlBalance, farmerOldHodlBalance);
|
164
|
+
|
165
|
+
oldValue = (fTokenBalance.times(1e18).times(lpPrice)).div(1e36);
|
166
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((farmerNewHodlBalance.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
167
|
+
|
168
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))*365;
|
169
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))+1)**365;
|
170
|
+
|
171
|
+
console.log("Overall APR:", apr*100, "%");
|
172
|
+
console.log("Overall APY:", (apy-1)*100, "%");
|
173
|
+
|
174
|
+
console.log("potpool totalShare: ", (new BigNumber(await potPool.totalSupply())).toFixed());
|
175
|
+
console.log("HodlToken in potpool: ", (new BigNumber(await hodlVault.balanceOf(potPool.address))).toFixed() );
|
176
|
+
console.log("Farmer got HodlToken from potpool: ", farmerNewHodlBalance.toFixed());
|
177
|
+
console.log("earned!");
|
178
|
+
|
179
|
+
await strategy.withdrawAllToVault({ from: governance }); // making sure can withdraw all for a next switch
|
180
|
+
});
|
181
|
+
});
|
182
|
+
});
|
@@ -0,0 +1,244 @@
|
|
1
|
+
// Utilities
|
2
|
+
const Utils = require("../utilities/Utils.js");
|
3
|
+
const { impersonates, setupCoreProtocol, depositVault } = require("../utilities/hh-utils.js");
|
4
|
+
|
5
|
+
const BigNumber = require("bignumber.js");
|
6
|
+
const IERC20 = artifacts.require("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20");
|
7
|
+
|
8
|
+
const HodlStrategy = artifacts.require("JarvisStrategyV3Mainnet_SES_2JPY");
|
9
|
+
const Strategy = artifacts.require("JarvisHodlStrategyV3Mainnet_2JPY");
|
10
|
+
const CurvePool = artifacts.require("ICurveDeposit_2token");
|
11
|
+
const IDMMPool = artifacts.require("IDMMPool");
|
12
|
+
|
13
|
+
const D18 = new BigNumber(Math.pow(10, 18));
|
14
|
+
|
15
|
+
//This test was developed at blockNumber 24170621
|
16
|
+
|
17
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
18
|
+
describe("Mainnet Jarvis 2JPY HODL in LP", function() {
|
19
|
+
let accounts;
|
20
|
+
|
21
|
+
// external contracts
|
22
|
+
let underlying;
|
23
|
+
|
24
|
+
// external setup
|
25
|
+
let underlyingWhale = "0xc91faf934708a5e3b3ff8ed212904c4efd2aaf57";
|
26
|
+
let hodlUnderlying = "0x3b76F90A8ab3EA7f0EA717F34ec65d194E5e9737";
|
27
|
+
let curvePoolAddr = "0xE8dCeA7Fb2Baf7a9F4d9af608F06d78a687F8d9A";
|
28
|
+
|
29
|
+
// parties in the protocol
|
30
|
+
let governance;
|
31
|
+
let farmer1;
|
32
|
+
|
33
|
+
// numbers used in tests
|
34
|
+
let farmerBalance;
|
35
|
+
|
36
|
+
// Core protocol contracts
|
37
|
+
let controller;
|
38
|
+
let vault;
|
39
|
+
let strategy;
|
40
|
+
|
41
|
+
async function setupExternalContracts() {
|
42
|
+
underlying = await IERC20.at("0xE8dCeA7Fb2Baf7a9F4d9af608F06d78a687F8d9A");
|
43
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
44
|
+
}
|
45
|
+
|
46
|
+
async function setupBalance(){
|
47
|
+
let etherGiver = accounts[9];
|
48
|
+
// Give whale some ether to make sure the following actions are good
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 1e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
console.log("underlyingWhale balance: ", new BigNumber(farmerBalance).toFixed());
|
53
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
54
|
+
}
|
55
|
+
|
56
|
+
before(async function() {
|
57
|
+
governance = "0xf00dD244228F51547f0563e60bCa65a30FBF5f7f";
|
58
|
+
accounts = await web3.eth.getAccounts();
|
59
|
+
|
60
|
+
farmer1 = accounts[1];
|
61
|
+
|
62
|
+
// impersonate accounts
|
63
|
+
await impersonates([governance, underlyingWhale]);
|
64
|
+
|
65
|
+
await setupExternalContracts();
|
66
|
+
[controller, hodlVault, hodlStrategy] = await setupCoreProtocol({
|
67
|
+
"existingVaultAddress": null,
|
68
|
+
"strategyArtifact": HodlStrategy,
|
69
|
+
"strategyArtifactIsUpgradable": true,
|
70
|
+
"underlying": await IERC20.at(hodlUnderlying),
|
71
|
+
"governance": governance,
|
72
|
+
});
|
73
|
+
[controller, vault, strategy, potPool] = await setupCoreProtocol({
|
74
|
+
"existingVaultAddress": null,
|
75
|
+
"strategyArtifact": Strategy,
|
76
|
+
"strategyArtifactIsUpgradable": true,
|
77
|
+
"underlying": underlying,
|
78
|
+
"governance": governance,
|
79
|
+
"rewardPool" : true,
|
80
|
+
"rewardPoolConfig": {
|
81
|
+
type: 'PotPool',
|
82
|
+
rewardTokens: [
|
83
|
+
hodlVault.address // fSES-2JPY
|
84
|
+
]
|
85
|
+
},
|
86
|
+
});
|
87
|
+
|
88
|
+
await strategy.setHodlVault(hodlVault.address, {from: governance});
|
89
|
+
await strategy.setPotPool(potPool.address, {from: governance});
|
90
|
+
await potPool.setRewardDistribution([strategy.address], true, {from: governance});
|
91
|
+
// await controller.addToWhitelist(strategy.address, {from: governance});
|
92
|
+
|
93
|
+
// whale send underlying to farmers
|
94
|
+
await setupBalance();
|
95
|
+
});
|
96
|
+
|
97
|
+
describe("Happy path", function() {
|
98
|
+
it("Farmer should earn money", async function() {
|
99
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
100
|
+
console.log("farmerOldBalance: ", farmerOldBalance.toFixed());
|
101
|
+
let farmerOldfSES_2JPY = new BigNumber(await hodlVault.balanceOf(farmer1));
|
102
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
103
|
+
let fTokenBalance = new BigNumber(await vault.balanceOf(farmer1));
|
104
|
+
|
105
|
+
let erc20Vault = await IERC20.at(vault.address);
|
106
|
+
await erc20Vault.approve(potPool.address, fTokenBalance, {from: farmer1});
|
107
|
+
await potPool.stake(fTokenBalance, {from: farmer1});
|
108
|
+
|
109
|
+
// Using half days is to simulate how we doHardwork in the real world
|
110
|
+
let hours = 10;
|
111
|
+
let blocksPerHour = 1565*5;
|
112
|
+
let oldSharePrice;
|
113
|
+
let newSharePrice;
|
114
|
+
let oldHodlSharePrice;
|
115
|
+
let newHodlSharePrice;
|
116
|
+
let oldPotPoolBalance;
|
117
|
+
let newPotPoolBalance;
|
118
|
+
let hodlPrice;
|
119
|
+
let lpPrice;
|
120
|
+
let oldValue;
|
121
|
+
let newValue;
|
122
|
+
let curvePool;
|
123
|
+
let dmmPool;
|
124
|
+
|
125
|
+
curvePool = await CurvePool.at(curvePoolAddr);
|
126
|
+
lpPrice = new BigNumber(await curvePool.get_virtual_price());
|
127
|
+
hodlPrice = new BigNumber(119.387).times(D18);
|
128
|
+
dmmPool = await IDMMPool.at(hodlUnderlying);
|
129
|
+
console.log("total supply of DMM pool lp tokens: ", new BigNumber(await dmmPool.totalSupply()).toFixed());
|
130
|
+
|
131
|
+
const tradeInfo = await dmmPool.getTradeInfo();
|
132
|
+
var {0: reserve0, 1: reserve1, 2: vReserve0, 3: vReserve1, 4: feeInPrecision} = tradeInfo;
|
133
|
+
|
134
|
+
// token0: Sestertius (SES-FEB22)
|
135
|
+
// token1: Curve.fi Factory Plain Pool: 2jpy (2jpy-f)
|
136
|
+
|
137
|
+
console.log("DMM pool reserve0: ", new BigNumber(reserve0).toFixed());
|
138
|
+
console.log("DMM pool reserve1: ", new BigNumber(reserve1).toFixed());
|
139
|
+
console.log("DMM pool vReserve0: ", new BigNumber(vReserve0).toFixed());
|
140
|
+
console.log("DMM pool vReserve1: ", new BigNumber(vReserve1).toFixed());
|
141
|
+
|
142
|
+
// 1 SES-FEB22 = 66220 2jpy-f from https://kyberswap.com/#/add/0x9120ECada8dc70Dc62cBD49f58e861a09bf83788/0xE8dCeA7Fb2Baf7a9F4d9af608F06d78a687F8d9A/0x3b76F90A8ab3EA7f0EA717F34ec65d194E5e9737 (02.02.2022)
|
143
|
+
console.log("Exchange rate: ", new BigNumber(vReserve1).div(new BigNumber(vReserve0)).toFixed() );
|
144
|
+
|
145
|
+
// all pool SES-FEB22 tokens in 2jpy-f value
|
146
|
+
let token0Amount = (new BigNumber(reserve0).toFixed()/D18.toFixed());
|
147
|
+
console.log("token0Amount: ", token0Amount);
|
148
|
+
|
149
|
+
let token1Amount = (new BigNumber(reserve1).toFixed()/D18.toFixed());
|
150
|
+
console.log("token1Amount: ", token1Amount)
|
151
|
+
|
152
|
+
let lpTokenAmount = new BigNumber(await dmmPool.totalSupply()).toFixed()/D18.toFixed();
|
153
|
+
console.log("lpTokenAmount: ", lpTokenAmount);
|
154
|
+
|
155
|
+
let token0inToken1Value = token0Amount*(new BigNumber(vReserve1).div(new BigNumber(vReserve0)).toFixed())
|
156
|
+
console.log("pool SES-FEB22 tokens in 2jpy-f unit: ", token0inToken1Value);
|
157
|
+
hodlPriceNew = ((token0inToken1Value + token1Amount) * (lpPrice.toFixed()/D18.toFixed())) / lpTokenAmount;
|
158
|
+
|
159
|
+
console.log("hodlPriceNew: ", hodlPriceNew);
|
160
|
+
|
161
|
+
hodlPrice = new BigNumber(hodlPriceNew).times(D18);
|
162
|
+
|
163
|
+
console.log("Hodl price:", hodlPrice.toFixed()/D18.toFixed());
|
164
|
+
console.log("LP price:", lpPrice.toFixed()/D18.toFixed());
|
165
|
+
|
166
|
+
for (let i = 0; i < hours; i++) {
|
167
|
+
console.log("loop ", i);
|
168
|
+
|
169
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
170
|
+
oldHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
171
|
+
oldPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
172
|
+
await controller.doHardWork(vault.address, {from: governance});
|
173
|
+
await controller.doHardWork(hodlVault.address, {from: governance});
|
174
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
175
|
+
newHodlSharePrice = new BigNumber(await hodlVault.getPricePerFullShare());
|
176
|
+
newPotPoolBalance = new BigNumber(await hodlVault.balanceOf(potPool.address));
|
177
|
+
|
178
|
+
// https://kyberswap.com/#/pools/0xE8dCeA7Fb2Baf7a9F4d9af608F06d78a687F8d9A/0x9120ECada8dc70Dc62cBD49f58e861a09bf83788
|
179
|
+
|
180
|
+
// info about Kyber DMM pool: https://chainsecurity.com/wp-content/uploads/2021/04/ChainSecurity_KyberNetwork_DMM_Dynamic-Market-Making_Final.pdf
|
181
|
+
// reserves use the Amplification Model. Instead of the inventory function x*y = k
|
182
|
+
// Kyber DMM pool uses x * y = k * a^2
|
183
|
+
// All invariants related to swapping are based on the virtualReserves.
|
184
|
+
// All invariants related to adding or removing liquidity are based on the values of the "traditional" reserves
|
185
|
+
|
186
|
+
// ftokenBalance: amount of f2JPY of farmer1
|
187
|
+
// oldSharePrice: vault (f2JPY strategy) share price: underlyingUnit().mul(underlyingBalanceWithInvestment()).div(totalSupply());
|
188
|
+
// lpPrice (underlying of f2JPY): price of 2jpy in virtual price of curve lp ("average dollar value of pool token")
|
189
|
+
|
190
|
+
// oldPotPoolBalance: amount of fSES-2JPY that the PotPool holds
|
191
|
+
// oldHodlSharePrice: vault (fSES-2JPY) share price: underlyingUnit().mul(underlyingBalanceWithInvestment()).div(totalSupply());
|
192
|
+
// hodlPrice (underlying of fSES-2JPY): price of KyberDMM LP SES-FEB22-2jpy in
|
193
|
+
|
194
|
+
// oldValue = (fTokenBalance * oldSharePrice * lpPrice) / 1e36 + (oldPotPoolBalance * oldHodlSharePrice * hodlPrice) / 1e36
|
195
|
+
oldValue = (fTokenBalance.times(oldSharePrice).times(lpPrice)).div(1e36).plus((oldPotPoolBalance.times(oldHodlSharePrice).times(hodlPrice)).div(1e36));
|
196
|
+
|
197
|
+
// newValue = (fTokenBalance * newSharePrice * lpPrice) / 1e36 + (newPotPoolBalance * newHodlSharePrice * hodlPrice) / 1e36
|
198
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((newPotPoolBalance.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
199
|
+
|
200
|
+
console.log("old value: ", oldValue.toFixed()/D18.toFixed());
|
201
|
+
console.log("new value: ", newValue.toFixed()/D18.toFixed());
|
202
|
+
console.log("growth: ", newValue.toFixed() / oldValue.toFixed());
|
203
|
+
|
204
|
+
console.log("fSES-JPY in potpool: ", newPotPoolBalance.toFixed());
|
205
|
+
|
206
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))*365;
|
207
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour/1565))+1)**365;
|
208
|
+
|
209
|
+
console.log("instant APR:", apr*100, "%");
|
210
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
211
|
+
|
212
|
+
await Utils.advanceNBlock(blocksPerHour);
|
213
|
+
}
|
214
|
+
// withdrawAll to make sure no doHardwork is called when we do withdraw later.
|
215
|
+
await vault.withdrawAll({ from: governance });
|
216
|
+
|
217
|
+
// wait until all reward can be claimed by the farmer
|
218
|
+
await Utils.waitTime(86400 * 30 * 1000);
|
219
|
+
console.log("vaultBalance: ", fTokenBalance.toFixed());
|
220
|
+
await potPool.exit({from: farmer1});
|
221
|
+
await vault.withdraw(fTokenBalance.toFixed(), { from: farmer1 });
|
222
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
223
|
+
let farmerNewfSES_2JPY = new BigNumber(await hodlVault.balanceOf(farmer1));
|
224
|
+
Utils.assertBNGte(farmerNewBalance, farmerOldBalance);
|
225
|
+
Utils.assertBNGt(farmerNewfSES_2JPY, farmerOldfSES_2JPY);
|
226
|
+
|
227
|
+
oldValue = (fTokenBalance.times(1e18).times(lpPrice)).div(1e36);
|
228
|
+
newValue = (fTokenBalance.times(newSharePrice).times(lpPrice)).div(1e36).plus((farmerNewfSES_2JPY.times(newHodlSharePrice).times(hodlPrice)).div(1e36));
|
229
|
+
|
230
|
+
apr = (newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))*365;
|
231
|
+
apy = ((newValue.toFixed()/oldValue.toFixed()-1)*(24/(blocksPerHour*hours/1565))+1)**365;
|
232
|
+
|
233
|
+
console.log("Overall APR:", apr*100, "%");
|
234
|
+
console.log("Overall APY:", (apy-1)*100, "%");
|
235
|
+
|
236
|
+
console.log("potpool totalShare: ", (new BigNumber(await potPool.totalSupply())).toFixed());
|
237
|
+
console.log("fSES-JPY in potpool: ", (new BigNumber(await hodlVault.balanceOf(potPool.address))).toFixed() );
|
238
|
+
console.log("Farmer got fSES-JPY from potpool: ", farmerNewfSES_2JPY.toFixed());
|
239
|
+
console.log("earned!");
|
240
|
+
|
241
|
+
await strategy.withdrawAllToVault({ from: governance }); // making sure can withdraw all for a next switch
|
242
|
+
});
|
243
|
+
});
|
244
|
+
});
|