@harvest-finance/harvest-strategy-arbitrum 0.0.1-security → 1.0.1
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-arbitrum might be problematic. Click here for more details.
- package/README.md +127 -5
- package/contracts/base/Controller.sol +358 -0
- package/contracts/base/Drip.sol +86 -0
- package/contracts/base/PotPool.sol +367 -0
- package/contracts/base/ProfitSharingReceiver.sol +38 -0
- package/contracts/base/Reader.sol +54 -0
- package/contracts/base/RewardForwarder.sol +109 -0
- package/contracts/base/VaultProxy.sol +34 -0
- package/contracts/base/VaultStorage.sol +205 -0
- package/contracts/base/VaultV1.sol +371 -0
- package/contracts/base/VaultV1GMX.sol +465 -0
- package/contracts/base/VaultV2.sol +111 -0
- package/contracts/base/VaultV2GMX.sol +111 -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 +41 -0
- package/contracts/base/factory/strategy/UpgradableStrategyFactory.sol +19 -0
- package/contracts/base/factory/vault/RegularVaultFactory.sol +34 -0
- package/contracts/base/incentives/GlobalIncentivesExecutor.sol +85 -0
- package/contracts/base/incentives/GlobalIncentivesHelper.sol +174 -0
- package/contracts/base/incentives/NotifyHelperGeneric.sol +61 -0
- package/contracts/base/incentives/NotifyHelperStateful.sol +290 -0
- package/contracts/base/incentives/ViewerNotifyHelperStateful.sol +25 -0
- package/contracts/base/inheritance/Controllable.sol +25 -0
- package/contracts/base/inheritance/ControllableInit.sol +30 -0
- package/contracts/base/inheritance/Governable.sol +28 -0
- package/contracts/base/inheritance/GovernableInit.sol +50 -0
- package/contracts/base/inheritance/IUpgradeSource.sol +7 -0
- package/contracts/base/inheritance/OwnableWhitelist.sol +17 -0
- package/contracts/base/inheritance/Storage.sol +35 -0
- package/contracts/base/interface/IBalDex.sol +7 -0
- package/contracts/base/interface/IController.sol +132 -0
- package/contracts/base/interface/IDex.sol +9 -0
- package/contracts/base/interface/IERC4626.sol +261 -0
- package/contracts/base/interface/IGMXStrategy.sol +37 -0
- package/contracts/base/interface/IGlobalIncentivesHelper.sol +6 -0
- package/contracts/base/interface/IPotPool.sol +70 -0
- package/contracts/base/interface/IProfitSharingReceiver.sol +9 -0
- package/contracts/base/interface/IRewardForwarder.sol +57 -0
- package/contracts/base/interface/IStrategy.sol +37 -0
- package/contracts/base/interface/IUniversalLiquidator.sol +21 -0
- package/contracts/base/interface/IUniversalLiquidatorRegistry.sol +20 -0
- package/contracts/base/interface/IUpgradeSource.sol +9 -0
- package/contracts/base/interface/IVault.sol +58 -0
- package/contracts/base/interface/IVaultGMX.sol +71 -0
- package/contracts/base/interface/aura/IAuraBaseRewardPool.sol +25 -0
- package/contracts/base/interface/aura/IAuraBooster.sol +17 -0
- package/contracts/base/interface/aura/IAuraDepositor.sol +7 -0
- package/contracts/base/interface/balancer/Gauge.sol +22 -0
- package/contracts/base/interface/balancer/IBVault.sol +580 -0
- package/contracts/base/interface/balancer/IBalancerMinter.sol +114 -0
- package/contracts/base/interface/balancer/IGyroPool.sol +7 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPool.sol +184 -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 +56 -0
- package/contracts/base/interface/compound/CTokenInterface.sol +29 -0
- package/contracts/base/interface/compound/IComptroller.sol +9 -0
- package/contracts/base/interface/dolomite/IDepositWithdraw.sol +13 -0
- package/contracts/base/interface/dolomite/IDolomiteMargin.sol +15 -0
- package/contracts/base/interface/dolomite/IRewardsDistributor.sol +11 -0
- package/contracts/base/interface/gamma/IClearing.sol +7 -0
- package/contracts/base/interface/gamma/IHypervisor.sol +9 -0
- package/contracts/base/interface/gamma/IUniProxy.sol +14 -0
- package/contracts/base/interface/gmx/EventUtils.sol +253 -0
- package/contracts/base/interface/gmx/ICallbackReceiver.sol +119 -0
- package/contracts/base/interface/gmx/IDataStore.sol +7 -0
- package/contracts/base/interface/gmx/IExchangeRouter.sol +38 -0
- package/contracts/base/interface/gmx/IGMXViewer.sol +7 -0
- package/contracts/base/interface/gmx/IHandler.sol +12 -0
- package/contracts/base/interface/gmx/IMarket.sol +7 -0
- package/contracts/base/interface/gmx/IOracle.sol +6 -0
- package/contracts/base/interface/gmx/IPriceFeed.sol +12 -0
- package/contracts/base/interface/gmx/IReader.sol +49 -0
- package/contracts/base/interface/gmx/IRoleStore.sol +6 -0
- package/contracts/base/interface/ipor/Errors.sol +20 -0
- package/contracts/base/interface/ipor/FuseStorageLib.sol +71 -0
- package/contracts/base/interface/ipor/FusesLib.sol +149 -0
- package/contracts/base/interface/ipor/IFuseCommon.sol +9 -0
- package/contracts/base/interface/ipor/IFuseInstantWithdraw.sol +14 -0
- package/contracts/base/interface/ipor/IMarketBalanceFuse.sol +10 -0
- package/contracts/base/interface/ipor/IPriceOracleMiddleware.sol +42 -0
- package/contracts/base/interface/ipor/IporMath.sol +110 -0
- package/contracts/base/interface/ipor/PlasmaVaultConfigLib.sol +106 -0
- package/contracts/base/interface/ipor/PlasmaVaultLib.sol +293 -0
- package/contracts/base/interface/ipor/PlasmaVaultStorageLib.sol +352 -0
- package/contracts/base/interface/merkl/IDistributor.sol +6 -0
- package/contracts/base/interface/notional/INProxy.sol +44 -0
- package/contracts/base/interface/notional/IPrimeToken.sol +6 -0
- package/contracts/base/interface/venus/IRewardsDistributor.sol +6 -0
- package/contracts/base/interface/weth/IWETH.sol +39 -0
- package/contracts/base/ipor/Erc4626BalanceFuse.sol +54 -0
- package/contracts/base/ipor/Erc4626SupplyFuse.sol +134 -0
- package/contracts/base/noop/NoopStrategyUpgradeable.sol +90 -0
- package/contracts/base/upgradability/BaseUpgradeabilityProxy.sol +60 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategy.sol +144 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategyStorage.sol +284 -0
- package/contracts/base/upgradability/IUpgradable.sol +7 -0
- package/contracts/base/upgradability/ReentrancyGuardUpgradeable.sol +51 -0
- package/contracts/base/upgradability/StrategyProxy.sol +34 -0
- package/contracts/strategies/aura/AuraStrategy.sol +403 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_MORE_GYD.sol +32 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_sUSDe_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waFRAX_sFRAX.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waGHO_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GHO.sol +32 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDT_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_wstETH_GYD.sol +31 -0
- package/contracts/strategies/camelot/CamelotV3Strategy.sol +304 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ARB_USDC.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDC.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDT.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GMX_ETH.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GRAIL_ETH.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_USDC_USDT.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_WBTC_ETH.sol +28 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategy.sol +273 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_DAI.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_GMX.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDC.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDCe.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDT.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WBTC.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WETH.sol +26 -0
- package/contracts/strategies/fluid/FluidLendStrategy.sol +241 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_ETH.sol +25 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDC.sol +25 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDT.sol +25 -0
- package/contracts/strategies/gmx/GMXStrategy.sol +472 -0
- package/contracts/strategies/gmx/GMXStrategyMainnet_WBTC.sol +25 -0
- package/contracts/strategies/gmx/GMXViewer.sol +110 -0
- package/contracts/strategies/notional/NotionalStrategy.sol +223 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nETH.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDC.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDT.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nwstETH.sol +27 -0
- package/contracts/strategies/venus/VenusFoldStrategy.sol +591 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ARB.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_core.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_lsd.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDC.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDT.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_WBTC.sol +32 -0
- package/hardhat.config.js +60 -0
- package/index.js +42 -0
- package/package.json +39 -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 +40 -0
- package/scripts/04-deploy-new-implementation.js +24 -0
- package/scripts/05-deploy-GMXViewer.js +17 -0
- package/scripts/06-deploy-GMXVault.js +49 -0
- package/scripts/07-deploy-ipor-fuses.js +29 -0
- package/scripts/08-deploy-drip.js +20 -0
- package/scripts/README.md +55 -0
- package/scripts/utils.js +22 -0
- package/test/aura/more-gyd.js +140 -0
- package/test/aura/susde-gyd.js +140 -0
- package/test/aura/wafrax-sfrax.js +140 -0
- package/test/aura/wagho-gyd.js +140 -0
- package/test/aura/wausdc-gho.js +141 -0
- package/test/aura/wausdc-gyd.js +140 -0
- package/test/aura/wausdt-gyd.js +140 -0
- package/test/aura/wsteth-gyd.js +138 -0
- package/test/camelot/arb-usdc.js +125 -0
- package/test/camelot/eth-usdc.js +125 -0
- package/test/camelot/eth-usdt.js +125 -0
- package/test/camelot/gmx-eth.js +125 -0
- package/test/camelot/grail-eth.js +125 -0
- package/test/camelot/usdc-usdt.js +125 -0
- package/test/camelot/wbtc-eth.js +125 -0
- package/test/dolomite/dai.js +127 -0
- package/test/dolomite/gmx.js +134 -0
- package/test/dolomite/usdc.js +127 -0
- package/test/dolomite/usdce.js +127 -0
- package/test/dolomite/usdt.js +127 -0
- package/test/dolomite/wbtc.js +127 -0
- package/test/dolomite/weth.js +127 -0
- package/test/fluid/eth.js +127 -0
- package/test/fluid/usdc.js +134 -0
- package/test/fluid/usdt.js +134 -0
- package/test/gmx/wbtc.js +184 -0
- package/test/notional/neth.js +133 -0
- package/test/notional/nusdc.js +133 -0
- package/test/notional/nusdt.js +133 -0
- package/test/notional/nwsteth.js +133 -0
- package/test/test-config.js +28 -0
- package/test/utilities/Utils.js +96 -0
- package/test/utilities/hh-utils.js +248 -0
- package/test/utilities/make-vault.js +16 -0
- package/test/venus/arb.js +135 -0
- package/test/venus/eth-core.js +133 -0
- package/test/venus/eth-lsd.js +133 -0
- package/test/venus/usdc.js +133 -0
- package/test/venus/usdt.js +133 -0
- package/test/venus/wbtc.js +133 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
|
2
|
+
// Utilities
|
3
|
+
const Utils = require("../utilities/Utils.js");
|
4
|
+
const {
|
5
|
+
impersonates,
|
6
|
+
setupCoreProtocol,
|
7
|
+
depositVault,
|
8
|
+
} = require("../utilities/hh-utils.js");
|
9
|
+
|
10
|
+
const addresses = require("../test-config.js");
|
11
|
+
const BigNumber = require("bignumber.js");
|
12
|
+
const IERC20 = artifacts.require("IERC20");
|
13
|
+
|
14
|
+
//const Strategy = artifacts.require("");
|
15
|
+
const Strategy = artifacts.require("VenusFoldStrategyMainnet_ARB");
|
16
|
+
|
17
|
+
// Developed and tested at blockNumber 300500460
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Arbitrum Mainnet Venus Fold ARB", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0xbf827dC78D68bC1a90D59972c4fA1c823b7a8973";
|
28
|
+
let xvs = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
|
29
|
+
let weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
30
|
+
|
31
|
+
// parties in the protocol
|
32
|
+
let governance;
|
33
|
+
let farmer1;
|
34
|
+
|
35
|
+
// numbers used in tests
|
36
|
+
let farmerBalance;
|
37
|
+
|
38
|
+
// Core protocol contracts
|
39
|
+
let controller;
|
40
|
+
let vault;
|
41
|
+
let strategy;
|
42
|
+
|
43
|
+
async function setupExternalContracts() {
|
44
|
+
underlying = await IERC20.at("0x912CE59144191C1204E64559FE8253a0e49E6548");
|
45
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
46
|
+
}
|
47
|
+
|
48
|
+
async function setupBalance(){
|
49
|
+
let etherGiver = accounts[9];
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
51
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
52
|
+
|
53
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
54
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
55
|
+
}
|
56
|
+
|
57
|
+
before(async function() {
|
58
|
+
governance = addresses.Governance;
|
59
|
+
accounts = await web3.eth.getAccounts();
|
60
|
+
|
61
|
+
farmer1 = accounts[1];
|
62
|
+
|
63
|
+
// impersonate accounts
|
64
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
65
|
+
|
66
|
+
let etherGiver = accounts[9];
|
67
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
68
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
69
|
+
|
70
|
+
await setupExternalContracts();
|
71
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
72
|
+
// "existingVaultAddress": "0x32DB5Cbac1C278696875eB9F27eD4cD7423dd126",
|
73
|
+
"strategyArtifact": Strategy,
|
74
|
+
"strategyArtifactIsUpgradable": true,
|
75
|
+
// "announceStrategy": true,
|
76
|
+
"underlying": underlying,
|
77
|
+
"governance": governance,
|
78
|
+
"ULOwner": addresses.ULOwner,
|
79
|
+
"liquidation": [
|
80
|
+
{"uniV3": [xvs, weth]},
|
81
|
+
],
|
82
|
+
"uniV3Fee": [
|
83
|
+
[xvs, weth, '3000'],
|
84
|
+
]
|
85
|
+
});
|
86
|
+
|
87
|
+
// whale send underlying to farmers
|
88
|
+
await setupBalance();
|
89
|
+
});
|
90
|
+
|
91
|
+
describe("Happy path", function() {
|
92
|
+
it("Farmer should earn money", async function() {
|
93
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
94
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
95
|
+
|
96
|
+
let hours = 10;
|
97
|
+
let blocksPerHour = 200;
|
98
|
+
let oldSharePrice;
|
99
|
+
let newSharePrice;
|
100
|
+
|
101
|
+
for (let i = 0; i < hours; i++) {
|
102
|
+
console.log("loop ", i);
|
103
|
+
|
104
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
105
|
+
await controller.doHardWork(vault.address, { from: governance });
|
106
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
107
|
+
|
108
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
109
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
110
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
111
|
+
|
112
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
113
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
114
|
+
|
115
|
+
console.log("instant APR:", apr*100, "%");
|
116
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
117
|
+
|
118
|
+
await Utils.advanceNBlock(blocksPerHour);
|
119
|
+
}
|
120
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
121
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
122
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
123
|
+
|
124
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
125
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
126
|
+
|
127
|
+
console.log("earned!");
|
128
|
+
console.log("APR:", apr*100, "%");
|
129
|
+
console.log("APY:", (apy-1)*100, "%");
|
130
|
+
|
131
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
132
|
+
|
133
|
+
});
|
134
|
+
});
|
135
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
// Utilities
|
3
|
+
const Utils = require("../utilities/Utils.js");
|
4
|
+
const {
|
5
|
+
impersonates,
|
6
|
+
setupCoreProtocol,
|
7
|
+
depositVault,
|
8
|
+
} = require("../utilities/hh-utils.js");
|
9
|
+
|
10
|
+
const addresses = require("../test-config.js");
|
11
|
+
const BigNumber = require("bignumber.js");
|
12
|
+
const IERC20 = artifacts.require("IERC20");
|
13
|
+
|
14
|
+
//const Strategy = artifacts.require("");
|
15
|
+
const Strategy = artifacts.require("VenusFoldStrategyMainnet_ETH_core");
|
16
|
+
|
17
|
+
// Developed and tested at blockNumber 303586650
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Arbitrum Mainnet Venus Fold ETH core", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0x2021dA0831881CF4D1F38308214996B46c508A8A";
|
28
|
+
let xvs = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
|
29
|
+
let weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
30
|
+
|
31
|
+
// parties in the protocol
|
32
|
+
let governance;
|
33
|
+
let farmer1;
|
34
|
+
|
35
|
+
// numbers used in tests
|
36
|
+
let farmerBalance;
|
37
|
+
|
38
|
+
// Core protocol contracts
|
39
|
+
let controller;
|
40
|
+
let vault;
|
41
|
+
let strategy;
|
42
|
+
|
43
|
+
async function setupExternalContracts() {
|
44
|
+
underlying = await IERC20.at("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1");
|
45
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
46
|
+
}
|
47
|
+
|
48
|
+
async function setupBalance(){
|
49
|
+
let etherGiver = accounts[9];
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
51
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
52
|
+
|
53
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
54
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
55
|
+
}
|
56
|
+
|
57
|
+
before(async function() {
|
58
|
+
governance = addresses.Governance;
|
59
|
+
accounts = await web3.eth.getAccounts();
|
60
|
+
|
61
|
+
farmer1 = accounts[1];
|
62
|
+
|
63
|
+
// impersonate accounts
|
64
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
65
|
+
|
66
|
+
let etherGiver = accounts[9];
|
67
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
68
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
69
|
+
|
70
|
+
await setupExternalContracts();
|
71
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
72
|
+
"strategyArtifact": Strategy,
|
73
|
+
"strategyArtifactIsUpgradable": true,
|
74
|
+
"underlying": underlying,
|
75
|
+
"governance": governance,
|
76
|
+
"ULOwner": addresses.ULOwner,
|
77
|
+
// "liquidation": [
|
78
|
+
// {"uniV3": [xvs, weth]},
|
79
|
+
// ],
|
80
|
+
// "uniV3Fee": [
|
81
|
+
// [xvs, weth, '3000'],
|
82
|
+
// ]
|
83
|
+
});
|
84
|
+
|
85
|
+
// whale send underlying to farmers
|
86
|
+
await setupBalance();
|
87
|
+
});
|
88
|
+
|
89
|
+
describe("Happy path", function() {
|
90
|
+
it("Farmer should earn money", async function() {
|
91
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
92
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
93
|
+
|
94
|
+
let hours = 10;
|
95
|
+
let blocksPerHour = 200;
|
96
|
+
let oldSharePrice;
|
97
|
+
let newSharePrice;
|
98
|
+
|
99
|
+
for (let i = 0; i < hours; i++) {
|
100
|
+
console.log("loop ", i);
|
101
|
+
|
102
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
103
|
+
await controller.doHardWork(vault.address, { from: governance });
|
104
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
105
|
+
|
106
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
107
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
108
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
109
|
+
|
110
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
111
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
112
|
+
|
113
|
+
console.log("instant APR:", apr*100, "%");
|
114
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
115
|
+
|
116
|
+
await Utils.advanceNBlock(blocksPerHour);
|
117
|
+
}
|
118
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
119
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
120
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
121
|
+
|
122
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
123
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
124
|
+
|
125
|
+
console.log("earned!");
|
126
|
+
console.log("APR:", apr*100, "%");
|
127
|
+
console.log("APY:", (apy-1)*100, "%");
|
128
|
+
|
129
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
130
|
+
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
// Utilities
|
3
|
+
const Utils = require("../utilities/Utils.js");
|
4
|
+
const {
|
5
|
+
impersonates,
|
6
|
+
setupCoreProtocol,
|
7
|
+
depositVault,
|
8
|
+
} = require("../utilities/hh-utils.js");
|
9
|
+
|
10
|
+
const addresses = require("../test-config.js");
|
11
|
+
const BigNumber = require("bignumber.js");
|
12
|
+
const IERC20 = artifacts.require("IERC20");
|
13
|
+
|
14
|
+
//const Strategy = artifacts.require("");
|
15
|
+
const Strategy = artifacts.require("VenusFoldStrategyMainnet_ETH_lsd");
|
16
|
+
|
17
|
+
// Developed and tested at blockNumber 303586650
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Arbitrum Mainnet Venus Fold ETH lsd", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0x2021dA0831881CF4D1F38308214996B46c508A8A";
|
28
|
+
let xvs = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
|
29
|
+
let weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
30
|
+
|
31
|
+
// parties in the protocol
|
32
|
+
let governance;
|
33
|
+
let farmer1;
|
34
|
+
|
35
|
+
// numbers used in tests
|
36
|
+
let farmerBalance;
|
37
|
+
|
38
|
+
// Core protocol contracts
|
39
|
+
let controller;
|
40
|
+
let vault;
|
41
|
+
let strategy;
|
42
|
+
|
43
|
+
async function setupExternalContracts() {
|
44
|
+
underlying = await IERC20.at("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1");
|
45
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
46
|
+
}
|
47
|
+
|
48
|
+
async function setupBalance(){
|
49
|
+
let etherGiver = accounts[9];
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
51
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
52
|
+
|
53
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
54
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
55
|
+
}
|
56
|
+
|
57
|
+
before(async function() {
|
58
|
+
governance = addresses.Governance;
|
59
|
+
accounts = await web3.eth.getAccounts();
|
60
|
+
|
61
|
+
farmer1 = accounts[1];
|
62
|
+
|
63
|
+
// impersonate accounts
|
64
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
65
|
+
|
66
|
+
let etherGiver = accounts[9];
|
67
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
68
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
69
|
+
|
70
|
+
await setupExternalContracts();
|
71
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
72
|
+
"strategyArtifact": Strategy,
|
73
|
+
"strategyArtifactIsUpgradable": true,
|
74
|
+
"underlying": underlying,
|
75
|
+
"governance": governance,
|
76
|
+
"ULOwner": addresses.ULOwner,
|
77
|
+
// "liquidation": [
|
78
|
+
// {"uniV3": [xvs, weth]},
|
79
|
+
// ],
|
80
|
+
// "uniV3Fee": [
|
81
|
+
// [xvs, weth, '3000'],
|
82
|
+
// ]
|
83
|
+
});
|
84
|
+
|
85
|
+
// whale send underlying to farmers
|
86
|
+
await setupBalance();
|
87
|
+
});
|
88
|
+
|
89
|
+
describe("Happy path", function() {
|
90
|
+
it("Farmer should earn money", async function() {
|
91
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
92
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
93
|
+
|
94
|
+
let hours = 10;
|
95
|
+
let blocksPerHour = 200;
|
96
|
+
let oldSharePrice;
|
97
|
+
let newSharePrice;
|
98
|
+
|
99
|
+
for (let i = 0; i < hours; i++) {
|
100
|
+
console.log("loop ", i);
|
101
|
+
|
102
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
103
|
+
await controller.doHardWork(vault.address, { from: governance });
|
104
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
105
|
+
|
106
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
107
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
108
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
109
|
+
|
110
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
111
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
112
|
+
|
113
|
+
console.log("instant APR:", apr*100, "%");
|
114
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
115
|
+
|
116
|
+
await Utils.advanceNBlock(blocksPerHour);
|
117
|
+
}
|
118
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
119
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
120
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
121
|
+
|
122
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
123
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
124
|
+
|
125
|
+
console.log("earned!");
|
126
|
+
console.log("APR:", apr*100, "%");
|
127
|
+
console.log("APY:", (apy-1)*100, "%");
|
128
|
+
|
129
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
130
|
+
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
// Utilities
|
3
|
+
const Utils = require("../utilities/Utils.js");
|
4
|
+
const {
|
5
|
+
impersonates,
|
6
|
+
setupCoreProtocol,
|
7
|
+
depositVault,
|
8
|
+
} = require("../utilities/hh-utils.js");
|
9
|
+
|
10
|
+
const addresses = require("../test-config.js");
|
11
|
+
const BigNumber = require("bignumber.js");
|
12
|
+
const IERC20 = artifacts.require("IERC20");
|
13
|
+
|
14
|
+
//const Strategy = artifacts.require("");
|
15
|
+
const Strategy = artifacts.require("VenusFoldStrategyMainnet_USDC");
|
16
|
+
|
17
|
+
// Developed and tested at blockNumber 303586650
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Arbitrum Mainnet Venus Fold USDC", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0x1DDed46f6D34C3e34DA9f9e8Cf5B9B66f63e2C49";
|
28
|
+
let xvs = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
|
29
|
+
let weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
30
|
+
|
31
|
+
// parties in the protocol
|
32
|
+
let governance;
|
33
|
+
let farmer1;
|
34
|
+
|
35
|
+
// numbers used in tests
|
36
|
+
let farmerBalance;
|
37
|
+
|
38
|
+
// Core protocol contracts
|
39
|
+
let controller;
|
40
|
+
let vault;
|
41
|
+
let strategy;
|
42
|
+
|
43
|
+
async function setupExternalContracts() {
|
44
|
+
underlying = await IERC20.at("0xaf88d065e77c8cC2239327C5EDb3A432268e5831");
|
45
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
46
|
+
}
|
47
|
+
|
48
|
+
async function setupBalance(){
|
49
|
+
let etherGiver = accounts[9];
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
51
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
52
|
+
|
53
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
54
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
55
|
+
}
|
56
|
+
|
57
|
+
before(async function() {
|
58
|
+
governance = addresses.Governance;
|
59
|
+
accounts = await web3.eth.getAccounts();
|
60
|
+
|
61
|
+
farmer1 = accounts[1];
|
62
|
+
|
63
|
+
// impersonate accounts
|
64
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
65
|
+
|
66
|
+
let etherGiver = accounts[9];
|
67
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
68
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
69
|
+
|
70
|
+
await setupExternalContracts();
|
71
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
72
|
+
"strategyArtifact": Strategy,
|
73
|
+
"strategyArtifactIsUpgradable": true,
|
74
|
+
"underlying": underlying,
|
75
|
+
"governance": governance,
|
76
|
+
"ULOwner": addresses.ULOwner,
|
77
|
+
// "liquidation": [
|
78
|
+
// {"uniV3": [xvs, weth]},
|
79
|
+
// ],
|
80
|
+
// "uniV3Fee": [
|
81
|
+
// [xvs, weth, '3000'],
|
82
|
+
// ]
|
83
|
+
});
|
84
|
+
|
85
|
+
// whale send underlying to farmers
|
86
|
+
await setupBalance();
|
87
|
+
});
|
88
|
+
|
89
|
+
describe("Happy path", function() {
|
90
|
+
it("Farmer should earn money", async function() {
|
91
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
92
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
93
|
+
|
94
|
+
let hours = 10;
|
95
|
+
let blocksPerHour = 200;
|
96
|
+
let oldSharePrice;
|
97
|
+
let newSharePrice;
|
98
|
+
|
99
|
+
for (let i = 0; i < hours; i++) {
|
100
|
+
console.log("loop ", i);
|
101
|
+
|
102
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
103
|
+
await controller.doHardWork(vault.address, { from: governance });
|
104
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
105
|
+
|
106
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
107
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
108
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
109
|
+
|
110
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
111
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
112
|
+
|
113
|
+
console.log("instant APR:", apr*100, "%");
|
114
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
115
|
+
|
116
|
+
await Utils.advanceNBlock(blocksPerHour);
|
117
|
+
}
|
118
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
119
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
120
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
121
|
+
|
122
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
123
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
124
|
+
|
125
|
+
console.log("earned!");
|
126
|
+
console.log("APR:", apr*100, "%");
|
127
|
+
console.log("APY:", (apy-1)*100, "%");
|
128
|
+
|
129
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
130
|
+
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
// Utilities
|
3
|
+
const Utils = require("../utilities/Utils.js");
|
4
|
+
const {
|
5
|
+
impersonates,
|
6
|
+
setupCoreProtocol,
|
7
|
+
depositVault,
|
8
|
+
} = require("../utilities/hh-utils.js");
|
9
|
+
|
10
|
+
const addresses = require("../test-config.js");
|
11
|
+
const BigNumber = require("bignumber.js");
|
12
|
+
const IERC20 = artifacts.require("IERC20");
|
13
|
+
|
14
|
+
//const Strategy = artifacts.require("");
|
15
|
+
const Strategy = artifacts.require("VenusFoldStrategyMainnet_USDT");
|
16
|
+
|
17
|
+
// Developed and tested at blockNumber 303586650
|
18
|
+
|
19
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
20
|
+
describe("Arbitrum Mainnet Venus Fold USDT", function() {
|
21
|
+
let accounts;
|
22
|
+
|
23
|
+
// external contracts
|
24
|
+
let underlying;
|
25
|
+
|
26
|
+
// external setup
|
27
|
+
let underlyingWhale = "0x2aA31bf15CfD9b038Eff8214a98330D21C05d25F";
|
28
|
+
let xvs = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
|
29
|
+
let weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
30
|
+
|
31
|
+
// parties in the protocol
|
32
|
+
let governance;
|
33
|
+
let farmer1;
|
34
|
+
|
35
|
+
// numbers used in tests
|
36
|
+
let farmerBalance;
|
37
|
+
|
38
|
+
// Core protocol contracts
|
39
|
+
let controller;
|
40
|
+
let vault;
|
41
|
+
let strategy;
|
42
|
+
|
43
|
+
async function setupExternalContracts() {
|
44
|
+
underlying = await IERC20.at("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9");
|
45
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
46
|
+
}
|
47
|
+
|
48
|
+
async function setupBalance(){
|
49
|
+
let etherGiver = accounts[9];
|
50
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
51
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
52
|
+
|
53
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
54
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
55
|
+
}
|
56
|
+
|
57
|
+
before(async function() {
|
58
|
+
governance = addresses.Governance;
|
59
|
+
accounts = await web3.eth.getAccounts();
|
60
|
+
|
61
|
+
farmer1 = accounts[1];
|
62
|
+
|
63
|
+
// impersonate accounts
|
64
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
65
|
+
|
66
|
+
let etherGiver = accounts[9];
|
67
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
68
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: addresses.ULOwner, value: 10e18});
|
69
|
+
|
70
|
+
await setupExternalContracts();
|
71
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
72
|
+
"strategyArtifact": Strategy,
|
73
|
+
"strategyArtifactIsUpgradable": true,
|
74
|
+
"underlying": underlying,
|
75
|
+
"governance": governance,
|
76
|
+
"ULOwner": addresses.ULOwner,
|
77
|
+
// "liquidation": [
|
78
|
+
// {"uniV3": [xvs, weth]},
|
79
|
+
// ],
|
80
|
+
// "uniV3Fee": [
|
81
|
+
// [xvs, weth, '3000'],
|
82
|
+
// ]
|
83
|
+
});
|
84
|
+
|
85
|
+
// whale send underlying to farmers
|
86
|
+
await setupBalance();
|
87
|
+
});
|
88
|
+
|
89
|
+
describe("Happy path", function() {
|
90
|
+
it("Farmer should earn money", async function() {
|
91
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
92
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
93
|
+
|
94
|
+
let hours = 10;
|
95
|
+
let blocksPerHour = 200;
|
96
|
+
let oldSharePrice;
|
97
|
+
let newSharePrice;
|
98
|
+
|
99
|
+
for (let i = 0; i < hours; i++) {
|
100
|
+
console.log("loop ", i);
|
101
|
+
|
102
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
103
|
+
await controller.doHardWork(vault.address, { from: governance });
|
104
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
105
|
+
|
106
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
107
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
108
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
109
|
+
|
110
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
111
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
112
|
+
|
113
|
+
console.log("instant APR:", apr*100, "%");
|
114
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
115
|
+
|
116
|
+
await Utils.advanceNBlock(blocksPerHour);
|
117
|
+
}
|
118
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
119
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
120
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
121
|
+
|
122
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
123
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
124
|
+
|
125
|
+
console.log("earned!");
|
126
|
+
console.log("APR:", apr*100, "%");
|
127
|
+
console.log("APY:", (apy-1)*100, "%");
|
128
|
+
|
129
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
130
|
+
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|