@dhedge/v2-sdk 1.7.2 → 1.8.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.
Files changed (48) hide show
  1. package/dist/config.d.ts +0 -1
  2. package/dist/entities/pool.d.ts +16 -7
  3. package/dist/services/futures/constants.d.ts +3 -0
  4. package/dist/services/futures/index.d.ts +2 -0
  5. package/dist/services/futures/margin.d.ts +2 -0
  6. package/dist/services/futures/trade.d.ts +2 -0
  7. package/dist/services/velodrome/liquidity.d.ts +2 -2
  8. package/dist/test/constants.d.ts +24 -2
  9. package/dist/test/utils/token.d.ts +3 -0
  10. package/dist/utils/deadline.d.ts +2 -0
  11. package/dist/v2-sdk.cjs.development.js +4540 -5101
  12. package/dist/v2-sdk.cjs.development.js.map +1 -1
  13. package/dist/v2-sdk.cjs.production.min.js +1 -1
  14. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  15. package/dist/v2-sdk.esm.js +7340 -7901
  16. package/dist/v2-sdk.esm.js.map +1 -1
  17. package/package.json +5 -2
  18. package/src/abi/IDhedgeEasySwapper.json +99 -239
  19. package/src/abi/ISynthetiXFuturesMarketV2.json +531 -0
  20. package/src/config.ts +4 -5
  21. package/src/entities/pool.ts +68 -44
  22. package/src/services/futures/constants.ts +4 -0
  23. package/src/services/futures/index.ts +2 -0
  24. package/src/services/futures/margin.ts +10 -0
  25. package/src/services/futures/trade.ts +15 -0
  26. package/src/services/oneInch/protocols.ts +1 -1
  27. package/src/services/toros/easySwapper.ts +3 -2
  28. package/src/services/uniswap/V3Liquidity.ts +2 -3
  29. package/src/services/velodrome/liquidity.ts +7 -7
  30. package/src/test/constants.ts +27 -2
  31. package/src/test/futures.test.ts +48 -0
  32. package/src/test/oneInch.test.ts +32 -36
  33. package/src/test/pool.test.ts +42 -85
  34. package/src/test/toros.test.ts +50 -98
  35. package/src/test/uniswap.test.ts +65 -30
  36. package/src/test/utils/token.ts +31 -0
  37. package/src/test/velodrome.test.ts +74 -101
  38. package/src/test/wallet.ts +5 -3
  39. package/src/utils/deadline.ts +6 -0
  40. package/dist/services/claim-balancer/claim.service.d.ts +0 -17
  41. package/dist/services/claim-balancer/claim.worker.d.ts +0 -4
  42. package/dist/services/claim-balancer/ipfs.service.d.ts +0 -4
  43. package/dist/services/claim-balancer/types.d.ts +0 -54
  44. package/src/services/claim-balancer/MultiTokenClaim.json +0 -115
  45. package/src/services/claim-balancer/claim.service.ts +0 -262
  46. package/src/services/claim-balancer/claim.worker.ts +0 -32
  47. package/src/services/claim-balancer/ipfs.service.ts +0 -12
  48. package/src/services/claim-balancer/types.ts +0 -66
@@ -1,117 +1,69 @@
1
- import { Dhedge, ethers } from "..";
2
- import {
3
- getEasySwapperDepositQuote,
4
- getEasySwapperWithdrawalQuote,
5
- getPoolDepositAsset
6
- } from "../services/toros/easySwapper";
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";
7
5
  import { Dapp, Network } from "../types";
8
- import { BTCBEAR2X, ETHBULL3X, TEST_POOL, USDC, WBTC } from "./constants";
9
- import { getTxOptions } from "./txOptions";
6
+ import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
7
+ import { allowanceDelta, balanceDelta } from "./utils/token";
10
8
 
11
9
  import { wallet } from "./wallet";
12
10
 
