@dhedge/v2-sdk 1.9.5 → 1.9.7

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.
@@ -1,95 +1,139 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import BigNumber from "bignumber.js";
3
4
  import { Dhedge, Pool } from "..";
4
5
  import { routerAddress } from "../config";
5
- import { Dapp, Network } from "../types";
6
+ import { AssetEnabled, Dapp, Network } from "../types";
6
7
  import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
8
+ import {
9
+ TestingRunParams,
10
+ setUSDCAmount,
11
+ testingHelper,
12
+ wait
13
+ } from "./utils/testingHelper";
7
14
  import { allowanceDelta, balanceDelta } from "./utils/token";
8
15
 
9
- import { wallet } from "./wallet";
10
-
11
16
  //const network = Network.OPTIMISM;
12
17
  const network = Network.POLYGON;
13
18
  const USDC = CONTRACT_ADDRESS[network].USDC;
14
19
  const WETH = CONTRACT_ADDRESS[network].WETH;
15
-
16
- let dhedge: Dhedge;
17
- let pool: Pool;
18
20
  jest.setTimeout(100000);
19
21
 
20
- describe("pool", () => {
21
- beforeAll(async () => {
22
- dhedge = new Dhedge(wallet, network);
23
- pool = await dhedge.loadPool(TEST_POOL[network]);
24
- await pool.approve(Dapp.ONEINCH, USDC, MAX_AMOUNT);
25
- await pool.trade(Dapp.ONEINCH, USDC, WETH, "1000000", 0.5);
26
- });
22
+ const testArrakis = ({ wallet, network, provider }: TestingRunParams) => {
23
+ let dhedge: Dhedge;
24
+ let pool: Pool;
27
25
 
28
- it("approves unlimited USDC on Arrakis", async () => {
29
- await pool.approve(Dapp.ARRAKIS, USDC, MAX_AMOUNT);
30
- const usdcAllowanceDelta = await allowanceDelta(
31
- pool.address,
32
- USDC,
33
- routerAddress[network].arrakis!,
34
- pool.signer
35
- );
36
- await expect(usdcAllowanceDelta.gt(0));
37
- });
26
+ describe("pool", () => {
27
+ beforeAll(async () => {
28
+ dhedge = new Dhedge(wallet, network);
29
+ pool = await dhedge.loadPool(TEST_POOL[network]);
38
30
 
39
- it("approves unlimited WETH on Arrakis", async () => {
40
- await pool.approve(Dapp.ARRAKIS, WETH, MAX_AMOUNT);
41
- const wethAllowanceDelta = await allowanceDelta(
42
- pool.address,
43
- USDC,
44
- routerAddress[network].arrakis!,
45
- pool.signer
46
- );
47
- await expect(wethAllowanceDelta.gt(0));
48
- });
31
+ // top up gas
32
+ await provider.send("hardhat_setBalance", [
33
+ wallet.address,
34
+ "0x10000000000000000"
35
+ ]);
36
+ await provider.send("evm_mine", []);
37
+ await setUSDCAmount({
38
+ amount: new BigNumber(10000000).times(1e6).toFixed(0),
39
+ userAddress: pool.address,
40
+ network,
41
+ provider
42
+ });
49
43
 
50
- it("should add liquidity and stake in an WETH/USDC Arrakis pool", async () => {
51
- const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
52
- const wethBalance = await pool.utils.getBalance(WETH, pool.address);
53
- await pool.increaseLiquidity(
54
- Dapp.ARRAKIS,
55
- CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
56
- usdcBalance,
57
- wethBalance
58
- );
59
- const lpBalanceDelta = await balanceDelta(
60
- pool.address,
61
- CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_LP,
62
- pool.signer
63
- );
64
- expect(lpBalanceDelta.gt(0));
65
- });
44
+ const newAssets: AssetEnabled[] = [
45
+ { asset: CONTRACT_ADDRESS[network].USDC, isDeposit: true },
46
+ { asset: CONTRACT_ADDRESS[network].WETH, isDeposit: true },
47
+ {
48
+ asset: CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
49
+ isDeposit: false
50
+ },
51
+ {
52
+ asset: CONTRACT_ADDRESS[network].WMATIC, // reward token
53
+ isDeposit: false
54
+ },
55
+ {
56
+ asset: CONTRACT_ADDRESS[network].uniswapV3.nonfungiblePositionManager,
57
+ isDeposit: false
58
+ }
59
+ ];
60
+ await pool.changeAssets(newAssets);
61
+ await pool.approve(Dapp.ONEINCH, USDC, MAX_AMOUNT);
62
+ await pool.trade(Dapp.ONEINCH, USDC, WETH, "10000000", 0.5, null, false);
63
+ });
66
64
 
67
- it("approves unlimited LP staking Token before on Arrakis", async () => {
68
- await pool.approve(
69
- Dapp.ARRAKIS,
70
- CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
71
- MAX_AMOUNT
72
- );
73
- const gaugeAllowanceDelta = await allowanceDelta(
74
- pool.address,
75
- CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
76
- routerAddress[network].arrakis!,
77
- pool.signer
78
- );
79
- await expect(gaugeAllowanceDelta.gt(0));
80
- });
65
+ it("approves unlimited USDC on Arrakis", async () => {
66
+ await pool.approve(Dapp.ARRAKIS, USDC, MAX_AMOUNT);
67
+ const usdcAllowanceDelta = await allowanceDelta(
68
+ pool.address,
69
+ USDC,
70
+ routerAddress[network].arrakis!,
71
+ pool.signer
72
+ );
73
+ await expect(usdcAllowanceDelta.gt(0));
74
+ await wait(5);
75
+ });
76
+
77
+ it("approves unlimited WETH on Arrakis", async () => {
78
+ await pool.approve(Dapp.ARRAKIS, WETH, MAX_AMOUNT);
79
+ const wethAllowanceDelta = await allowanceDelta(
80
+ pool.address,
81
+ USDC,
82
+ routerAddress[network].arrakis!,
83
+ pool.signer
84
+ );
85
+ await expect(wethAllowanceDelta.gt(0));
86
+ });
87
+
88
+ it("should add liquidity and stake in an WETH/USDC Arrakis pool", async () => {
89
+ const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
90
+ const wethBalance = await pool.utils.getBalance(WETH, pool.address);
91
+ await pool.increaseLiquidity(
92
+ Dapp.ARRAKIS,
93
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
94
+ usdcBalance,
95
+ wethBalance
96
+ );
97
+ const lpBalanceDelta = await balanceDelta(
98
+ pool.address,
99
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_LP,
100
+ pool.signer
101
+ );
102
+ expect(lpBalanceDelta.gt(0));
103
+ });
81
104
 
82
- it("should remove liquidity from an existing pool ", async () => {
83
- await pool.decreaseLiquidity(
84
- Dapp.ARRAKIS,
85
- CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
86
- 100
87
- );
88
- const wethBalanceDelta = await balanceDelta(
89
- pool.address,
90
- CONTRACT_ADDRESS[network].WETH,
91
- pool.signer
92
- );
93
- expect(wethBalanceDelta.gt(0));
105
+ it("approves unlimited LP staking Token before on Arrakis", async () => {
106
+ await pool.approve(
107
+ Dapp.ARRAKIS,
108
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
109
+ MAX_AMOUNT
110
+ );
111
+ const gaugeAllowanceDelta = await allowanceDelta(
112
+ pool.address,
113
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
114
+ routerAddress[network].arrakis!,
115
+ pool.signer
116
+ );
117
+ await expect(gaugeAllowanceDelta.gt(0));
118
+ });
119
+
120
+ it("should remove liquidity from an existing pool ", async () => {
121
+ await pool.decreaseLiquidity(
122
+ Dapp.ARRAKIS,
123
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
124
+ 100
125
+ );
126
+ const wethBalanceDelta = await balanceDelta(
127
+ pool.address,
128
+ CONTRACT_ADDRESS[network].WETH,
129
+ pool.signer
130
+ );
131
+ expect(wethBalanceDelta.gt(0));
132
+ });
94
133
  });
134
+ };
135
+
136
+ testingHelper({
137
+ network: Network.POLYGON,
138
+ testingRun: testArrakis
95
139
  });
@@ -52,15 +52,27 @@ export const CONTRACT_ADDRESS = {
52
52
  WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
53
53
  WBTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
54
54
  ARRAKIS_USDC_WETH_GAUGE: "0x33d1ad9Cd88A509397CD924C2d7613C285602C20",
55
- ARRAKIS_USDC_WETH_LP: "0xa173340f1e942c2845bcbce8ebd411022e18eb13"
55
+ ARRAKIS_USDC_WETH_LP: "0xa173340f1e942c2845bcbce8ebd411022e18eb13",
56
+ WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
57
+ uniswapV3: {
58
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
59
+ }
56
60
  },
61
+
57
62
  [Network.OPTIMISM]: {
58
63
  USDC: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
59
64
  SUSD: "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
60
65
  SWETH: "",
61
66
  WETH: "0x4200000000000000000000000000000000000006",
62
67
  WBTC: "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
63
- KWENTA_ETH_PERP_V2: "0x2b3bb4c683bfc5239b029131eef3b1d214478d93"
68
+ KWENTA_ETH_PERP_V2: "0x2b3bb4c683bfc5239b029131eef3b1d214478d93",
69
+ uniswapV3: {
70
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
71
+ },
72
+ WMATIC: "",
73
+ //
74
+ ARRAKIS_USDC_WETH_GAUGE: "",
75
+ ARRAKIS_USDC_WETH_LP: ""
64
76
  },
65
77
  [Network.ARBITRUM]: {
66
78
  USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
@@ -69,13 +81,29 @@ export const CONTRACT_ADDRESS = {
69
81
  WBTC: "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
70
82
  WSTETH: "0x5979d7b546e38e414f7e9822514be443a4800529",
71
83
  BALANCER_WSTETH_WETH_POOL: "0x36bf227d6bac96e2ab1ebb5492ecec69c691943f",
72
- BALANCER_WSTETH_WETH_GAUGE: "0x251e51b25afa40f2b6b9f05aaf1bc7eaa0551771"
84
+ BALANCER_WSTETH_WETH_GAUGE: "0x251e51b25afa40f2b6b9f05aaf1bc7eaa0551771",
85
+
86
+ uniswapV3: {
87
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
88
+ },
89
+
90
+ //
91
+ ARRAKIS_USDC_WETH_GAUGE: "",
92
+ ARRAKIS_USDC_WETH_LP: "",
93
+ WMATIC: ""
73
94
  },
74
95
  [Network.BASE]: {
75
96
  USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
76
97
  WETH: "0x4200000000000000000000000000000000000006",
77
98
  WBTC: "",
78
- SWETH: ""
99
+ SWETH: "",
100
+ uniswapV3: {
101
+ nonfungiblePositionManager: ""
102
+ },
103
+ //
104
+ ARRAKIS_USDC_WETH_GAUGE: "",
105
+ ARRAKIS_USDC_WETH_LP: "",
106
+ WMATIC: ""
79
107
  }
80
108
  };
81
109
 
@@ -7,7 +7,8 @@ import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
7
7
  import {
8
8
  TestingRunParams,
9
9
  setUSDCAmount,
10
- testingHelper
10
+ testingHelper,
11
+ wait
11
12
  } from "./utils/testingHelper";
12
13
  import { allowanceDelta, balanceDelta } from "./utils/token";
13
14
  import { getTxOptions } from "./txOptions";
@@ -32,7 +33,7 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
32
33
  await provider.send("evm_mine", []);
33
34
  // top up USDC
34
35
  await setUSDCAmount({
35
- amount: new BigNumber(100).times(1e18).toFixed(0),
36
+ amount: new BigNumber(2).times(1e6).toFixed(0),
36
37
  userAddress: pool.address,
37
38
  network,
38
39
  provider
@@ -50,7 +51,38 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
50
51
  await expect(usdcAllowanceDelta.gt(0));
51
52
  });
52
53
 
54
+ it("gets gas estimation for 2 USDC into WETH on 1Inch", async () => {
55
+ const gasEstimate = await pool.trade(
56
+ Dapp.ONEINCH,
57
+ USDC,
58
+ WETH,
59
+ "2000000",
60
+ 0.5,
61
+ await getTxOptions(network),
62
+ true
63
+ );
64
+ expect(gasEstimate.gt(0));
65
+ });
66
+
67
+ it("gets error on gas estimation for 200 USDC into WETH on 1Inch", async () => {
68
+ await wait(1);
69
+ let gasEstimate = null;
70
+ try {
71
+ gasEstimate = await pool.trade(
72
+ Dapp.ONEINCH,
73
+ USDC,
74
+ WETH,
75
+ "200000000",
76
+ 0.5,
77
+ await getTxOptions(network),
78
+ true
79
+ );
80
+ } catch (err) {}
81
+ expect(gasEstimate).toBeNull();
82
+ });
83
+
53
84
  it("trades 2 USDC into WETH on 1Inch", async () => {
85
+ await wait(1);
54
86
  await pool.trade(
55
87
  Dapp.ONEINCH,
56
88
  USDC,
@@ -2,7 +2,7 @@
2
2
  import { FeeAmount } from "@uniswap/v3-sdk";
3
3
  import { Dhedge, ethers, Pool } from "..";
4
4
  import { routerAddress } from "../config";
5
- import { Dapp, Network } from "../types";
5
+ import { AssetEnabled, Dapp, Network } from "../types";
6
6
  import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
7
7
  import { allowanceDelta, balanceDelta } from "./utils/token";
8
8
  import {
@@ -11,12 +11,15 @@ import {
11
11
  TestingRunParams
12
12
  } from "./utils/testingHelper";
13
13
  import BigNumber from "bignumber.js";
14
+ import INonfungiblePositionManager from "../abi/INonfungiblePositionManager.json";
14
15
 
15
16
  const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
16
17
  let dhedge: Dhedge;
17
18
  let pool: Pool;
19
+ let nonfungiblePositionManager: ethers.Contract;
20
+ let tokenId: ethers.BigNumber;
18
21
 
19
- jest.setTimeout(100000);
22
+ jest.setTimeout(600000);
20
23
  describe(`testUniswapV3 on ${network}`, () => {
21
24
  beforeAll(async () => {
22
25
  dhedge = new Dhedge(wallet, network);
@@ -29,11 +32,27 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
29
32
  ]);
30
33
  await provider.send("evm_mine", []);
31
34
  await setUSDCAmount({
32
- amount: new BigNumber(100).times(1e18).toFixed(0),
35
+ amount: new BigNumber(1000000).times(1e6).toFixed(0),
33
36
  userAddress: pool.address,
34
37
  network,
35
38
  provider
36
39
  });
40
+
41
+ const newAssets: AssetEnabled[] = [
42
+ { asset: CONTRACT_ADDRESS[network].USDC, isDeposit: true },
43
+ { asset: CONTRACT_ADDRESS[network].WETH, isDeposit: true },
44
+ {
45
+ asset: CONTRACT_ADDRESS[network].uniswapV3.nonfungiblePositionManager,
46
+ isDeposit: false
47
+ }
48
+ ];
49
+ await pool.changeAssets(newAssets);
50
+
51
+ nonfungiblePositionManager = new ethers.Contract(
52
+ CONTRACT_ADDRESS[network].uniswapV3.nonfungiblePositionManager,
53
+ INonfungiblePositionManager.abi,
54
+ pool.signer
55
+ );
37
56
  });
38
57
 
39
58
  it("approves unlimited USDC on for trading on UniswapV3", async () => {
@@ -52,11 +71,11 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
52
71
  expect(UsdcAllowanceDelta.gte(0));
53
72
  });
54
73
 
55
- it("should swap 5 USDC into WETH on UniswapV3", async () => {
74
+ it("should swap 5000 USDC into WETH on UniswapV3", async () => {
56
75
  await pool.tradeUniswapV3(
57
76
  CONTRACT_ADDRESS[network].USDC,
58
77
  CONTRACT_ADDRESS[network].WETH,
59
- "5000000",
78
+ new BigNumber(5000).times(1e6).toFixed(0),
60
79
  FeeAmount.LOW,
61
80
  0.5
62
81
  );
@@ -69,78 +88,88 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
69
88
  expect(wethAllowanceDelta.gt(0));
70
89
  });
71
90
 
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
- // );
91
+ it("approves unlimited WETH on for UniswapV3 LP", async () => {
92
+ await pool.approveUniswapV3Liquidity(
93
+ CONTRACT_ADDRESS[network].USDC,
94
+ ethers.constants.MaxInt256
95
+ );
96
+ await pool.approveUniswapV3Liquidity(
97
+ CONTRACT_ADDRESS[network].WETH,
98
+ ethers.constants.MaxInt256
99
+ );
100
+ const UsdcAllowanceDelta = await allowanceDelta(
101
+ pool.address,
102
+ CONTRACT_ADDRESS[network].USDC,
103
+ pool.address,
104
+ pool.signer
105
+ );
83
106
 
84
- // expect(result).not.toBe(null);
85
- // });
107
+ expect(UsdcAllowanceDelta).not.toBe(null);
108
+ });
86
109
 
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);
110
+ it("adds WETH and USDC to a new V3 pool", async () => {
111
+ let result = null;
112
+ const pool = await dhedge.loadPool(TEST_POOL[network]);
113
+ const usdcBalance = await dhedge.utils.getBalance(
114
+ CONTRACT_ADDRESS[network].USDC,
115
+ pool.address
116
+ );
117
+ const wethBalance = await dhedge.utils.getBalance(
118
+ CONTRACT_ADDRESS[network].WETH,
119
+ pool.address
120
+ );
92
121
 
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
- // });
122
+ try {
123
+ result = await pool.addLiquidityUniswapV3(
124
+ CONTRACT_ADDRESS[network].WETH,
125
+ CONTRACT_ADDRESS[network].USDC,
126
+ wethBalance,
127
+ usdcBalance,
128
+ 2000,
129
+ 3000,
130
+ null,
131
+ null,
132
+ FeeAmount.LOW
133
+ // options
134
+ );
135
+ await result.wait(1);
136
+
137
+ tokenId = await nonfungiblePositionManager.tokenOfOwnerByIndex(
138
+ pool.address,
139
+ 0
140
+ );
141
+ } catch (e) {
142
+ console.log("e", e);
143
+ }
144
+ expect(result).not.toBe(null);
145
+ });
112
146
 
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
- // });
147
+ it("should remove liquidity from an existing pool ", async () => {
148
+ const result = await pool.decreaseLiquidity(
149
+ Dapp.UNISWAPV3,
150
+ tokenId.toString(),
151
+ 50 // precent
152
+ );
153
+ // console.log("result", result);
154
+ expect(result).not.toBe(null);
155
+ });
124
156
 
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
- // });
157
+ it("should increase liquidity in the existing WETH/USDC pool", async () => {
158
+ const result = await pool.increaseLiquidity(
159
+ Dapp.UNISWAPV3,
160
+ tokenId.toString(),
161
+ new BigNumber(3000).times(1e6).toFixed(0), // usdc
162
+ new BigNumber(1).times(1e18).toFixed(0) // eth
163
+ );
164
+ // console.log("result", result);
165
+ expect(result).not.toBe(null);
166
+ });
137
167
 
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
- // });
168
+ it("should claim fees an existing pool", async () => {
169
+ const result = await pool.claimFees(Dapp.UNISWAPV3, tokenId.toString());
170
+ // console.log("result", result);
171
+ expect(result).not.toBe(null);
172
+ });
144
173
 
145
174
  // it("approves unlimited USDC to swap on UniswapV3", async () => {
146
175
  // let result;
@@ -187,6 +216,6 @@ testingHelper({
187
216
  });
188
217
 
189
218
  testingHelper({
190
- network: Network.BASE,
219
+ network: Network.ARBITRUM,
191
220
  testingRun: testUniswapV3
192
221
  });
@@ -90,3 +90,7 @@ export const setUSDCAmount = async ({
90
90
  slot: USDC_BALANCEOF_SLOT[network]
91
91
  });
92
92
  };
93
+
94
+ export const wait = (seconds: number): Promise<void> => {
95
+ return new Promise(resolve => setTimeout(resolve, seconds * 1000));
96
+ };
@@ -3,7 +3,7 @@
3
3
  import set from "lodash/set";
4
4
  import { Interface } from "@ethersproject/abi";
5
5
  import { multiCallAddress } from "../config";
6
- import { ethers, Network } from "..";
6
+ import { ethers, Network, Pool } from "..";
7
7
 
8
8
  export async function call(
9
9
  provider: ethers.Signer,
@@ -93,3 +93,19 @@ export class Multicaller {
93
93
  return obj;
94
94
  }
95
95
  }
96
+
97
+ export const getPoolTxOrGasEstimate = async (
98
+ pool: Pool,
99
+ args: any[],
100
+ estimateGas: boolean
101
+ ): Promise<any> => {
102
+ if (estimateGas) {
103
+ return await pool.poolLogic.estimateGas.execTransaction(
104
+ args[0],
105
+ args[1],
106
+ args[2]
107
+ );
108
+ } else {
109
+ return await pool.poolLogic.execTransaction(args[0], args[1], args[2]);
110
+ }
111
+ };
@@ -1,7 +0,0 @@
1
- import BigNumber from "bignumber.js";
2
- import { MerkleTree } from "./merkle";
3
- export declare function scale(input: BigNumber | string, decimalPlaces: number): BigNumber;
4
- export declare function loadTree(balances: {
5
- [x: string]: string | BigNumber;
6
- }, decimals?: number): MerkleTree;
7
- export declare function bnum(val: string | number | BigNumber): BigNumber;
@@ -1,22 +0,0 @@
1
- /// <reference types="node" />
2
- import BigNumber from "bignumber.js";
3
- export declare class MerkleTree {
4
- elements: any;
5
- layers: any;
6
- constructor(elements: any[]);
7
- getLayers(elements: string | any[]): (string | any[])[];
8
- getNextLayer(elements: any[]): any[];
9
- combinedHash(first: any, second: any): any;
10
- getRoot(): any;
11
- getHexRoot(): string;
12
- getProof(el: any): any;
13
- getHexProof(_el: any): string[];
14
- getPairElement(idx: number, layer: string | any[]): any;
15
- bufIndexOf(el: string | any[], arr: string | any[]): number;
16
- bufDedup(elements: any[]): any[];
17
- bufArrToHexArr(arr: any[]): string[];
18
- sortAndConcat(...args: any[]): Buffer;
19
- }
20
- export declare function loadTree(balances: {
21
- [x: string]: string | BigNumber;
22
- }, decimals?: number): MerkleTree;
@@ -1,38 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
3
- /* eslint-disable @typescript-eslint/ban-ts-comment */
4
- import BigNumber from "bignumber.js";
5
- import { soliditySha3 } from "web3-utils";
6
- import { MerkleTree } from "./merkle";
7
-
8
- export function scale(
9
- input: BigNumber | string,
10
- decimalPlaces: number
11
- ): BigNumber {
12
- const unscaled = typeof input === "string" ? new BigNumber(input) : input;
13
- const scalePow = new BigNumber(decimalPlaces.toString());
14
- const scaleMul = new BigNumber(10).pow(scalePow);
15
- return unscaled.times(scaleMul);
16
- }
17
-
18
- export function loadTree(
19
- balances: { [x: string]: string | BigNumber },
20
- decimals = 18
21
- ) {
22
- const elements: any[] = [];
23
- Object.keys(balances).forEach(address => {
24
- const balance: string = scale(balances[address], decimals).toString(10);
25
- const leaf = soliditySha3(
26
- { t: "address", v: address },
27
- { t: "uint", v: balance }
28
- );
29
- // @ts-ignore
30
- elements.push(leaf);
31
- });
32
- return new MerkleTree(elements);
33
- }
34
-
35
- export function bnum(val: string | number | BigNumber): BigNumber {
36
- const number = typeof val === "string" ? val : val ? val.toString() : "0";
37
- return new BigNumber(number);
38
- }