@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.
- package/dist/config.d.ts +0 -1
- package/dist/entities/pool.d.ts +16 -7
- package/dist/services/futures/constants.d.ts +3 -0
- package/dist/services/futures/index.d.ts +2 -0
- package/dist/services/futures/margin.d.ts +2 -0
- package/dist/services/futures/trade.d.ts +2 -0
- package/dist/services/velodrome/liquidity.d.ts +2 -2
- package/dist/test/constants.d.ts +24 -2
- package/dist/test/utils/token.d.ts +3 -0
- package/dist/utils/deadline.d.ts +2 -0
- package/dist/v2-sdk.cjs.development.js +4540 -5101
- 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 +7340 -7901
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +5 -2
- package/src/abi/IDhedgeEasySwapper.json +99 -239
- package/src/abi/ISynthetiXFuturesMarketV2.json +531 -0
- package/src/config.ts +4 -5
- package/src/entities/pool.ts +68 -44
- package/src/services/futures/constants.ts +4 -0
- package/src/services/futures/index.ts +2 -0
- package/src/services/futures/margin.ts +10 -0
- package/src/services/futures/trade.ts +15 -0
- package/src/services/oneInch/protocols.ts +1 -1
- package/src/services/toros/easySwapper.ts +3 -2
- package/src/services/uniswap/V3Liquidity.ts +2 -3
- package/src/services/velodrome/liquidity.ts +7 -7
- package/src/test/constants.ts +27 -2
- package/src/test/futures.test.ts +48 -0
- package/src/test/oneInch.test.ts +32 -36
- package/src/test/pool.test.ts +42 -85
- package/src/test/toros.test.ts +50 -98
- package/src/test/uniswap.test.ts +65 -30
- package/src/test/utils/token.ts +31 -0
- package/src/test/velodrome.test.ts +74 -101
- package/src/test/wallet.ts +5 -3
- package/src/utils/deadline.ts +6 -0
- package/dist/services/claim-balancer/claim.service.d.ts +0 -17
- package/dist/services/claim-balancer/claim.worker.d.ts +0 -4
- package/dist/services/claim-balancer/ipfs.service.d.ts +0 -4
- package/dist/services/claim-balancer/types.d.ts +0 -54
- package/src/services/claim-balancer/MultiTokenClaim.json +0 -115
- package/src/services/claim-balancer/claim.service.ts +0 -262
- package/src/services/claim-balancer/claim.worker.ts +0 -32
- package/src/services/claim-balancer/ipfs.service.ts +0 -12
- package/src/services/claim-balancer/types.ts +0 -66
package/src/test/toros.test.ts
CHANGED
|
@@ -1,117 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 {
|
|
9
|
-
import {
|
|
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
|
-
|
|
14
|
-
|
|
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,
|
|
21
|
-
|
|
21
|
+
dhedge = new Dhedge(wallet, network);
|
|
22
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
it("
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
});
|
package/src/test/uniswap.test.ts
CHANGED
|
@@ -1,35 +1,70 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
|
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,
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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,
|
|
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
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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
|
|
18
|
+
let pool: Pool;
|
|
14
19
|
jest.setTimeout(100000);
|
|
15
20
|
|
|
16
21
|
describe("pool", () => {
|
|
17
22
|
beforeAll(async () => {
|
|
18
|
-
dhedge = new Dhedge(wallet,
|
|
19
|
-
|
|
23
|
+
dhedge = new Dhedge(wallet, network);
|
|
24
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
20
25
|
});
|
|
21
26
|
|
|
22
|
-
it("approves unlimited
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
77
|
-
|
|
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
|
|
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
|
-
|
|
75
|
+
USDC_SUSD_Gauge,
|
|
91
76
|
pool.address
|
|
92
77
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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(
|
|
84
|
+
expect(lpTokenDelta.gt(0));
|
|
106
85
|
});
|
|
107
86
|
|
|
108
87
|
it("approves unlimited wETH/stwETH LP for Velodrome", async () => {
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
pool.
|
|
106
|
+
const susdBalanceDelta = await balanceDelta(
|
|
107
|
+
pool.address,
|
|
108
|
+
SUSD,
|
|
109
|
+
pool.signer
|
|
138
110
|
);
|
|
139
|
-
expect(
|
|
111
|
+
expect(usdcBalanceDelta.gt(0));
|
|
112
|
+
expect(susdBalanceDelta.gt(0));
|
|
140
113
|
});
|
|
141
114
|
});
|
package/src/test/wallet.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
@@ -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,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
|
-
};
|