13
- let dhedge: Dhedge;
14
- let options: any;
11
+ const ETHy = "0xb2cfb909e8657c0ec44d3dd898c1053b87804755";
12
+ const network = Network.OPTIMISM;
13
+ const SUSD = CONTRACT_ADDRESS[network].SUSD;
15
14
 
15
+ let dhedge: Dhedge;
16
+ let pool: Pool;
16
17
  jest.setTimeout(100000);
17
18
 
18
19
  describe("pool", () => {
19
20
  beforeAll(async () => {
20
- dhedge = new Dhedge(wallet, Network.POLYGON);
21
- options = await getTxOptions(Network.POLYGON);
21
+ dhedge = new Dhedge(wallet, network);
22
+ pool = await dhedge.loadPool(TEST_POOL[network]);
22
23
  });
23
24
 
24
- it("gets Deposit Quote for ETHBULL3X invest with USDC", async () => {
25
- let result;
26
- const pool = await dhedge.loadPool(ETHBULL3X);
27
- try {
28
- const depositAsset = await getPoolDepositAsset(pool, ETHBULL3X, USDC);
29
- if (!depositAsset) throw new Error("no deposit assets");
30
-
31
- result = await getEasySwapperDepositQuote(
32
- pool,
33
- pool.address,
34
- USDC,
35
- depositAsset,
36
- ethers.BigNumber.from("100000000")
37
- );
38
- console.log("deposit quote", result.toString());
39
- } catch (e) {
40
- console.log(e);
41
- }
42
- expect(result).not.toBe(null);
25
+ it("approves unlimited ETHy on Toros (Easyswapper)", async () => {
26
+ await pool.approve(Dapp.TOROS, ETHy, MAX_AMOUNT);
27
+ const ETHyAllowanceDelta = await allowanceDelta(
28
+ pool.address,
29
+ ETHy,
30
+ routerAddress[network].toros!,
31
+ pool.signer
32
+ );
33
+ expect(ETHyAllowanceDelta.gt(0));
43
34
  });
44
35
 
45
- it("gets withdrawal Quote for BTCBEAR2X sell for WBTC", async () => {
46
- let result;
47
- const pool = await dhedge.loadPool(BTCBEAR2X);
48
- try {
49
- result = await getEasySwapperWithdrawalQuote(
50
- pool,
51
- pool.address,
52
- WBTC,
53
- ethers.BigNumber.from("9751590099507644982205")
54
- );
55
- console.log("withdrawal quote", result.toString());
56
- } catch (e) {
57
- console.log(e);
58
- }
59
- expect(result).not.toBe(null);
36
+ it("sell ETHy to SUSD on Toros", async () => {
37
+ const ETHyBalance = await pool.utils.getBalance(ETHy, pool.address);
38
+ await pool.trade(Dapp.TOROS, ETHy, SUSD, ETHyBalance, 3);
39
+ const ETHyBalanceDelta = await balanceDelta(
40
+ pool.address,
41
+ SUSD,
42
+ pool.signer
43
+ );
44
+ expect(ETHyBalanceDelta.lt(0));
60
45
  });
61
46
 
62
- it("approves unlimited ETHBULL3X on Easyswapper", async () => {
63
- let result;
64
- const pool = await dhedge.loadPool(TEST_POOL);
65
- try {
66
- result = await pool.approve(
67
- Dapp.TOROS,
68
- ETHBULL3X,
69
- ethers.constants.MaxInt256,
70
- options
71
- );
72
- console.log(result);
73
- } catch (e) {
74
- console.log(e);
75
- }
76
- expect(result).not.toBe(null);
47
+ it("approves unlimited sUSD on Toros (Easyswapper)", async () => {
48
+ await pool.approve(Dapp.TOROS, SUSD, MAX_AMOUNT, { gasLimit: "3000000" });
49
+ const sUSDAllowanceDelta = await allowanceDelta(
50
+ pool.address,
51
+ SUSD,
52
+ routerAddress[network].toros!,
53
+ pool.signer
54
+ );
55
+ expect(sUSDAllowanceDelta.gt(0));
77
56
  });
78
57
 
79
- // it("buys ETHBULL3X for 1 USDC", async () => {
80
- // let result;
81
- // const pool = await dhedge.loadPool(TEST_POOL);
82
- // try {
83
- // result = await pool.trade(
84
- // Dapp.TOROS,
85
- // USDC,
86
- // ETHBULL3X,
87
- // "1000000",
88
- // 0.5,
89
- // options
90
- // );
91
- // console.log(result);
92
- // } catch (e) {
93
- // console.log(e);
94
- // }
95
- // expect(result).not.toBe(null);
96
- // });
97
-
98
- it("sells ETHBULL3X balance for USDC", async () => {
99
- let result;
100
- const pool = await dhedge.loadPool(TEST_POOL);
101
- const balance = await pool.utils.getBalance(ETHBULL3X, pool.address);
102
- try {
103
- result = await pool.trade(
104
- Dapp.TOROS,
105
- ETHBULL3X,
106
- USDC,
107
- balance,
108
- 3,
109
- options
110
- );
111
- console.log(result);
112
- } catch (e) {
113
- console.log(e);
114
- }
115
- expect(result).not.toBe(null);
58
+ it("buys ETHy for 3 sUSD", async () => {
59
+ await pool.trade(Dapp.TOROS, SUSD, ETHy, (3 * 10e18).toString(), 3, {
60
+ gasLimit: "3000000"
61
+ });
62
+ const ETHyBalanceDelta = await balanceDelta(
63
+ pool.address,
64
+ ETHy,
65
+ pool.signer
66
+ );
67
+ expect(ETHyBalanceDelta.gt(0));
116
68
  });
117
69
  });
@@ -1,35 +1,70 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Dhedge } from "..";
2
+ import { FeeAmount } from "@uniswap/v3-sdk";
3
+ import { Dhedge, ethers, Pool } from "..";
4
+ import { routerAddress } from "../config";
3
5
  import { Dapp, Network } from "../types";
4
- import { TEST_POOL } from "./constants";
5
- import { getTxOptions } from "./txOptions";
6
+ import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
7
+ import { allowanceDelta, balanceDelta } from "./utils/token";
6
8
 
7
9
  import { wallet } from "./wallet";
8
10
 
9
11
  let dhedge: Dhedge;
10
- let options: any;
12
+ let pool: Pool;
11
13
  jest.setTimeout(100000);
12
14
 
15
+ const network = Network.POLYGON;
16
+
13
17
  describe("pool", () => {
14
18
  beforeAll(async () => {
15
- dhedge = new Dhedge(wallet, Network.POLYGON);
16
- options = await getTxOptions(Network.POLYGON);
17
- //options = { gasLimit: "3000000" };
19
+ dhedge = new Dhedge(wallet, network);
20
+ pool = await dhedge.loadPool(TEST_POOL[network]);
21
+ });
22
+
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
+ });
38
+
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));
18
54
  });
19
55
 
20
56
  // it("approves unlimited WETH on for UniswapV3 LP", async () => {
21
- // let result;
22
- // const pool = await dhedge.loadPool(TEST_POOL);
23
- // try {
24
- // result = await pool.approveUniswapV3Liquidity(
25
- // USDC,
26
- // ethers.constants.MaxInt256,
27
- // options
28
- // );
29
- // console.log(result);
30
- // } catch (e) {
31
- // console.log(e);
32
- // }
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
+
33
68
  // expect(result).not.toBe(null);
34
69
  // });
35
70
 
@@ -59,17 +94,17 @@ describe("pool", () => {
59
94
  // expect(result).not.toBe(null);
60
95
  // });
61
96
 
62
- it("should remove liquidity from an existing pool ", async () => {
63
- const pool = await dhedge.loadPool(TEST_POOL);
64
- const result = await pool.decreaseLiquidity(
65
- Dapp.UNISWAPV3,
66
- "110507",
67
- 100,
68
- options
69
- );
70
- console.log("result", result);
71
- expect(result).not.toBe(null);
72
- });
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
+ // });
73
108
 
74
109
  // it("should increase liquidity in an existing pool WETH/WBTC pool", async () => {
75
110
  // const pool = await dhedge.loadPool(TEST_POOL);
@@ -0,0 +1,31 @@
1
+ import { BigNumber, Wallet, Contract } from "ethers";
2
+ import IERC20 from "../../abi/IERC20.json";
3
+
4
+ export const balanceDelta = async (
5
+ owner: string,
6
+ asset: string,
7
+ signer: Wallet
8
+ ): Promise<BigNumber> => {
9
+ const block = await signer.provider.getBlockNumber();
10
+ const iERC20 = new Contract(asset, IERC20.abi, signer);
11
+ const [balanceBefore, balanceAfter] = await Promise.all(
12
+ [block - 1, block].map(e => iERC20.balanceOf(owner, { blockTag: e }))
13
+ );
14
+ return balanceAfter.sub(balanceBefore);
15
+ };
16
+
17
+ export const allowanceDelta = async (
18
+ owner: string,
19
+ asset: string,
20
+ spender: string,
21
+ signer: Wallet
22
+ ): Promise<BigNumber> => {
23
+ const block = await signer.provider.getBlockNumber();
24
+ const iERC20 = new Contract(asset, IERC20.abi, signer);
25
+ const [allowanceBefore, allowanceAfter] = await Promise.all(
26
+ [block - 1, block].map(e =>
27
+ iERC20.allowance(owner, spender, { blockTag: e })
28
+ )
29
+ );
30
+ return allowanceAfter.sub(allowanceBefore);
31
+ };
@@ -1,141 +1,114 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
1
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Dhedge, ethers } from "..";
3
+ import { Dhedge, Pool } from "..";
4
+ import { routerAddress } from "../config";
3
5
  import { Dapp, Network } from "../types";
4
- import { TEST_POOL, VEL, WETH, WSTETH } from "./constants";
5
- import { getTxOptions } from "./txOptions";
6
+ import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
7
+ import { allowanceDelta, balanceDelta } from "./utils/token";
6
8
 
7
9
  import { wallet } from "./wallet";
8
10
 
9
- const wETHwstETHLp = "0xBf205335De602ac38244F112d712ab04CB59A498";
10
- const wETHwstETHGauge = "0x131Ae347E654248671Afc885F0767cB605C065d7";
11
+ const USDC_SUSD_Lp = "0xd16232ad60188b68076a235c65d692090caba155";
12
+ const USDC_SUSD_Gauge = "0xb03f52d2db3e758dd49982defd6aeefea9454e80";
13
+ const network = Network.OPTIMISM;
14
+ const SUSD = CONTRACT_ADDRESS[network].SUSD;
15
+ const USDC = CONTRACT_ADDRESS[network].USDC;
11
16
 
12
17
  let dhedge: Dhedge;
13
- let options: any;
18
+ let pool: Pool;
14
19
  jest.setTimeout(100000);
15
20
 
16
21
  describe("pool", () => {
17
22
  beforeAll(async () => {
18
- dhedge = new Dhedge(wallet, Network.OPTIMISM);
19
- options = await getTxOptions(Network.OPTIMISM);
23
+ dhedge = new Dhedge(wallet, network);
24
+ pool = await dhedge.loadPool(TEST_POOL[network]);
20
25
  });
21
26
 
22
- it("approves unlimited WETH on for Velodrome", async () => {
23
- let result;
24
- const pool = await dhedge.loadPool(TEST_POOL);
25
- try {
26
- result = await pool.approve(
27
- Dapp.VELODROME,
28
- WSTETH,
29
- ethers.constants.MaxInt256,
30
- options
31
- );
32
- console.log(result);
33
- } catch (e) {
34
- console.log(e);
35
- }
36
- expect(result).not.toBe(null);
27
+ it("approves unlimited sUSD and USDC on for Velodrome", async () => {
28
+ await pool.approve(Dapp.VELODROME, SUSD, MAX_AMOUNT);
29
+ await pool.approve(Dapp.VELODROME, USDC, MAX_AMOUNT);
30
+ const UsdcAllowanceDelta = await allowanceDelta(
31
+ pool.address,
32
+ USDC,
33
+ routerAddress[network].velodrome!,
34
+ pool.signer
35
+ );
36
+ await expect(UsdcAllowanceDelta.gt(0));
37
37
  });
38
38
 
39
- it("adds WETH and wstETH to a Velodrome stable pool", async () => {
40
- const pool = await dhedge.loadPool(TEST_POOL);
41
- const wethBalance = await dhedge.utils.getBalance(WETH, pool.address);
42
- const stwethBalance = await dhedge.utils.getBalance(WSTETH, pool.address);
43
-
44
- const result = await pool.addLiquidityVelodrome(
45
- WETH,
46
- WSTETH,
47
- wethBalance,
48
- stwethBalance,
49
- true,
50
- options
39
+ it("adds USDC and SUSD to a Velodrome stable pool", async () => {
40
+ await pool.addLiquidityVelodrome(
41
+ USDC,
42
+ SUSD,
43
+ (5 * 1e6).toString(),
44
+ (5 * 1e18).toString(),
45
+ true
51
46
  );
52
47
 
53
- result.wait(1);
54
- const lpBalance = await dhedge.utils.getBalance(wETHwstETHLp, pool.address);
55
- expect(lpBalance.gt(0));
48
+ const lpTokenDelta = await balanceDelta(
49
+ pool.address,
50
+ USDC_SUSD_Lp,
51
+ pool.signer
52
+ );
53
+ expect(lpTokenDelta.gt(0));
56
54
  });
57
55
 
58
- it("should stake wETH/wStETH LP in a gauge", async () => {
59
- const pool = await dhedge.loadPool(TEST_POOL);
60
- const balance = await dhedge.utils.getBalance(wETHwstETHLp, pool.address);
61
- const result = await pool.stakeInGauge(
62
- Dapp.VELODROME,
63
- wETHwstETHGauge,
64
- balance,
65
- options
66
- );
67
- result.wait(1);
68
- const gaugeBalance = await dhedge.utils.getBalance(
69
- wETHwstETHGauge,
70
- pool.address
56
+ it("should stake USDC-sUSD LP in a gauge", async () => {
57
+ const balance = await dhedge.utils.getBalance(USDC_SUSD_Lp, pool.address);
58
+ await pool.approveSpender(USDC_SUSD_Gauge, USDC_SUSD_Lp, MAX_AMOUNT);
59
+ await pool.stakeInGauge(Dapp.VELODROME, USDC_SUSD_Gauge, balance);
60
+ const gaugeBalance = await balanceDelta(
61
+ pool.address,
62
+ USDC_SUSD_Lp,
63
+ pool.signer
71
64
  );
72
65
  expect(gaugeBalance.gt(0));
73
66
  });
74
67
 
75
68
  it("should claim rewards from Gauge", async () => {
76
- const pool = await dhedge.loadPool(TEST_POOL);
77
- const result = await pool.claimFees(
78
- Dapp.VELODROME,
79
- wETHwstETHGauge,
80
- options
81
- );
82
- result.wait(1);
83
- const velBalance = await dhedge.utils.getBalance(VEL, pool.address);
84
- expect(velBalance.gt(0));
69
+ const tx = await pool.claimFees(Dapp.VELODROME, USDC_SUSD_Gauge);
70
+ expect(tx).not.toBe(null);
85
71
  });
86
72
 
87
- it("should unStake wETH/wStETH LP from a gauge", async () => {
88
- const pool = await dhedge.loadPool(TEST_POOL);
73
+ it("should unStake USDC-sUSD LP from a gauge", async () => {
89
74
  const gaugeBalance = await dhedge.utils.getBalance(
90
- wETHwstETHGauge,
75
+ USDC_SUSD_Gauge,
91
76
  pool.address
92
77
  );
93
- const result = await pool.unstakeFromGauge(
94
- wETHwstETHGauge,
95
- gaugeBalance,
96
- options
97
- );
98
- result.wait(1);
99
- const lpBalance = await dhedge.utils.getBalance(wETHwstETHLp, pool.address);
100
- expect(lpBalance.gt(0));
101
- const gaugeBalanceAfter = await dhedge.utils.getBalance(
102
- wETHwstETHGauge,
103
- pool.address
78
+ await pool.unstakeFromGauge(USDC_SUSD_Gauge, gaugeBalance);
79
+ const lpTokenDelta = await balanceDelta(
80
+ pool.address,
81
+ USDC_SUSD_Lp,
82
+ pool.signer
104
83
  );
105
- expect(gaugeBalanceAfter.eq(0));
84
+ expect(lpTokenDelta.gt(0));
106
85
  });
107
86
 
108
87
  it("approves unlimited wETH/stwETH LP for Velodrome", async () => {
109
- let result;
110
- const pool = await dhedge.loadPool(TEST_POOL);
111
- try {
112
- result = await pool.approve(
113
- Dapp.VELODROME,
114
- wETHwstETHLp,
115
- ethers.constants.MaxInt256,
116
- options
117
- );
118
- console.log(result);
119
- } catch (e) {
120
- console.log(e);
121
- }
122
- expect(result).not.toBe(null);
88
+ await pool.approve(Dapp.VELODROME, USDC_SUSD_Lp, MAX_AMOUNT);
89
+ const lpAllowanceDelta = await allowanceDelta(
90
+ pool.address,
91
+ USDC_SUSD_Lp,
92
+ routerAddress[network].velodrome!,
93
+ pool.signer
94
+ );
95
+ expect(lpAllowanceDelta.gt(0));
123
96
  });
124
97
 
125
98
  it("should remove all liquidity from an existing pool ", async () => {
126
- const pool = await dhedge.loadPool(TEST_POOL);
127
- const balance = await dhedge.utils.getBalance(wETHwstETHLp, pool.address);
128
- const result = await pool.removeLiquidityVelodrome(
129
- WETH,
130
- WSTETH,
131
- balance,
132
- options
99
+ const balance = await dhedge.utils.getBalance(USDC_SUSD_Lp, pool.address);
100
+ await pool.removeLiquidityVelodrome(USDC, SUSD, balance, true);
101
+ const usdcBalanceDelta = await balanceDelta(
102
+ pool.address,
103
+ USDC,
104
+ pool.signer
133
105
  );
134
- result.wait(1);
135
- const balanceAfter = await dhedge.utils.getBalance(
136
- wETHwstETHLp,
137
- pool.address
106
+ const susdBalanceDelta = await balanceDelta(
107
+ pool.address,
108
+ SUSD,
109
+ pool.signer
138
110
  );
139
- expect(balanceAfter.eq(0));
111
+ expect(usdcBalanceDelta.gt(0));
112
+ expect(susdBalanceDelta.gt(0));
140
113
  });
141
114
  });
@@ -3,9 +3,9 @@ import { ethers } from "ethers";
3
3
  // eslint-disable-next-line @typescript-eslint/no-var-requires
4
4
  require("dotenv").config();
5
5
 
6
- const provider = new ethers.providers.JsonRpcProvider(
7
- `https://opt-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`
8
- );
6
+ // const provider = new ethers.providers.JsonRpcProvider(
7
+ // `https://opt-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`
8
+ // );
9
9
 
10
10
  // const provider = new ethers.providers.JsonRpcProvider(
11
11
  // `https://opt-kovan.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`
@@ -19,6 +19,8 @@ const provider = new ethers.providers.JsonRpcProvider(
19
19
  // `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`
20
20
  // );
21
21
 
22
+ const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545/");
23
+
22
24
  export const wallet = new ethers.Wallet(
23
25
  process.env.PRIVATE_KEY as string,
24
26
  provider
@@ -0,0 +1,6 @@
1
+ import { Pool } from "../entities";
2
+
3
+ export const getDeadline = async (pool: Pool): Promise<number> => {
4
+ const timestamp = (await pool.signer.provider.getBlock("latest")).timestamp;
5
+ return timestamp + 60 * 20; //add 20 min
6
+ };
@@ -1,17 +0,0 @@
1
- import { ethers, Wallet } from "ethers";
2
- import { MultiTokenPendingClaims, TokenClaimInfo } from "./types";
3
- import { Network } from "../../types";
4
- export declare class ClaimService {
5
- network: Network;
6
- signer: ethers.Wallet;
7
- constructor(network: Network, signer: Wallet);
8
- getMultiTokensPendingClaims(account: string): Promise<MultiTokenPendingClaims[]>;
9
- getTokenPendingClaims(tokenClaimInfo: TokenClaimInfo, account: string): Promise<MultiTokenPendingClaims>;
10
- multiTokenClaimRewards(account: string, multiTokenPendingClaims: MultiTokenPendingClaims[]): Promise<any>;
11
- private computeClaimProofs;
12
- private computeClaimProof;
13
- private getTokenClaimsInfo;
14
- private getSnapshot;
15
- private getClaimStatus;
16
- private getReports;
17
- }
@@ -1,4 +0,0 @@
1
- import { ComputeClaimProofPayload } from "./types";
2
- export declare class ClaimWorker {
3
- calcClaimProof(payload: ComputeClaimProofPayload): any;
4
- }
@@ -1,4 +0,0 @@
1
- export default class IpfsService {
2
- get<T>(hash: string, protocol?: string): Promise<T>;
3
- }
4
- export declare const ipfsService: IpfsService;
@@ -1,54 +0,0 @@
1
- export interface Claim {
2
- id: string;
3
- amount: string;
4
- }
5
- export declare type Snapshot = Record<number, string>;
6
- export declare type TokenClaimInfo = {
7
- label: string;
8
- distributor: string;
9
- token: string;
10
- decimals: number;
11
- manifest: string;
12
- weekStart: number;
13
- };
14
- export declare type MultiTokenPendingClaims = {
15
- claims: Claim[];
16
- reports: Report;
17
- tokenClaimInfo: TokenClaimInfo;
18
- availableToClaim: string;
19
- };
20
- export declare type ClaimStatus = boolean;
21
- export declare type Report = Record<string, any>;
22
- export declare type MultiTokenCurrentRewardsEstimateResponse = {
23
- success: boolean;
24
- result: {
25
- current_timestamp: string;
26
- "liquidity-providers": Array<{
27
- snapshot_timestamp: string;
28
- address: string;
29
- token_address: string;
30
- chain_id: number;
31
- current_estimate: string;
32
- velocity: string;
33
- week: number;
34
- }>;
35
- };
36
- };
37
- export declare type MultiTokenCurrentRewardsEstimate = {
38
- rewards: string;
39
- velocity: string;
40
- token: string;
41
- };
42
- export declare type ClaimProofTuple = [number, string, string, number, string[]];
43
- export declare type ComputeClaimProofPayload = {
44
- report: Report;
45
- account: string;
46
- claim: Claim;
47
- distributor: string;
48
- tokenIndex: number;
49
- decimals: number;
50
- };
51
- export declare type ClaimWorkerMessage<P = any> = {
52
- type: "computeClaimProof";
53
- payload: P;
54
- };