@dhedge/v2-sdk 1.8.2 → 1.8.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -27,6 +27,11 @@
27
27
  "name": "amount1Min",
28
28
  "type": "uint256"
29
29
  },
30
+ {
31
+ "internalType": "uint256",
32
+ "name": "amountSharesMin",
33
+ "type": "uint256"
34
+ },
30
35
  {
31
36
  "internalType": "address",
32
37
  "name": "receiver",
package/src/config.ts CHANGED
@@ -27,7 +27,7 @@ export const routerAddress: AddressDappNetworkMap = {
27
27
  [Dapp.QUICKSWAP]: "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff",
28
28
  [Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
29
29
  [Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
30
- [Dapp.ARRAKIS]: "0xbc91a120cCD8F80b819EAF32F0996daC3Fa76a6C",
30
+ [Dapp.ARRAKIS]: "0xc73fb100a995b33f9fa181d420f4c8d74506df66",
31
31
  [Dapp.TOROS]: "0xB2F1498983bf9c9442c35F772e6C1AdE66a8DeDE"
32
32
  },
33
33
  [Network.OPTIMISM]: {
@@ -38,7 +38,7 @@ export const routerAddress: AddressDappNetworkMap = {
38
38
  [Dapp.TOROS]: "0x3988513793bCE39f0167064A9F7fC3617FaF35AB",
39
39
  [Dapp.VELODROME]: "0x9c12939390052919aF3155f41Bf4160Fd3666A6f",
40
40
  [Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B",
41
- [Dapp.ARRAKIS]: "0x86d62a8ad19998e315e6242b63eb73f391d4674b"
41
+ [Dapp.ARRAKIS]: "0x9ce88a56d120300061593eF7AD074A1B710094d5"
42
42
  }
43
43
  };
44
44
 
@@ -998,6 +998,7 @@ export class Pool {
998
998
  amountB,
999
999
  0,
1000
1000
  0,
1001
+ 0,
1001
1002
  this.address
1002
1003
  ]);
1003
1004
  } else {
@@ -1,102 +1,95 @@
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 { ARRAKIS_USDC_WETH_GAUGE, TEST_POOL, USDC, WETH } 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
 
11
+ //const network = Network.OPTIMISM;
12
+ const network = Network.POLYGON;
13
+ const USDC = CONTRACT_ADDRESS[network].USDC;
14
+ const WETH = CONTRACT_ADDRESS[network].WETH;
15
+
9
16
  let dhedge: Dhedge;
10
- let options: any;
17
+ let pool: Pool;
11
18
  jest.setTimeout(100000);
12
19
 
13
20
  describe("pool", () => {
14
21
  beforeAll(async () => {
15
- dhedge = new Dhedge(wallet, Network.OPTIMISM);
16
- options = await getTxOptions(Network.OPTIMISM);
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);
17
26
  });
18
27
 
19
28
  it("approves unlimited USDC on Arrakis", async () => {
20
- const pool = await dhedge.loadPool(TEST_POOL);
21
- const result = await pool.approve(
22
- Dapp.ARRAKIS,
29
+ await pool.approve(Dapp.ARRAKIS, USDC, MAX_AMOUNT);
30
+ const usdcAllowanceDelta = await allowanceDelta(
31
+ pool.address,
23
32
  USDC,
24
- ethers.constants.MaxInt256,
25
- options
33
+ routerAddress[network].arrakis!,
34
+ pool.signer
26
35
  );
27
- expect(result).not.toBe(null);
36
+ await expect(usdcAllowanceDelta.gt(0));
28
37
  });
29
38
 
30
39
  it("approves unlimited WETH on Arrakis", async () => {
31
- const pool = await dhedge.loadPool(TEST_POOL);
32
- const result = await pool.approve(
33
- Dapp.ARRAKIS,
34
- WETH,
35
- ethers.constants.MaxInt256,
36
- options
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
37
46
  );
38
- console.log(result);
39
- expect(result).not.toBe(null);
47
+ await expect(wethAllowanceDelta.gt(0));
40
48
  });
41
49
 
42
50
  it("should add liquidity and stake in an WETH/USDC Arrakis pool", async () => {
43
- const pool = await dhedge.loadPool(TEST_POOL);
51
+ const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
44
52
  const wethBalance = await pool.utils.getBalance(WETH, pool.address);
45
- const uasdBalance = await pool.utils.getBalance(USDC, pool.address);
46
- const lpBalance = await pool.utils.getBalance(
47
- ARRAKIS_USDC_WETH_GAUGE,
48
- pool.address
49
- );
50
- const result = await pool.increaseLiquidity(
53
+ await pool.increaseLiquidity(
51
54
  Dapp.ARRAKIS,
52
- ARRAKIS_USDC_WETH_GAUGE,
53
- uasdBalance,
54
- wethBalance,
55
- options
55
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
56
+ usdcBalance,
57
+ wethBalance
56
58
  );
57
- result.wait(1);
58
- const lpBalanceAfter = await pool.utils.getBalance(
59
- ARRAKIS_USDC_WETH_GAUGE,
60
- pool.address
59
+ const lpBalanceDelta = await balanceDelta(
60
+ pool.address,
61
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_LP,
62
+ pool.signer
61
63
  );
62
- expect(lpBalanceAfter.gt(lpBalance));
64
+ expect(lpBalanceDelta.gt(0));
63
65
  });
64
66
 
65
- it("approves unlimited LP staking Token before on Arrakis", async () => {
66
- const pool = await dhedge.loadPool(TEST_POOL);
67
- const result = await pool.approve(
67
+ it("approves unlimited LP staking Token before on Arrakis", async () => {
68
+ await pool.approve(
68
69
  Dapp.ARRAKIS,
69
- ARRAKIS_USDC_WETH_GAUGE,
70
- ethers.constants.MaxInt256,
71
- options
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
72
78
  );
73
- expect(result).not.toBe(null);
79
+ await expect(gaugeAllowanceDelta.gt(0));
74
80
  });
75
81
 
76
82
  it("should remove liquidity from an existing pool ", async () => {
77
- const pool = await dhedge.loadPool(TEST_POOL);
78
- const result = await pool.decreaseLiquidity(
83
+ await pool.decreaseLiquidity(
79
84
  Dapp.ARRAKIS,
80
- ARRAKIS_USDC_WETH_GAUGE,
81
- 100,
82
- options
85
+ CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
86
+ 100
83
87
  );
84
- result.wait(1);
85
- const lpBalanceAfter = await pool.utils.getBalance(
86
- ARRAKIS_USDC_WETH_GAUGE,
87
- pool.address
88
+ const wethBalanceDelta = await balanceDelta(
89
+ pool.address,
90
+ CONTRACT_ADDRESS[network].WETH,
91
+ pool.signer
88
92
  );
89
- expect(lpBalanceAfter.eq(0));
93
+ expect(wethBalanceDelta.gt(0));
90
94
  });
91
-
92
- // it("should claim fees an existing pool", async () => {
93
- // const pool = await dhedge.loadPool(TEST_POOL);
94
- // const result = await pool.claimFees(
95
- // Dapp.ARRAKIS,
96
- // ARRAKIS_USDC_WETH_GAUGE,
97
- // options
98
- // );
99
- // console.log("result", result);
100
- // expect(result).not.toBe(null);
101
- // });
102
95
  });
@@ -47,13 +47,17 @@ export const CONTRACT_ADDRESS = {
47
47
  [Network.POLYGON]: {
48
48
  USDC: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
49
49
  WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
50
- WBTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6"
50
+ WBTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
51
+ ARRAKIS_USDC_WETH_GAUGE: "0x33d1ad9Cd88A509397CD924C2d7613C285602C20",
52
+ ARRAKIS_USDC_WETH_LP: "0xa173340f1e942c2845bcbce8ebd411022e18eb13"
51
53
  },
52
54
  [Network.OPTIMISM]: {
53
55
  USDC: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
54
56
  SUSD: "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
55
57
  WETH: "0x4200000000000000000000000000000000000006",
56
- KWENTA_ETH_PERP_V2: "0x2b3bb4c683bfc5239b029131eef3b1d214478d93"
58
+ KWENTA_ETH_PERP_V2: "0x2b3bb4c683bfc5239b029131eef3b1d214478d93",
59
+ ARRAKIS_USDC_WETH_GAUGE: "0xd3a3fbae792c4ed0aa909ec032d3f14c999b2402",
60
+ ARRAKIS_USDC_WETH_LP: "0xc59d8fbc3d9a92d24a923722f0244a50daa2ea33"
57
61
  }
58
62
  };
59
63