@harvest-finance/harvest-strategy-arbitrum 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-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 +38 -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,125 @@
|
|
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 { send } = require("@openzeppelin/test-helpers");
|
12
|
+
const BigNumber = require("bignumber.js");
|
13
|
+
const IERC20 = artifacts.require("IERC20");
|
14
|
+
|
15
|
+
//const Strategy = artifacts.require("");
|
16
|
+
const Strategy = artifacts.require("CamelotV3StrategyMainnet_ETH_USDC");
|
17
|
+
|
18
|
+
// Developed and tested at blockNumber 286690500
|
19
|
+
|
20
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
21
|
+
describe("Arbitrum Mainnet Camelot V3 ETH-USDC", function() {
|
22
|
+
let accounts;
|
23
|
+
|
24
|
+
// external contracts
|
25
|
+
let underlying;
|
26
|
+
|
27
|
+
// external setup
|
28
|
+
let underlyingWhale = "0xc313B6B8fb7ED5E092C44375F928C40439278fEF";
|
29
|
+
|
30
|
+
// parties in the protocol
|
31
|
+
let governance;
|
32
|
+
let farmer1;
|
33
|
+
|
34
|
+
// numbers used in tests
|
35
|
+
let farmerBalance;
|
36
|
+
|
37
|
+
// Core protocol contracts
|
38
|
+
let controller;
|
39
|
+
let vault;
|
40
|
+
let strategy;
|
41
|
+
|
42
|
+
async function setupExternalContracts() {
|
43
|
+
underlying = await IERC20.at("0xd7Ef5Ac7fd4AAA7994F3bc1D273eAb1d1013530E");
|
44
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
53
|
+
}
|
54
|
+
|
55
|
+
before(async function() {
|
56
|
+
governance = addresses.Governance;
|
57
|
+
accounts = await web3.eth.getAccounts();
|
58
|
+
|
59
|
+
farmer1 = accounts[1];
|
60
|
+
|
61
|
+
// impersonate accounts
|
62
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
63
|
+
|
64
|
+
let etherGiver = accounts[9];
|
65
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
66
|
+
|
67
|
+
await setupExternalContracts();
|
68
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
69
|
+
"existingVaultAddress": "0x7f7e98E5FA2ef1dE3b747b55dd81f73960Ce92C2",
|
70
|
+
"announceStrategy": true,
|
71
|
+
"strategyArtifact": Strategy,
|
72
|
+
"strategyArtifactIsUpgradable": true,
|
73
|
+
"underlying": underlying,
|
74
|
+
"governance": governance,
|
75
|
+
});
|
76
|
+
|
77
|
+
// whale send underlying to farmers
|
78
|
+
await setupBalance();
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("Happy path", function() {
|
82
|
+
it("Farmer should earn money", async function() {
|
83
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
84
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
85
|
+
|
86
|
+
let hours = 10;
|
87
|
+
let blocksPerHour = 3600;
|
88
|
+
let oldSharePrice;
|
89
|
+
let newSharePrice;
|
90
|
+
|
91
|
+
for (let i = 0; i < hours; i++) {
|
92
|
+
console.log("loop ", i);
|
93
|
+
|
94
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
95
|
+
await controller.doHardWork(vault.address, { from: governance });
|
96
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
97
|
+
|
98
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
99
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
100
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
101
|
+
|
102
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
103
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
104
|
+
|
105
|
+
console.log("instant APR:", apr*100, "%");
|
106
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
107
|
+
|
108
|
+
await Utils.advanceNBlock(blocksPerHour);
|
109
|
+
}
|
110
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
111
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
112
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
113
|
+
|
114
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
115
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
116
|
+
|
117
|
+
console.log("earned!");
|
118
|
+
console.log("APR:", apr*100, "%");
|
119
|
+
console.log("APY:", (apy-1)*100, "%");
|
120
|
+
|
121
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
122
|
+
|
123
|
+
});
|
124
|
+
});
|
125
|
+
});
|
@@ -0,0 +1,125 @@
|
|
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 { send } = require("@openzeppelin/test-helpers");
|
12
|
+
const BigNumber = require("bignumber.js");
|
13
|
+
const IERC20 = artifacts.require("IERC20");
|
14
|
+
|
15
|
+
//const Strategy = artifacts.require("");
|
16
|
+
const Strategy = artifacts.require("CamelotV3StrategyMainnet_ETH_USDT");
|
17
|
+
|
18
|
+
// Developed and tested at blockNumber 286690500
|
19
|
+
|
20
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
21
|
+
describe("Arbitrum Mainnet Camelot V3 ETH-USDT", function() {
|
22
|
+
let accounts;
|
23
|
+
|
24
|
+
// external contracts
|
25
|
+
let underlying;
|
26
|
+
|
27
|
+
// external setup
|
28
|
+
let underlyingWhale = "0x4717ae9b852E7102aE147401dd1E03A343BAbe23";
|
29
|
+
|
30
|
+
// parties in the protocol
|
31
|
+
let governance;
|
32
|
+
let farmer1;
|
33
|
+
|
34
|
+
// numbers used in tests
|
35
|
+
let farmerBalance;
|
36
|
+
|
37
|
+
// Core protocol contracts
|
38
|
+
let controller;
|
39
|
+
let vault;
|
40
|
+
let strategy;
|
41
|
+
|
42
|
+
async function setupExternalContracts() {
|
43
|
+
underlying = await IERC20.at("0x9330e26b5Fc0b7c417C6bD901528d5c65BE5cdf2");
|
44
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
53
|
+
}
|
54
|
+
|
55
|
+
before(async function() {
|
56
|
+
governance = addresses.Governance;
|
57
|
+
accounts = await web3.eth.getAccounts();
|
58
|
+
|
59
|
+
farmer1 = accounts[1];
|
60
|
+
|
61
|
+
// impersonate accounts
|
62
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
63
|
+
|
64
|
+
let etherGiver = accounts[9];
|
65
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
66
|
+
|
67
|
+
await setupExternalContracts();
|
68
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
69
|
+
"existingVaultAddress": "0x6aDEBe9a4c8dF4E6BFd09263Ab7e2EdF67288763",
|
70
|
+
"announceStrategy": true,
|
71
|
+
"strategyArtifact": Strategy,
|
72
|
+
"strategyArtifactIsUpgradable": true,
|
73
|
+
"underlying": underlying,
|
74
|
+
"governance": governance,
|
75
|
+
});
|
76
|
+
|
77
|
+
// whale send underlying to farmers
|
78
|
+
await setupBalance();
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("Happy path", function() {
|
82
|
+
it("Farmer should earn money", async function() {
|
83
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
84
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
85
|
+
|
86
|
+
let hours = 10;
|
87
|
+
let blocksPerHour = 3600;
|
88
|
+
let oldSharePrice;
|
89
|
+
let newSharePrice;
|
90
|
+
|
91
|
+
for (let i = 0; i < hours; i++) {
|
92
|
+
console.log("loop ", i);
|
93
|
+
|
94
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
95
|
+
await controller.doHardWork(vault.address, { from: governance });
|
96
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
97
|
+
|
98
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
99
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
100
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
101
|
+
|
102
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
103
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
104
|
+
|
105
|
+
console.log("instant APR:", apr*100, "%");
|
106
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
107
|
+
|
108
|
+
await Utils.advanceNBlock(blocksPerHour);
|
109
|
+
}
|
110
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
111
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
112
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
113
|
+
|
114
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
115
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
116
|
+
|
117
|
+
console.log("earned!");
|
118
|
+
console.log("APR:", apr*100, "%");
|
119
|
+
console.log("APY:", (apy-1)*100, "%");
|
120
|
+
|
121
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
122
|
+
|
123
|
+
});
|
124
|
+
});
|
125
|
+
});
|
@@ -0,0 +1,125 @@
|
|
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 { send } = require("@openzeppelin/test-helpers");
|
12
|
+
const BigNumber = require("bignumber.js");
|
13
|
+
const IERC20 = artifacts.require("IERC20");
|
14
|
+
|
15
|
+
//const Strategy = artifacts.require("");
|
16
|
+
const Strategy = artifacts.require("CamelotV3StrategyMainnet_GMX_ETH");
|
17
|
+
|
18
|
+
// Developed and tested at blockNumber 286690500
|
19
|
+
|
20
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
21
|
+
describe("Arbitrum Mainnet Camelot V3 GMX-ETH", function() {
|
22
|
+
let accounts;
|
23
|
+
|
24
|
+
// external contracts
|
25
|
+
let underlying;
|
26
|
+
|
27
|
+
// external setup
|
28
|
+
let underlyingWhale = "0xC54595E2CD49d353139c1668380ca2E9A4Fb62Fb";
|
29
|
+
|
30
|
+
// parties in the protocol
|
31
|
+
let governance;
|
32
|
+
let farmer1;
|
33
|
+
|
34
|
+
// numbers used in tests
|
35
|
+
let farmerBalance;
|
36
|
+
|
37
|
+
// Core protocol contracts
|
38
|
+
let controller;
|
39
|
+
let vault;
|
40
|
+
let strategy;
|
41
|
+
|
42
|
+
async function setupExternalContracts() {
|
43
|
+
underlying = await IERC20.at("0x9bdb8335619bA4E20Bea1321f8E32f45fD6e6e22");
|
44
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
53
|
+
}
|
54
|
+
|
55
|
+
before(async function() {
|
56
|
+
governance = addresses.Governance;
|
57
|
+
accounts = await web3.eth.getAccounts();
|
58
|
+
|
59
|
+
farmer1 = accounts[1];
|
60
|
+
|
61
|
+
// impersonate accounts
|
62
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
63
|
+
|
64
|
+
let etherGiver = accounts[9];
|
65
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
66
|
+
|
67
|
+
await setupExternalContracts();
|
68
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
69
|
+
"existingVaultAddress": "0x0ffDC684cb69FaE92F26631614f9d6632bb658A8",
|
70
|
+
"announceStrategy": true,
|
71
|
+
"strategyArtifact": Strategy,
|
72
|
+
"strategyArtifactIsUpgradable": true,
|
73
|
+
"underlying": underlying,
|
74
|
+
"governance": governance,
|
75
|
+
});
|
76
|
+
|
77
|
+
// whale send underlying to farmers
|
78
|
+
await setupBalance();
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("Happy path", function() {
|
82
|
+
it("Farmer should earn money", async function() {
|
83
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
84
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
85
|
+
|
86
|
+
let hours = 10;
|
87
|
+
let blocksPerHour = 3600;
|
88
|
+
let oldSharePrice;
|
89
|
+
let newSharePrice;
|
90
|
+
|
91
|
+
for (let i = 0; i < hours; i++) {
|
92
|
+
console.log("loop ", i);
|
93
|
+
|
94
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
95
|
+
await controller.doHardWork(vault.address, { from: governance });
|
96
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
97
|
+
|
98
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
99
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
100
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
101
|
+
|
102
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
103
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
104
|
+
|
105
|
+
console.log("instant APR:", apr*100, "%");
|
106
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
107
|
+
|
108
|
+
await Utils.advanceNBlock(blocksPerHour);
|
109
|
+
}
|
110
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
111
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
112
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
113
|
+
|
114
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
115
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
116
|
+
|
117
|
+
console.log("earned!");
|
118
|
+
console.log("APR:", apr*100, "%");
|
119
|
+
console.log("APY:", (apy-1)*100, "%");
|
120
|
+
|
121
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
122
|
+
|
123
|
+
});
|
124
|
+
});
|
125
|
+
});
|
@@ -0,0 +1,125 @@
|
|
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 { send } = require("@openzeppelin/test-helpers");
|
12
|
+
const BigNumber = require("bignumber.js");
|
13
|
+
const IERC20 = artifacts.require("IERC20");
|
14
|
+
|
15
|
+
//const Strategy = artifacts.require("");
|
16
|
+
const Strategy = artifacts.require("CamelotV3StrategyMainnet_GRAIL_ETH");
|
17
|
+
|
18
|
+
// Developed and tested at blockNumber 286693815
|
19
|
+
|
20
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
21
|
+
describe("Arbitrum Mainnet Camelot V3 GRAIL-ETH", function() {
|
22
|
+
let accounts;
|
23
|
+
|
24
|
+
// external contracts
|
25
|
+
let underlying;
|
26
|
+
|
27
|
+
// external setup
|
28
|
+
let underlyingWhale = "0xF1527Cb2D748f38A324f273Bf499cE25Ff400304";
|
29
|
+
|
30
|
+
// parties in the protocol
|
31
|
+
let governance;
|
32
|
+
let farmer1;
|
33
|
+
|
34
|
+
// numbers used in tests
|
35
|
+
let farmerBalance;
|
36
|
+
|
37
|
+
// Core protocol contracts
|
38
|
+
let controller;
|
39
|
+
let vault;
|
40
|
+
let strategy;
|
41
|
+
|
42
|
+
async function setupExternalContracts() {
|
43
|
+
underlying = await IERC20.at("0x97D81162B96D57476CcF170595a39c1DC76676c9");
|
44
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
53
|
+
}
|
54
|
+
|
55
|
+
before(async function() {
|
56
|
+
governance = addresses.Governance;
|
57
|
+
accounts = await web3.eth.getAccounts();
|
58
|
+
|
59
|
+
farmer1 = accounts[1];
|
60
|
+
|
61
|
+
// impersonate accounts
|
62
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
63
|
+
|
64
|
+
let etherGiver = accounts[9];
|
65
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
66
|
+
|
67
|
+
await setupExternalContracts();
|
68
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
69
|
+
"existingVaultAddress": "0xd3Fa687F1F6E2384Ef92873Bed87533483a2ab37",
|
70
|
+
"announceStrategy": true,
|
71
|
+
"strategyArtifact": Strategy,
|
72
|
+
"strategyArtifactIsUpgradable": true,
|
73
|
+
"underlying": underlying,
|
74
|
+
"governance": governance,
|
75
|
+
});
|
76
|
+
|
77
|
+
// whale send underlying to farmers
|
78
|
+
await setupBalance();
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("Happy path", function() {
|
82
|
+
it("Farmer should earn money", async function() {
|
83
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
84
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
85
|
+
|
86
|
+
let hours = 10;
|
87
|
+
let blocksPerHour = 3600;
|
88
|
+
let oldSharePrice;
|
89
|
+
let newSharePrice;
|
90
|
+
|
91
|
+
for (let i = 0; i < hours; i++) {
|
92
|
+
console.log("loop ", i);
|
93
|
+
|
94
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
95
|
+
await controller.doHardWork(vault.address, { from: governance });
|
96
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
97
|
+
|
98
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
99
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
100
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
101
|
+
|
102
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
103
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
104
|
+
|
105
|
+
console.log("instant APR:", apr*100, "%");
|
106
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
107
|
+
|
108
|
+
await Utils.advanceNBlock(blocksPerHour);
|
109
|
+
}
|
110
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
111
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
112
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
113
|
+
|
114
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
115
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
116
|
+
|
117
|
+
console.log("earned!");
|
118
|
+
console.log("APR:", apr*100, "%");
|
119
|
+
console.log("APY:", (apy-1)*100, "%");
|
120
|
+
|
121
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
122
|
+
|
123
|
+
});
|
124
|
+
});
|
125
|
+
});
|
@@ -0,0 +1,125 @@
|
|
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 { send } = require("@openzeppelin/test-helpers");
|
12
|
+
const BigNumber = require("bignumber.js");
|
13
|
+
const IERC20 = artifacts.require("IERC20");
|
14
|
+
|
15
|
+
//const Strategy = artifacts.require("");
|
16
|
+
const Strategy = artifacts.require("CamelotV3StrategyMainnet_USDC_USDT");
|
17
|
+
|
18
|
+
// Developed and tested at blockNumber 286693815
|
19
|
+
|
20
|
+
// Vanilla Mocha test. Increased compatibility with tools that integrate Mocha.
|
21
|
+
describe("Arbitrum Mainnet Camelot V3 USDC-USDT", function() {
|
22
|
+
let accounts;
|
23
|
+
|
24
|
+
// external contracts
|
25
|
+
let underlying;
|
26
|
+
|
27
|
+
// external setup
|
28
|
+
let underlyingWhale = "0x0DbF24637f2D82f448cB2cc58B7c72aa7226E47d";
|
29
|
+
|
30
|
+
// parties in the protocol
|
31
|
+
let governance;
|
32
|
+
let farmer1;
|
33
|
+
|
34
|
+
// numbers used in tests
|
35
|
+
let farmerBalance;
|
36
|
+
|
37
|
+
// Core protocol contracts
|
38
|
+
let controller;
|
39
|
+
let vault;
|
40
|
+
let strategy;
|
41
|
+
|
42
|
+
async function setupExternalContracts() {
|
43
|
+
underlying = await IERC20.at("0xf662d78C79F6a3a6Fa70160fcE1085A9218D114e");
|
44
|
+
console.log("Fetching Underlying at: ", underlying.address);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function setupBalance(){
|
48
|
+
let etherGiver = accounts[9];
|
49
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: underlyingWhale, value: 10e18});
|
50
|
+
|
51
|
+
farmerBalance = await underlying.balanceOf(underlyingWhale);
|
52
|
+
await underlying.transfer(farmer1, farmerBalance, { from: underlyingWhale });
|
53
|
+
}
|
54
|
+
|
55
|
+
before(async function() {
|
56
|
+
governance = addresses.Governance;
|
57
|
+
accounts = await web3.eth.getAccounts();
|
58
|
+
|
59
|
+
farmer1 = accounts[1];
|
60
|
+
|
61
|
+
// impersonate accounts
|
62
|
+
await impersonates([governance, underlyingWhale, addresses.ULOwner]);
|
63
|
+
|
64
|
+
let etherGiver = accounts[9];
|
65
|
+
await web3.eth.sendTransaction({ from: etherGiver, to: governance, value: 10e18});
|
66
|
+
|
67
|
+
await setupExternalContracts();
|
68
|
+
[controller, vault, strategy] = await setupCoreProtocol({
|
69
|
+
"existingVaultAddress": "0x64769B9469A3F859320aD1811f08AbF6ACA5E991",
|
70
|
+
"announceStrategy": true,
|
71
|
+
"strategyArtifact": Strategy,
|
72
|
+
"strategyArtifactIsUpgradable": true,
|
73
|
+
"underlying": underlying,
|
74
|
+
"governance": governance,
|
75
|
+
});
|
76
|
+
|
77
|
+
// whale send underlying to farmers
|
78
|
+
await setupBalance();
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("Happy path", function() {
|
82
|
+
it("Farmer should earn money", async function() {
|
83
|
+
let farmerOldBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
84
|
+
await depositVault(farmer1, underlying, vault, farmerBalance);
|
85
|
+
|
86
|
+
let hours = 10;
|
87
|
+
let blocksPerHour = 3600;
|
88
|
+
let oldSharePrice;
|
89
|
+
let newSharePrice;
|
90
|
+
|
91
|
+
for (let i = 0; i < hours; i++) {
|
92
|
+
console.log("loop ", i);
|
93
|
+
|
94
|
+
oldSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
95
|
+
await controller.doHardWork(vault.address, { from: governance });
|
96
|
+
newSharePrice = new BigNumber(await vault.getPricePerFullShare());
|
97
|
+
|
98
|
+
console.log("old shareprice: ", oldSharePrice.toFixed());
|
99
|
+
console.log("new shareprice: ", newSharePrice.toFixed());
|
100
|
+
console.log("growth: ", newSharePrice.toFixed() / oldSharePrice.toFixed());
|
101
|
+
|
102
|
+
apr = (newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))*365;
|
103
|
+
apy = ((newSharePrice.toFixed()/oldSharePrice.toFixed()-1)*(24/(blocksPerHour/300))+1)**365;
|
104
|
+
|
105
|
+
console.log("instant APR:", apr*100, "%");
|
106
|
+
console.log("instant APY:", (apy-1)*100, "%");
|
107
|
+
|
108
|
+
await Utils.advanceNBlock(blocksPerHour);
|
109
|
+
}
|
110
|
+
await vault.withdraw(new BigNumber(await vault.balanceOf(farmer1)).toFixed(), { from: farmer1 });
|
111
|
+
let farmerNewBalance = new BigNumber(await underlying.balanceOf(farmer1));
|
112
|
+
Utils.assertBNGt(farmerNewBalance, farmerOldBalance);
|
113
|
+
|
114
|
+
apr = (farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))*365;
|
115
|
+
apy = ((farmerNewBalance.toFixed()/farmerOldBalance.toFixed()-1)*(24/(blocksPerHour*hours/300))+1)**365;
|
116
|
+
|
117
|
+
console.log("earned!");
|
118
|
+
console.log("APR:", apr*100, "%");
|
119
|
+
console.log("APY:", (apy-1)*100, "%");
|
120
|
+
|
121
|
+
await strategy.withdrawAllToVault({from:governance}); // making sure can withdraw all for a next switch
|
122
|
+
|
123
|
+
});
|
124
|
+
});
|
125
|
+
});
|