@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/dist/test/constants.d.ts +4 -0
- package/dist/v2-sdk.cjs.development.js +7 -2
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +7 -2
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/IArrakisV1RouterStaking.json +5 -0
- package/src/config.ts +2 -2
- package/src/entities/pool.ts +1 -0
- package/src/test/arrakis.test.ts +57 -64
- package/src/test/constants.ts +6 -2
package/package.json
CHANGED
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]: "
|
|
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]: "
|
|
41
|
+
[Dapp.ARRAKIS]: "0x9ce88a56d120300061593eF7AD074A1B710094d5"
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
package/src/entities/pool.ts
CHANGED
package/src/test/arrakis.test.ts
CHANGED
|
@@ -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,
|
|
3
|
+
import { Dhedge, Pool } from "..";
|
|
4
|
+
import { routerAddress } from "../config";
|
|
3
5
|
import { Dapp, Network } from "../types";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
|
17
|
+
let pool: Pool;
|
|
11
18
|
jest.setTimeout(100000);
|
|
12
19
|
|
|
13
20
|
describe("pool", () => {
|
|
14
21
|
beforeAll(async () => {
|
|
15
|
-
dhedge = new Dhedge(wallet,
|
|
16
|
-
|
|
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
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
29
|
+
await pool.approve(Dapp.ARRAKIS, USDC, MAX_AMOUNT);
|
|
30
|
+
const usdcAllowanceDelta = await allowanceDelta(
|
|
31
|
+
pool.address,
|
|
23
32
|
USDC,
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
routerAddress[network].arrakis!,
|
|
34
|
+
pool.signer
|
|
26
35
|
);
|
|
27
|
-
expect(
|
|
36
|
+
await expect(usdcAllowanceDelta.gt(0));
|
|
28
37
|
});
|
|
29
38
|
|
|
30
39
|
it("approves unlimited WETH on Arrakis", async () => {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
|
51
|
+
const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
44
52
|
const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
45
|
-
|
|
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
|
-
|
|
54
|
-
wethBalance
|
|
55
|
-
options
|
|
55
|
+
CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_GAUGE,
|
|
56
|
+
usdcBalance,
|
|
57
|
+
wethBalance
|
|
56
58
|
);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
pool.
|
|
59
|
+
const lpBalanceDelta = await balanceDelta(
|
|
60
|
+
pool.address,
|
|
61
|
+
CONTRACT_ADDRESS[network].ARRAKIS_USDC_WETH_LP,
|
|
62
|
+
pool.signer
|
|
61
63
|
);
|
|
62
|
-
expect(
|
|
64
|
+
expect(lpBalanceDelta.gt(0));
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
it("approves unlimited LP staking Token before on
|
|
66
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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(
|
|
79
|
+
await expect(gaugeAllowanceDelta.gt(0));
|
|
74
80
|
});
|
|
75
81
|
|
|
76
82
|
it("should remove liquidity from an existing pool ", async () => {
|
|
77
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
pool.
|
|
88
|
+
const wethBalanceDelta = await balanceDelta(
|
|
89
|
+
pool.address,
|
|
90
|
+
CONTRACT_ADDRESS[network].WETH,
|
|
91
|
+
pool.signer
|
|
88
92
|
);
|
|
89
|
-
expect(
|
|
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
|
});
|
package/src/test/constants.ts
CHANGED
|
@@ -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
|
|