@dhedge/v2-sdk 1.9.3 → 1.9.5

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.
@@ -0,0 +1,190 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { Dhedge, Pool } from "..";
4
+ import { routerAddress } from "../config";
5
+ import { Dapp, Network } from "../types";
6
+ import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
7
+ import {
8
+ TestingRunParams,
9
+ beforeAfterReset,
10
+ testingHelper
11
+ } from "./utils/testingHelper";
12
+ import { allowanceDelta, balanceDelta } from "./utils/token";
13
+ import { getWalletData } from "./wallet";
14
+
15
+ const testRamses = ({ network, provider }: TestingRunParams) => {
16
+ const USDC_swETH_Lp = "0xf1a5444a7ed5f24962a118512b076a015b0e6c0b";
17
+ const USDC_swETH_Gauge = "0x9765cdaec6395b04737edc22c5b3e7d85677328a";
18
+ const RAM = "0xaaa6c1e32c55a7bfa8066a6fae9b42650f262418";
19
+ const xoRAM = "0xaaa1ee8dc1864ae49185c368e8c64dd780a50fb7";
20
+
21
+ const USDC = CONTRACT_ADDRESS[network].USDC;
22
+ const SWETH = CONTRACT_ADDRESS[network].SWETH;
23
+
24
+ let dhedge: Dhedge;
25
+ let pool: Pool;
26
+ jest.setTimeout(100000);
27
+
28
+ describe(`[${network}] ramses tests`, () => {
29
+ beforeAll(async () => {
30
+ const { wallet } = getWalletData(network);
31
+ // top up ETH (gas)
32
+ await provider.send("hardhat_setBalance", [
33
+ wallet.address,
34
+ "0x100000000000000"
35
+ ]);
36
+ dhedge = new Dhedge(wallet, network);
37
+ pool = await dhedge.loadPool(TEST_POOL[network]);
38
+ await pool.trade(Dapp.ONEINCH, USDC, SWETH, (5 * 1e6).toString());
39
+ });
40
+ beforeAfterReset({ beforeAll, afterAll, provider });
41
+
42
+ it("approves unlimited USDC and swETH on for Ramses", async () => {
43
+ await pool.approve(Dapp.RAMSES, USDC, MAX_AMOUNT);
44
+ await pool.approve(Dapp.RAMSES, SWETH, MAX_AMOUNT);
45
+ const UsdcAllowanceDelta = await allowanceDelta(
46
+ pool.address,
47
+ USDC,
48
+ routerAddress[network].ramses!,
49
+ pool.signer
50
+ );
51
+ await expect(UsdcAllowanceDelta.gt(0));
52
+ });
53
+
54
+ it("adds USDC and swETH to a Ramses volatile pool", async () => {
55
+ const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
56
+ const swethBalance = await pool.utils.getBalance(SWETH, pool.address);
57
+ await pool.addLiquidityV2(
58
+ Dapp.RAMSES,
59
+ USDC,
60
+ SWETH,
61
+ usdcBalance,
62
+ swethBalance,
63
+ false
64
+ );
65
+
66
+ const lpTokenDelta = await balanceDelta(
67
+ pool.address,
68
+ USDC_swETH_Lp,
69
+ pool.signer
70
+ );
71
+ expect(lpTokenDelta.gt(0));
72
+ });
73
+
74
+ it("should stake USDC-swETH LP in a gauge", async () => {
75
+ const balance = await dhedge.utils.getBalance(
76
+ USDC_swETH_Lp,
77
+ pool.address
78
+ );
79
+ await pool.approveSpender(USDC_swETH_Gauge, USDC_swETH_Lp, MAX_AMOUNT);
80
+ await pool.stakeInGauge(Dapp.RAMSES, USDC_swETH_Gauge, balance);
81
+ const gaugeBalance = await balanceDelta(
82
+ pool.address,
83
+ USDC_swETH_Gauge,
84
+ pool.signer
85
+ );
86
+ expect(gaugeBalance.gt(0));
87
+ });
88
+
89
+ it("should claim rewards from Gauge", async () => {
90
+ await provider.send("evm_increaseTime", [24 * 60 * 60]); // 1 day
91
+ await provider.send("evm_mine", []);
92
+ const claimTx = await pool.claimFees(Dapp.RAMSES, USDC_swETH_Gauge);
93
+ expect(claimTx).not.toBe(null);
94
+ const ramBalanceDelta = await balanceDelta(
95
+ pool.address,
96
+ RAM,
97
+ pool.signer
98
+ );
99
+ const xoRamBalanceDelta = await balanceDelta(
100
+ pool.address,
101
+ xoRAM,
102
+ pool.signer
103
+ );
104
+ expect(ramBalanceDelta.gt(0));
105
+ expect(xoRamBalanceDelta.gt(0));
106
+ });
107
+
108
+ it("createVest for xoRAM", async () => {
109
+ const xoRAMBalanceBefore = await dhedge.utils.getBalance(
110
+ xoRAM,
111
+ pool.address
112
+ );
113
+ expect(xoRAMBalanceBefore.gt(0));
114
+ const vestTx = await pool.vestTokens(xoRAM, xoRAMBalanceBefore);
115
+ expect(vestTx).not.toBe(null);
116
+ const xoRAMBalanceAfter = await dhedge.utils.getBalance(
117
+ xoRAM,
118
+ pool.address
119
+ );
120
+ expect(xoRAMBalanceAfter.eq(0));
121
+ });
122
+
123
+ it("exitVest for xoRAM", async () => {
124
+ await provider.send("evm_increaseTime", [3600 * 24 * 90]); // 90 days
125
+ await provider.send("evm_mine", []);
126
+
127
+ const ramBalanceBefore = await dhedge.utils.getBalance(RAM, pool.address);
128
+
129
+ const exitvestTx = await pool.exitVestedToken(xoRAM, 0);
130
+ const xoRAMBalanceAfter = await dhedge.utils.getBalance(
131
+ USDC_swETH_Gauge,
132
+ pool.address
133
+ );
134
+ expect(exitvestTx).not.toBe(null);
135
+ const ramBalanceAfter = await dhedge.utils.getBalance(RAM, pool.address);
136
+ expect(xoRAMBalanceAfter.eq(0));
137
+ expect(ramBalanceAfter.gt(ramBalanceBefore));
138
+ });
139
+
140
+ it("should unStake USDC-swETH LP from a gauge", async () => {
141
+ const gaugeBalance = await dhedge.utils.getBalance(
142
+ USDC_swETH_Gauge,
143
+ pool.address
144
+ );
145
+ await pool.unstakeFromGauge(USDC_swETH_Gauge, gaugeBalance);
146
+ const lpTokenDelta = await balanceDelta(
147
+ pool.address,
148
+ USDC_swETH_Lp,
149
+ pool.signer
150
+ );
151
+ expect(lpTokenDelta.gt(0));
152
+ });
153
+
154
+ it("approves unlimited USDC/swETH LP for Ramses", async () => {
155
+ await pool.approve(Dapp.RAMSES, USDC_swETH_Lp, MAX_AMOUNT);
156
+ const lpAllowanceDelta = await allowanceDelta(
157
+ pool.address,
158
+ USDC_swETH_Lp,
159
+ routerAddress[network].ramses!,
160
+ pool.signer
161
+ );
162
+ expect(lpAllowanceDelta.gt(0));
163
+ });
164
+
165
+ it("should remove all liquidity from an existing pool ", async () => {
166
+ const balance = await dhedge.utils.getBalance(
167
+ USDC_swETH_Lp,
168
+ pool.address
169
+ );
170
+ await pool.removeLiquidityV2(Dapp.RAMSES, USDC, SWETH, balance, false);
171
+ const usdcBalanceDelta = await balanceDelta(
172
+ pool.address,
173
+ USDC,
174
+ pool.signer
175
+ );
176
+ const swETHBalanceDelta = await balanceDelta(
177
+ pool.address,
178
+ SWETH,
179
+ pool.signer
180
+ );
181
+ expect(usdcBalanceDelta.gt(0));
182
+ expect(swETHBalanceDelta.gt(0));
183
+ });
184
+ });
185
+ };
186
+
187
+ testingHelper({
188
+ network: Network.ARBITRUM,
189
+ testingRun: testRamses
190
+ });
@@ -6,6 +6,8 @@ import { TEST_POOL } from "./constants";
6
6
 
7
7
  import { wallet } from "./wallet";
8
8
 
9
+ const TEST_POOL_OP = TEST_POOL.optimism;
10
+
9
11
  let dhedge: Dhedge;
10
12
  let options: any;
11
13
  jest.setTimeout(100000);
@@ -18,7 +20,7 @@ describe("pool", () => {
18
20
  });
19
21
 
20
22
  it("should swap sETH into sUSD on Synthetix", async () => {
21
- const pool = await dhedge.loadPool(TEST_POOL);
23
+ const pool = await dhedge.loadPool(TEST_POOL_OP);
22
24
  const result = await pool.trade(
23
25
  Dapp.SYNTHETIX,
24
26
  "sETH",
@@ -5,156 +5,188 @@ import { routerAddress } from "../config";
5
5
  import { Dapp, Network } from "../types";
6
6
  import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
7
7
  import { allowanceDelta, balanceDelta } from "./utils/token";
8
-
9
- import { wallet } from "./wallet";
10
-
11
- let dhedge: Dhedge;
12
- let pool: Pool;
13
- jest.setTimeout(100000);
14
-
15
- const network = Network.POLYGON;
16
-
17
- describe("pool", () => {
18
- beforeAll(async () => {
19
- dhedge = new Dhedge(wallet, network);
20
- pool = await dhedge.loadPool(TEST_POOL[network]);
8
+ import {
9
+ setUSDCAmount,
10
+ testingHelper,
11
+ TestingRunParams
12
+ } from "./utils/testingHelper";
13
+ import BigNumber from "bignumber.js";
14
+
15
+ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
16
+ let dhedge: Dhedge;
17
+ let pool: Pool;
18
+
19
+ jest.setTimeout(100000);
20
+ describe(`testUniswapV3 on ${network}`, () => {
21
+ beforeAll(async () => {
22
+ dhedge = new Dhedge(wallet, network);
23
+ pool = await dhedge.loadPool(TEST_POOL[network]);
24
+
25
+ // top up gas
26
+ await provider.send("hardhat_setBalance", [
27
+ wallet.address,
28
+ "0x10000000000000000"
29
+ ]);
30
+ await provider.send("evm_mine", []);
31
+ await setUSDCAmount({
32
+ amount: new BigNumber(100).times(1e18).toFixed(0),
33
+ userAddress: pool.address,
34
+ network,
35
+ provider
36
+ });
37
+ });
38
+
39
+ it("approves unlimited USDC on for trading on UniswapV3", async () => {
40
+ await pool.approve(
41
+ Dapp.UNISWAPV3,
42
+ CONTRACT_ADDRESS[network].USDC,
43
+ ethers.constants.MaxUint256
44
+ );
45
+ const UsdcAllowanceDelta = await allowanceDelta(
46
+ pool.address,
47
+ CONTRACT_ADDRESS[network].USDC,
48
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
49
+ routerAddress[network].uniswapV3!,
50
+ pool.signer
51
+ );
52
+ expect(UsdcAllowanceDelta.gte(0));
53
+ });
54
+
55
+ it("should swap 5 USDC into WETH on UniswapV3", async () => {
56
+ await pool.tradeUniswapV3(
57
+ CONTRACT_ADDRESS[network].USDC,
58
+ CONTRACT_ADDRESS[network].WETH,
59
+ "5000000",
60
+ FeeAmount.LOW,
61
+ 0.5
62
+ );
63
+
64
+ const wethAllowanceDelta = await balanceDelta(
65
+ pool.address,
66
+ CONTRACT_ADDRESS[network].WETH,
67
+ pool.signer
68
+ );
69
+ expect(wethAllowanceDelta.gt(0));
70
+ });
71
+
72
+ // it("approves unlimited WETH on for UniswapV3 LP", async () => {
73
+ // await pool.approveUniswapV3Liquidity(
74
+ // CONTRACT_ADDRESS[network].USDC,
75
+ // ethers.constants.MaxInt256
76
+ // );
77
+ // const UsdcAllowanceDelta = await allowanceDelta(
78
+ // pool.address,
79
+ // CONTRACT_ADDRESS[network].USDC,
80
+ // pool.address,
81
+ // pool.signer
82
+ // );
83
+
84
+ // expect(result).not.toBe(null);
85
+ // });
86
+
87
+ // it("adds WETH and WBTC to a new V3 pool", async () => {
88
+ // let result;
89
+ // const pool = await dhedge.loadPool(TEST_POOL);
90
+ // const usdcBalance = await dhedge.utils.getBalance(USDC, pool.address);
91
+ // const wethBalance = await dhedge.utils.getBalance(WETH, pool.address);
92
+
93
+ // try {
94
+ // result = await pool.addLiquidityUniswapV3(
95
+ // USDC,
96
+ // WETH,
97
+ // usdcBalance,
98
+ // wethBalance,
99
+ // 0.0003,
100
+ // 0.0004,
101
+ // null,
102
+ // null,
103
+ // FeeAmount.LOW,
104
+ // options
105
+ // );
106
+ // console.log(result);
107
+ // } catch (e) {
108
+ // console.log(e);
109
+ // }
110
+ // expect(result).not.toBe(null);
111
+ // });
112
+
113
+ // it("should remove liquidity from an existing pool ", async () => {
114
+ // const pool = await dhedge.loadPool(TEST_POOL);
115
+ // const result = await pool.decreaseLiquidity(
116
+ // Dapp.UNISWAPV3,
117
+ // "110507",
118
+ // 100,
119
+ // options
120
+ // );
121
+ // console.log("result", result);
122
+ // expect(result).not.toBe(null);
123
+ // });
124
+
125
+ // it("should increase liquidity in an existing pool WETH/WBTC pool", async () => {
126
+ // const pool = await dhedge.loadPool(TEST_POOL);
127
+ // const result = await pool.increaseLiquidity(
128
+ // Dapp.UNISWAPV3,
129
+ // "110507",
130
+ // "244838",
131
+ // "258300000000000",
132
+ // options
133
+ // );
134
+ // console.log("result", result);
135
+ // expect(result).not.toBe(null);
136
+ // });
137
+
138
+ // it("should claim fees an existing pool", async () => {
139
+ // const pool = await dhedge.loadPool(TEST_POOL);
140
+ // const result = await pool.claimFeesUniswapV3("54929", options);
141
+ // console.log("result", result);
142
+ // expect(result).not.toBe(null);
143
+ // });
144
+
145
+ // it("approves unlimited USDC to swap on UniswapV3", async () => {
146
+ // let result;
147
+ // const pool = await dhedge.loadPool(TEST_POOL);
148
+ // try {
149
+ // result = await pool.approve(
150
+ // Dapp.UNISWAPV3,
151
+ // USDC,
152
+ // ethers.constants.MaxInt256,
153
+ // options
154
+ // );
155
+ // console.log(result);
156
+ // } catch (e) {
157
+ // console.log(e);
158
+ // }
159
+ // expect(result).not.toBe(null);
160
+ // });
161
+
162
+ // it("should swap USDC into WETH on UniswapV3 pool", async () => {
163
+ // const pool = await dhedge.loadPool(TEST_POOL);
164
+ // const result = await pool.tradeUniswapV3(
165
+ // USDC,
166
+ // WETH,
167
+ // "1000000",
168
+ // FeeAmount.LOW,
169
+ // 1,
170
+ // options
171
+ // );
172
+
173
+ // console.log(result);
174
+ // expect(result).not.toBe(null);
175
+ // });
21
176
  });
177
+ };
22
178
 
23
- it("approves unlimited USDC on for trading on UniswapV3", async () => {
24
- await pool.approve(
25
- Dapp.UNISWAPV3,
26
- CONTRACT_ADDRESS[network].USDC,
27
- ethers.constants.MaxUint256
28
- );
29
- const UsdcAllowanceDelta = await allowanceDelta(
30
- pool.address,
31
- CONTRACT_ADDRESS[network].USDC,
32
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
- routerAddress[network].uniswapV3!,
34
- pool.signer
35
- );
36
- expect(UsdcAllowanceDelta.gte(0));
37
- });
179
+ testingHelper({
180
+ network: Network.OPTIMISM,
181
+ testingRun: testUniswapV3
182
+ });
38
183
 
39
- it("should swap 5 USDC into WETH on UniswapV3", async () => {
40
- await pool.tradeUniswapV3(
41
- CONTRACT_ADDRESS[network].USDC,
42
- CONTRACT_ADDRESS[network].WETH,
43
- "5000000",
44
- FeeAmount.LOW,
45
- 0.5
46
- );
47
-
48
- const wethAllowanceDelta = await balanceDelta(
49
- pool.address,
50
- CONTRACT_ADDRESS[network].WETH,
51
- pool.signer
52
- );
53
- expect(wethAllowanceDelta.gt(0));
54
- });
184
+ testingHelper({
185
+ network: Network.POLYGON,
186
+ testingRun: testUniswapV3
187
+ });
55
188
 
56
- // it("approves unlimited WETH on for UniswapV3 LP", async () => {
57
- // await pool.approveUniswapV3Liquidity(
58
- // CONTRACT_ADDRESS[network].USDC,
59
- // ethers.constants.MaxInt256
60
- // );
61
- // const UsdcAllowanceDelta = await allowanceDelta(
62
- // pool.address,
63
- // CONTRACT_ADDRESS[network].USDC,
64
- // pool.address,
65
- // pool.signer
66
- // );
67
-
68
- // expect(result).not.toBe(null);
69
- // });
70
-
71
- // it("adds WETH and WBTC to a new V3 pool", async () => {
72
- // let result;
73
- // const pool = await dhedge.loadPool(TEST_POOL);
74
- // const usdcBalance = await dhedge.utils.getBalance(USDC, pool.address);
75
- // const wethBalance = await dhedge.utils.getBalance(WETH, pool.address);
76
-
77
- // try {
78
- // result = await pool.addLiquidityUniswapV3(
79
- // USDC,
80
- // WETH,
81
- // usdcBalance,
82
- // wethBalance,
83
- // 0.0003,
84
- // 0.0004,
85
- // null,
86
- // null,
87
- // FeeAmount.LOW,
88
- // options
89
- // );
90
- // console.log(result);
91
- // } catch (e) {
92
- // console.log(e);
93
- // }
94
- // expect(result).not.toBe(null);
95
- // });
96
-
97
- // it("should remove liquidity from an existing pool ", async () => {
98
- // const pool = await dhedge.loadPool(TEST_POOL);
99
- // const result = await pool.decreaseLiquidity(
100
- // Dapp.UNISWAPV3,
101
- // "110507",
102
- // 100,
103
- // options
104
- // );
105
- // console.log("result", result);
106
- // expect(result).not.toBe(null);
107
- // });
108
-
109
- // it("should increase liquidity in an existing pool WETH/WBTC pool", async () => {
110
- // const pool = await dhedge.loadPool(TEST_POOL);
111
- // const result = await pool.increaseLiquidity(
112
- // Dapp.UNISWAPV3,
113
- // "110507",
114
- // "244838",
115
- // "258300000000000",
116
- // options
117
- // );
118
- // console.log("result", result);
119
- // expect(result).not.toBe(null);
120
- // });
121
-
122
- // it("should claim fees an existing pool", async () => {
123
- // const pool = await dhedge.loadPool(TEST_POOL);
124
- // const result = await pool.claimFeesUniswapV3("54929", options);
125
- // console.log("result", result);
126
- // expect(result).not.toBe(null);
127
- // });
128
-
129
- // it("approves unlimited USDC to swap on UniswapV3", async () => {
130
- // let result;
131
- // const pool = await dhedge.loadPool(TEST_POOL);
132
- // try {
133
- // result = await pool.approve(
134
- // Dapp.UNISWAPV3,
135
- // USDC,
136
- // ethers.constants.MaxInt256,
137
- // options
138
- // );
139
- // console.log(result);
140
- // } catch (e) {
141
- // console.log(e);
142
- // }
143
- // expect(result).not.toBe(null);
144
- // });
145
-
146
- // it("should swap USDC into WETH on UniswapV3 pool", async () => {
147
- // const pool = await dhedge.loadPool(TEST_POOL);
148
- // const result = await pool.tradeUniswapV3(
149
- // USDC,
150
- // WETH,
151
- // "1000000",
152
- // FeeAmount.LOW,
153
- // 1,
154
- // options
155
- // );
156
-
157
- // console.log(result);
158
- // expect(result).not.toBe(null);
159
- // });
189
+ testingHelper({
190
+ network: Network.BASE,
191
+ testingRun: testUniswapV3
160
192
  });
@@ -1,6 +1,7 @@
1
- import { ethers } from "ethers";
1
+ import { BigNumber, ethers } from "ethers";
2
2
  import { Network } from "../../types";
3
3
  import { getWalletData } from "../wallet";
4
+ import { CONTRACT_ADDRESS, USDC_BALANCEOF_SLOT } from "../constants";
4
5
 
5
6
  export type TestingRunParams = {
6
7
  network: Network;
@@ -40,3 +41,52 @@ export const beforeAfterReset = ({
40
41
  await provider.send("evm_mine", []);
41
42
  });
42
43
  };
44
+
45
+ export const setTokenAmount = async ({
46
+ amount,
47
+ userAddress,
48
+ tokenAddress,
49
+ slot,
50
+ provider
51
+ }: {
52
+ amount: string;
53
+ userAddress: string;
54
+ tokenAddress: string;
55
+ slot: number;
56
+ provider: ethers.providers.JsonRpcProvider;
57
+ }): Promise<void> => {
58
+ const toBytes32 = (bn: string) => {
59
+ return ethers.utils.hexlify(
60
+ ethers.utils.zeroPad(BigNumber.from(bn).toHexString(), 32)
61
+ );
62
+ };
63
+ const index = ethers.utils.solidityKeccak256(
64
+ ["uint256", "uint256"],
65
+ [userAddress, slot] // key, slot
66
+ );
67
+ await provider.send("hardhat_setStorageAt", [
68
+ tokenAddress,
69
+ index,
70
+ toBytes32(amount).toString()
71
+ ]);
72
+ await provider.send("evm_mine", []);
73
+ };
74
+ export const setUSDCAmount = async ({
75
+ provider,
76
+ userAddress,
77
+ amount,
78
+ network
79
+ }: {
80
+ amount: string;
81
+ userAddress: string;
82
+ provider: ethers.providers.JsonRpcProvider;
83
+ network: Network;
84
+ }): Promise<void> => {
85
+ await setTokenAmount({
86
+ amount,
87
+ userAddress,
88
+ provider,
89
+ tokenAddress: CONTRACT_ADDRESS[network].USDC,
90
+ slot: USDC_BALANCEOF_SLOT[network]
91
+ });
92
+ };
@@ -29,7 +29,8 @@ export const wallet = new ethers.Wallet(
29
29
  export const networkPortMap = {
30
30
  [Network.POLYGON]: 8542,
31
31
  [Network.OPTIMISM]: 8544,
32
- [Network.ARBITRUM]: 8540
32
+ [Network.ARBITRUM]: 8540,
33
+ [Network.BASE]: 8546
33
34
  };
34
35
 
35
36
  export const getWalletData = (
@@ -1,12 +1,18 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ import BigNumber from "bignumber.js";
2
3
  import { Dhedge, Pool } from "..";
3
4
  import { routerAddress } from "../config";
4
5
  import { Dapp, Network } from "../types";
5
6
  import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
6
- import { TestingRunParams, testingHelper } from "./utils/testingHelper";
7
+ import {
8
+ TestingRunParams,
9
+ setUSDCAmount,
10
+ testingHelper
11
+ } from "./utils/testingHelper";
7
12
  import { allowanceDelta, balanceDelta } from "./utils/token";
13
+ import { getTxOptions } from "./txOptions";
8
14
 
9
- const testZeroEx = ({ wallet, network }: TestingRunParams) => {
15
+ const testZeroEx = ({ wallet, network, provider }: TestingRunParams) => {
10
16
  const USDC = CONTRACT_ADDRESS[network].USDC;
11
17
  const WETH = CONTRACT_ADDRESS[network].WETH;
12
18
 
@@ -18,10 +24,28 @@ const testZeroEx = ({ wallet, network }: TestingRunParams) => {
18
24
  beforeAll(async () => {
19
25
  dhedge = new Dhedge(wallet, network);
20
26
  pool = await dhedge.loadPool(TEST_POOL[network]);
27
+ // top up gas
28
+ await provider.send("hardhat_setBalance", [
29
+ wallet.address,
30
+ "0x10000000000000000"
31
+ ]);
32
+ await provider.send("evm_mine", []);
33
+ // top up USDC
34
+ await setUSDCAmount({
35
+ amount: new BigNumber(100).times(1e18).toFixed(0),
36
+ userAddress: pool.address,
37
+ network,
38
+ provider
39
+ });
21
40
  });
22
41
 
23
42
  it("approves unlimited USDC on 0x", async () => {
24
- await pool.approve(Dapp.ZEROEX, USDC, MAX_AMOUNT);
43
+ await pool.approve(
44
+ Dapp.ZEROEX,
45
+ USDC,
46
+ MAX_AMOUNT,
47
+ await getTxOptions(network)
48
+ );
25
49
  const usdcAllowanceDelta = await allowanceDelta(
26
50
  pool.address,
27
51
  USDC,
@@ -32,7 +56,14 @@ const testZeroEx = ({ wallet, network }: TestingRunParams) => {
32
56
  });
33
57
 
34
58
  it("trades 2 USDC into WETH on 0x", async () => {
35
- await pool.trade(Dapp.ZEROEX, USDC, WETH, "2000000", 0.5);
59
+ await pool.trade(
60
+ Dapp.ZEROEX,
61
+ USDC,
62
+ WETH,
63
+ "2000000",
64
+ 0.5,
65
+ await getTxOptions(network)
66
+ );
36
67
  const wethBalanceDelta = await balanceDelta(
37
68
  pool.address,
38
69
  WETH,
@@ -52,3 +83,8 @@ testingHelper({
52
83
  network: Network.POLYGON,
53
84
  testingRun: testZeroEx
54
85
  });
86
+
87
+ testingHelper({
88
+ network: Network.BASE,
89
+ testingRun: testZeroEx
90
+ });