@dhedge/v2-sdk 1.0.0 → 1.2.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/README.md +69 -3
- package/dist/config.d.ts +4 -0
- package/dist/entities/dhedge.d.ts +2 -1
- package/dist/entities/pool.d.ts +94 -13
- package/dist/entities/utils.d.ts +15 -0
- package/dist/services/claim-balancer/claim.service.d.ts +21 -0
- package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
- package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
- package/dist/services/claim-balancer/types.d.ts +54 -0
- package/dist/test/constants.d.ts +12 -0
- package/dist/types.d.ts +17 -3
- package/dist/utils/contract.d.ts +14 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/merkle.d.ts +22 -0
- package/dist/v2-sdk.cjs.development.js +5066 -669
- 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 +5065 -670
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +11 -2
- package/src/abi/IAaveIncentivesController.json +50 -0
- package/src/abi/IBalancerMerkleOrchard.json +353 -0
- package/src/abi/IBalancertV2Vault.json +938 -0
- package/src/abi/ILendingPool.json +807 -0
- package/src/config.ts +26 -3
- package/src/entities/dhedge.ts +7 -3
- package/src/entities/pool.ts +360 -35
- package/src/entities/utils.ts +201 -1
- package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
- package/src/services/claim-balancer/claim.service.ts +324 -0
- package/src/services/claim-balancer/claim.worker.ts +32 -0
- package/src/services/claim-balancer/ipfs.service.ts +12 -0
- package/src/services/claim-balancer/types.ts +66 -0
- package/src/test/aave.test.ts +73 -0
- package/src/test/balancer.test.ts +109 -0
- package/src/test/constants.ts +13 -0
- package/src/test/dhedge.test.ts +20 -8
- package/src/test/oneInch.test.ts +56 -0
- package/src/test/pool.test.ts +11 -168
- package/src/test/sushi.test.ts +173 -0
- package/src/test/utils.test.ts +43 -17
- package/src/types.ts +18 -3
- package/src/utils/contract.ts +95 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/merkle.ts +172 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface Claim {
|
|
2
|
+
id: string;
|
|
3
|
+
amount: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type Snapshot = Record<number, string>;
|
|
7
|
+
|
|
8
|
+
export type TokenClaimInfo = {
|
|
9
|
+
label: string;
|
|
10
|
+
distributor: string;
|
|
11
|
+
token: string;
|
|
12
|
+
decimals: number;
|
|
13
|
+
manifest: string;
|
|
14
|
+
weekStart: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type MultiTokenPendingClaims = {
|
|
18
|
+
claims: Claim[];
|
|
19
|
+
reports: Report;
|
|
20
|
+
tokenClaimInfo: TokenClaimInfo;
|
|
21
|
+
availableToClaim: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ClaimStatus = boolean;
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
export type Report = Record<string, any>;
|
|
28
|
+
|
|
29
|
+
export type MultiTokenCurrentRewardsEstimateResponse = {
|
|
30
|
+
success: boolean;
|
|
31
|
+
result: {
|
|
32
|
+
current_timestamp: string;
|
|
33
|
+
"liquidity-providers": Array<{
|
|
34
|
+
snapshot_timestamp: string;
|
|
35
|
+
address: string;
|
|
36
|
+
token_address: string;
|
|
37
|
+
chain_id: number;
|
|
38
|
+
current_estimate: string;
|
|
39
|
+
velocity: string;
|
|
40
|
+
week: number;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type MultiTokenCurrentRewardsEstimate = {
|
|
46
|
+
rewards: string;
|
|
47
|
+
velocity: string;
|
|
48
|
+
token: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type ClaimProofTuple = [number, string, string, number, string[]]; // claimId, claimAmount, distributor, tokenIndex, proof
|
|
52
|
+
|
|
53
|
+
export type ComputeClaimProofPayload = {
|
|
54
|
+
report: Report;
|
|
55
|
+
account: string;
|
|
56
|
+
claim: Claim;
|
|
57
|
+
distributor: string;
|
|
58
|
+
tokenIndex: number;
|
|
59
|
+
decimals: number;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
export type ClaimWorkerMessage<P = any> = {
|
|
64
|
+
type: "computeClaimProof";
|
|
65
|
+
payload: P;
|
|
66
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Dhedge, ethers } from "..";
|
|
2
|
+
import { Network } from "../types";
|
|
3
|
+
import { AMUSDC, TEST_POOL, VDEBTWETH } from "./constants";
|
|
4
|
+
|
|
5
|
+
import { wallet } from "./wallet";
|
|
6
|
+
|
|
7
|
+
let dhedge: Dhedge;
|
|
8
|
+
|
|
9
|
+
jest.setTimeout(100000);
|
|
10
|
+
|
|
11
|
+
const options = {
|
|
12
|
+
gasLimit: 5000000,
|
|
13
|
+
gasPrice: ethers.utils.parseUnits("100", "gwei")
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("pool", () => {
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// it("withdraws 1 USDC from Aave lending pool", async () => {
|
|
22
|
+
// let result;
|
|
23
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
24
|
+
// try {
|
|
25
|
+
// result = await pool.withdrawDeposit(
|
|
26
|
+
// Dapp.AAVE,
|
|
27
|
+
// weth,
|
|
28
|
+
// "86567951006165",
|
|
29
|
+
// options
|
|
30
|
+
// );
|
|
31
|
+
// console.log(result);
|
|
32
|
+
// } catch (e) {
|
|
33
|
+
// console.log(e);
|
|
34
|
+
// }
|
|
35
|
+
// expect(result).not.toBe(null);
|
|
36
|
+
// });
|
|
37
|
+
|
|
38
|
+
// it("borrows 0.0001 WETH from Aave lending pool", async () => {
|
|
39
|
+
// let result;
|
|
40
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
41
|
+
// try {
|
|
42
|
+
// result = await pool.borrow(Dapp.AAVE, weth, "100000000000000");
|
|
43
|
+
// console.log(result);
|
|
44
|
+
// } catch (e) {
|
|
45
|
+
// console.log(e);
|
|
46
|
+
// }
|
|
47
|
+
// expect(result).not.toBe(null);
|
|
48
|
+
// });
|
|
49
|
+
|
|
50
|
+
// it("reapys 0.0001 WETH to Aave lending pool", async () => {
|
|
51
|
+
// let result;
|
|
52
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
53
|
+
// try {
|
|
54
|
+
// result = await pool.repay(Dapp.AAVE, weth, "100000000000000", options);
|
|
55
|
+
// console.log(result);
|
|
56
|
+
// } catch (e) {
|
|
57
|
+
// console.log(e);
|
|
58
|
+
// }
|
|
59
|
+
// expect(result).not.toBe(null);
|
|
60
|
+
// });
|
|
61
|
+
|
|
62
|
+
it("claims rewards from Aave", async () => {
|
|
63
|
+
let result;
|
|
64
|
+
const pool = await dhedge.loadPool(TEST_POOL);
|
|
65
|
+
try {
|
|
66
|
+
result = await pool.harvestAaveRewards([AMUSDC, VDEBTWETH], options);
|
|
67
|
+
console.log(result);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.log(e);
|
|
70
|
+
}
|
|
71
|
+
expect(result).not.toBe(null);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Dhedge, ethers } from "..";
|
|
2
|
+
import { Network } from "../types";
|
|
3
|
+
import { TEST_POOL } from "./constants";
|
|
4
|
+
|
|
5
|
+
import { wallet } from "./wallet";
|
|
6
|
+
|
|
7
|
+
let dhedge: Dhedge;
|
|
8
|
+
|
|
9
|
+
jest.setTimeout(100000);
|
|
10
|
+
|
|
11
|
+
const options = {
|
|
12
|
+
gasLimit: 2000000,
|
|
13
|
+
gasPrice: ethers.utils.parseUnits("1000", "gwei")
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("pool", () => {
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// it("approves unlimited USDC on Balancer", async () => {
|
|
22
|
+
// let result;
|
|
23
|
+
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
24
|
+
// try {
|
|
25
|
+
// result = await pool.approve(
|
|
26
|
+
// Dapp.BALANCER,
|
|
27
|
+
// USDC,
|
|
28
|
+
// ethers.constants.MaxInt256,
|
|
29
|
+
// options
|
|
30
|
+
// );
|
|
31
|
+
// console.log(result);
|
|
32
|
+
// } catch (e) {
|
|
33
|
+
// console.log(e);
|
|
34
|
+
// }
|
|
35
|
+
// expect(result).not.toBe(null);
|
|
36
|
+
// });
|
|
37
|
+
|
|
38
|
+
// it("trades 2 USDC into SUSHI on Balancer", async () => {
|
|
39
|
+
// let result;
|
|
40
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
41
|
+
// try {
|
|
42
|
+
// result = await pool.trade(
|
|
43
|
+
// Dapp.BALANCER,
|
|
44
|
+
// usdc,
|
|
45
|
+
// sushi,
|
|
46
|
+
// "2000000",
|
|
47
|
+
// 0.5,
|
|
48
|
+
// options
|
|
49
|
+
// );
|
|
50
|
+
// console.log(result);
|
|
51
|
+
// } catch (e) {
|
|
52
|
+
// console.log(e);
|
|
53
|
+
// }
|
|
54
|
+
// expect(result).not.toBe(null);
|
|
55
|
+
// });
|
|
56
|
+
|
|
57
|
+
// it("adds 1 USDC to a USDC/TUSD/DAI/USDT balancer pool", async () => {
|
|
58
|
+
// let result;
|
|
59
|
+
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
60
|
+
// const assets = [USDC, TUSD, DAI, USDT];
|
|
61
|
+
// const amounts = ["1000000", "0", "0", "0"];
|
|
62
|
+
// try {
|
|
63
|
+
// result = await pool.joinBalancerPool(
|
|
64
|
+
// "0x0d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068",
|
|
65
|
+
// assets,
|
|
66
|
+
// amounts,
|
|
67
|
+
// options
|
|
68
|
+
// );
|
|
69
|
+
// console.log("result", result);
|
|
70
|
+
// } catch (e) {
|
|
71
|
+
// console.log(e);
|
|
72
|
+
// }
|
|
73
|
+
// expect(result).not.toBe(null);
|
|
74
|
+
// });
|
|
75
|
+
|
|
76
|
+
// it("exits entire balance of WBTC/USDC/WETH balancer pool", async () => {
|
|
77
|
+
// let result;
|
|
78
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
79
|
+
// const assets = [wbtc, usdc, weth];
|
|
80
|
+
// const amount = await dhedge.utils.getBalance(
|
|
81
|
+
// "0x03cd191f589d12b0582a99808cf19851e468e6b5",
|
|
82
|
+
// pool.address
|
|
83
|
+
// );
|
|
84
|
+
// try {
|
|
85
|
+
// result = await pool.exitBalancerPool(
|
|
86
|
+
// "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a",
|
|
87
|
+
// assets,
|
|
88
|
+
// amount,
|
|
89
|
+
// options
|
|
90
|
+
// );
|
|
91
|
+
// console.log("result", result);
|
|
92
|
+
// } catch (e) {
|
|
93
|
+
// console.log(e);
|
|
94
|
+
// }
|
|
95
|
+
// expect(result).not.toBe(null);
|
|
96
|
+
// });
|
|
97
|
+
|
|
98
|
+
it("claims balancer rewards", async () => {
|
|
99
|
+
let result;
|
|
100
|
+
const pool = await dhedge.loadPool(TEST_POOL);
|
|
101
|
+
try {
|
|
102
|
+
result = await pool.harvestBalancerRewards(options);
|
|
103
|
+
console.log("result", result);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
console.log(e);
|
|
106
|
+
}
|
|
107
|
+
expect(result).not.toBe(null);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
2
|
+
export const USDT = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
3
|
+
export const DAI = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
|
|
4
|
+
export const TUSD = "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756";
|
|
5
|
+
export const WETH = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
6
|
+
export const WBTC = "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6";
|
|
7
|
+
export const SUSHI = "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a";
|
|
8
|
+
export const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
|
|
9
|
+
export const BAL = "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3";
|
|
10
|
+
export const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
|
|
11
|
+
export const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
|
|
12
|
+
|
|
13
|
+
export const TEST_POOL = "0x3deeba9ca29e2dd98d32eed8dd559dac55014615";
|
package/src/test/dhedge.test.ts
CHANGED
|
@@ -4,11 +4,15 @@ import { Network } from "../types";
|
|
|
4
4
|
|
|
5
5
|
import { wallet } from "./wallet";
|
|
6
6
|
|
|
7
|
-
const myPool = "
|
|
8
|
-
// const usdc = "
|
|
9
|
-
// const weth = "
|
|
7
|
+
const myPool = "0x279ac4c05154fd72a636fce1bc25c50966141fd0";
|
|
8
|
+
// const usdc = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
9
|
+
// const weth = "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// const options = {
|
|
12
|
+
// gasPrice: ethers.utils.parseUnits("40", "gwei")
|
|
13
|
+
// };
|
|
14
|
+
|
|
15
|
+
jest.setTimeout(900000);
|
|
12
16
|
|
|
13
17
|
let dhedge: Dhedge;
|
|
14
18
|
|
|
@@ -28,10 +32,18 @@ describe("dhedge", () => {
|
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
// it("create a pool", async () => {
|
|
31
|
-
// const pool = await dhedge.createPool(
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
+
// const pool = await dhedge.createPool(
|
|
36
|
+
// "Batman",
|
|
37
|
+
// "Gotham Pool",
|
|
38
|
+
// "DHHH",
|
|
39
|
+
// [
|
|
40
|
+
// [usdc, true],
|
|
41
|
+
// [weth, true]
|
|
42
|
+
// ],
|
|
43
|
+
// 25,
|
|
44
|
+
// options
|
|
45
|
+
// );
|
|
46
|
+
// console.log(pool.address);
|
|
35
47
|
// expect(pool.poolLogic.address).toBe(pool.address);
|
|
36
48
|
// });
|
|
37
49
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Dhedge, ethers } from "..";
|
|
2
|
+
import { Dapp, Network } from "../types";
|
|
3
|
+
import { TEST_POOL, USDC, WETH } from "./constants";
|
|
4
|
+
|
|
5
|
+
import { wallet } from "./wallet";
|
|
6
|
+
|
|
7
|
+
let dhedge: Dhedge;
|
|
8
|
+
|
|
9
|
+
jest.setTimeout(100000);
|
|
10
|
+
|
|
11
|
+
const options = {
|
|
12
|
+
gasLimit: 5000000,
|
|
13
|
+
gasPrice: ethers.utils.parseUnits("35", "gwei")
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("pool", () => {
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// it("approves unlimited USDC on 1Inch", async () => {
|
|
22
|
+
// let result;
|
|
23
|
+
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
24
|
+
// try {
|
|
25
|
+
// result = await pool.approve(
|
|
26
|
+
// Dapp.ONEINCH,
|
|
27
|
+
// USDC,
|
|
28
|
+
// ethers.constants.MaxInt256,
|
|
29
|
+
// options
|
|
30
|
+
// );
|
|
31
|
+
// console.log(result);
|
|
32
|
+
// } catch (e) {
|
|
33
|
+
// console.log(e);
|
|
34
|
+
// }
|
|
35
|
+
// expect(result).not.toBe(null);
|
|
36
|
+
// });
|
|
37
|
+
|
|
38
|
+
it("trades 1 USDC into WETH on 1Inch", async () => {
|
|
39
|
+
let result;
|
|
40
|
+
const pool = await dhedge.loadPool(TEST_POOL);
|
|
41
|
+
try {
|
|
42
|
+
result = await pool.trade(
|
|
43
|
+
Dapp.ONEINCH,
|
|
44
|
+
USDC,
|
|
45
|
+
WETH,
|
|
46
|
+
"1000000",
|
|
47
|
+
0.5,
|
|
48
|
+
options
|
|
49
|
+
);
|
|
50
|
+
console.log("1inch trade", result);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log(e);
|
|
53
|
+
}
|
|
54
|
+
expect(result).not.toBe(null);
|
|
55
|
+
});
|
|
56
|
+
});
|
package/src/test/pool.test.ts
CHANGED
|
@@ -1,69 +1,34 @@
|
|
|
1
1
|
import { Dhedge } from "..";
|
|
2
2
|
import { Network } from "../types";
|
|
3
|
+
import { TEST_POOL } from "./constants";
|
|
3
4
|
|
|
4
5
|
import { wallet } from "./wallet";
|
|
5
6
|
|
|
6
|
-
const myPool = "0xbae28251b2a4e621aa7e20538c06dee010bc06de";
|
|
7
|
-
|
|
8
|
-
// const weth = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
9
|
-
//const usdt = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
10
|
-
//const dai = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
|
|
11
|
-
//const usdc = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
12
|
-
// const sushi = "0x0b3F868E0BE5597D5DB7fEB59E1CADBb0fdDa50a";
|
|
13
|
-
// const wmatic = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
|
|
14
|
-
// const lpUsdcWeth = "0x34965ba0ac2451A34a0471F04CCa3F990b8dea27";
|
|
15
|
-
//const lpUsdcDai = "0xCD578F016888B57F1b1e3f887f392F0159E26747";
|
|
16
|
-
// const tradeAmountUsdc = "1000000";
|
|
17
|
-
// const liquidityAmountUsdt = "1000000";
|
|
18
|
-
// const lpUsdcWETHAmount = "10951027354";
|
|
19
|
-
// const depositAmountUsdc = "100000";
|
|
20
|
-
|
|
21
7
|
let dhedge: Dhedge;
|
|
22
8
|
|
|
23
9
|
jest.setTimeout(100000);
|
|
24
10
|
|
|
11
|
+
// const options = {
|
|
12
|
+
// gasLimit: 5000000,
|
|
13
|
+
// gasPrice: ethers.utils.parseUnits("35", "gwei")
|
|
14
|
+
// };
|
|
15
|
+
|
|
25
16
|
describe("pool", () => {
|
|
26
17
|
beforeAll(() => {
|
|
27
18
|
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
28
19
|
});
|
|
29
20
|
|
|
30
21
|
it("checks fund composition", async () => {
|
|
31
|
-
const pool = await dhedge.loadPool(
|
|
22
|
+
const pool = await dhedge.loadPool(TEST_POOL);
|
|
32
23
|
const result = await pool.getComposition();
|
|
24
|
+
console.log(result);
|
|
33
25
|
expect(result.length).toBeGreaterThan(0);
|
|
34
26
|
});
|
|
35
27
|
|
|
36
28
|
// it("withdraws 1.00002975 fund tokens", async () => {
|
|
37
|
-
// const pool = await dhedge.loadPool(myPool)
|
|
29
|
+
// const pool = await dhedge.loadPool(myPool);
|
|
38
30
|
// const result = await pool.withdraw("1000029750000000000");
|
|
39
31
|
// expect(result).toBeGreaterThan(0);
|
|
40
|
-
// })
|
|
41
|
-
|
|
42
|
-
// it("approves unlimited SUSHI on sushiswap", async () => {
|
|
43
|
-
// let result;
|
|
44
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
45
|
-
// try {
|
|
46
|
-
// result = await pool.approve(
|
|
47
|
-
// Dapp.SUSHISWAP,
|
|
48
|
-
// sushi,
|
|
49
|
-
// ethers.constants.MaxInt256
|
|
50
|
-
// );
|
|
51
|
-
// console.log(result);
|
|
52
|
-
// } catch (e) {
|
|
53
|
-
// console.log(e);
|
|
54
|
-
// }
|
|
55
|
-
// expect(result).not.toBe(null);
|
|
56
|
-
// });
|
|
57
|
-
|
|
58
|
-
// it("trades 0.5 USDC into USDT on sushiswap", async () => {
|
|
59
|
-
// let result;
|
|
60
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
61
|
-
// try {
|
|
62
|
-
// result = await pool.trade(Dapp.SUSHISWAP, usdc, usdt, "500000", "497382");
|
|
63
|
-
// } catch (e) {
|
|
64
|
-
// console.log(e);
|
|
65
|
-
// }
|
|
66
|
-
// expect(result).not.toBe(null);
|
|
67
32
|
// });
|
|
68
33
|
|
|
69
34
|
// it("approve USDC balance of User for Deposit", async () => {
|
|
@@ -95,9 +60,8 @@ describe("pool", () => {
|
|
|
95
60
|
// { asset: usdc, isDeposit: true },
|
|
96
61
|
// { asset: weth, isDeposit: true },
|
|
97
62
|
// { asset: usdt, isDeposit: true },
|
|
98
|
-
// { asset:
|
|
99
|
-
// { asset:
|
|
100
|
-
// { asset: wmatic, isDeposit: false }
|
|
63
|
+
// { asset: amusdc, isDeposit: false },
|
|
64
|
+
// { asset: lpUsdcUsdt, isDeposit: false }
|
|
101
65
|
// ];
|
|
102
66
|
// try {
|
|
103
67
|
// result = await pool.changeAssets(newAssets);
|
|
@@ -124,114 +88,6 @@ describe("pool", () => {
|
|
|
124
88
|
// expect(result).not.toBe(null);
|
|
125
89
|
// });
|
|
126
90
|
|
|
127
|
-
// it("adds Liquidity into a WETH/USDT pool on sushi", async () => {
|
|
128
|
-
// let result;
|
|
129
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
130
|
-
// const liquidityAmountWETH = await dhedge.utils.getLpAmount(
|
|
131
|
-
// Dapp.SUSHISWAP,
|
|
132
|
-
// usdt,
|
|
133
|
-
// weth,
|
|
134
|
-
// liquidityAmountUsdt
|
|
135
|
-
// );
|
|
136
|
-
// try {
|
|
137
|
-
// result = await pool.addLiquidity(
|
|
138
|
-
// Dapp.SUSHISWAP,
|
|
139
|
-
// usdt,
|
|
140
|
-
// weth,
|
|
141
|
-
// liquidityAmountUsdt,
|
|
142
|
-
// liquidityAmountWETH
|
|
143
|
-
// );
|
|
144
|
-
// } catch (e) {
|
|
145
|
-
// console.log(e);
|
|
146
|
-
// }
|
|
147
|
-
// expect(result).not.toBe(null);
|
|
148
|
-
// });
|
|
149
|
-
|
|
150
|
-
// it("approves unlimited LP USDC/WETH on sushiswap for staking", async () => {
|
|
151
|
-
// let result;
|
|
152
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
153
|
-
// try {
|
|
154
|
-
// result = await pool.approveStaking(
|
|
155
|
-
// Dapp.SUSHISWAP,
|
|
156
|
-
// lpUsdcDai,
|
|
157
|
-
// ethers.constants.MaxUint256
|
|
158
|
-
// );
|
|
159
|
-
// } catch (e) {
|
|
160
|
-
// console.log(e);
|
|
161
|
-
// }
|
|
162
|
-
// expect(result).not.toBe(null);
|
|
163
|
-
// });
|
|
164
|
-
|
|
165
|
-
// it("deposit 0.1 USDC into Pool", async () => {
|
|
166
|
-
// let result;
|
|
167
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
168
|
-
// try {
|
|
169
|
-
// result = await pool.deposit(usdc, depositAmountUsdc);
|
|
170
|
-
// } catch (e) {
|
|
171
|
-
// console.log(e);
|
|
172
|
-
// }
|
|
173
|
-
// expect(result).not.toBe(null);
|
|
174
|
-
// });
|
|
175
|
-
|
|
176
|
-
// it("adds LpUSDCWETH to enabled assets", async () => {
|
|
177
|
-
// let result;
|
|
178
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
179
|
-
// const newAssets: AssetEnabled[] = [
|
|
180
|
-
// { asset: usdc, isDeposit: true },
|
|
181
|
-
// { asset: weth, isDeposit: true },
|
|
182
|
-
// { asset: usdt, isDeposit: true },
|
|
183
|
-
// { asset: lpUsdcWeth, isDeposit: false }
|
|
184
|
-
// ];
|
|
185
|
-
// try {
|
|
186
|
-
// result = await pool.changeAssets(newAssets);
|
|
187
|
-
// console.log(result);
|
|
188
|
-
// } catch (e) {
|
|
189
|
-
// console.log(e);
|
|
190
|
-
// }
|
|
191
|
-
// expect(result).not.toBe(null);
|
|
192
|
-
// });
|
|
193
|
-
|
|
194
|
-
// it("unStakes USDC/DAI LP on sushi", async () => {
|
|
195
|
-
// let result;
|
|
196
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
197
|
-
// const balance = "11013356749811";
|
|
198
|
-
// try {
|
|
199
|
-
// result = await pool.unStake(Dapp.SUSHISWAP, lpUsdcDai, balance);
|
|
200
|
-
// console.log(result);
|
|
201
|
-
// } catch (e) {
|
|
202
|
-
// console.log(e);
|
|
203
|
-
// }
|
|
204
|
-
// expect(result).not.toBe(null);
|
|
205
|
-
// });
|
|
206
|
-
|
|
207
|
-
// it("trades entire sushi balance into usdc", async () => {
|
|
208
|
-
// let result: FundComposition[] = [];
|
|
209
|
-
// let tx;
|
|
210
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
211
|
-
// try {
|
|
212
|
-
// result = await pool.getComposition();
|
|
213
|
-
// const sushiBalance = result.find(e => e.asset === sushi)?.balance;
|
|
214
|
-
// if (sushiBalance) {
|
|
215
|
-
// tx = await pool.trade(Dapp.SUSHISWAP, sushi, usdc, sushiBalance);
|
|
216
|
-
// console.log(tx);
|
|
217
|
-
// }
|
|
218
|
-
// } catch (e) {
|
|
219
|
-
// console.log(e);
|
|
220
|
-
// }
|
|
221
|
-
// expect(result.length).toBeGreaterThan(0);
|
|
222
|
-
// });
|
|
223
|
-
|
|
224
|
-
// it("harvests USDC/DAI LP Farm on sushi", async () => {
|
|
225
|
-
// let result;
|
|
226
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
227
|
-
// try {
|
|
228
|
-
// result = await pool.harvestRewards(Dapp.SUSHISWAP, lpUsdcdai);
|
|
229
|
-
// } catch (e) {
|
|
230
|
-
// console.log(e);
|
|
231
|
-
// }
|
|
232
|
-
// expect(result).not.toBe(null);
|
|
233
|
-
// });
|
|
234
|
-
|
|
235
91
|
// it("sets a trader account", async () => {
|
|
236
92
|
// let result;
|
|
237
93
|
// const newTrader = "0xC52D9a9D9b05a01887871216fF02bA4235e8503d";
|
|
@@ -244,17 +100,4 @@ describe("pool", () => {
|
|
|
244
100
|
// }
|
|
245
101
|
// expect(result).not.toBe(null);
|
|
246
102
|
// });
|
|
247
|
-
|
|
248
|
-
// it("removes liquidity from USDC/DAI LP on sushi", async () => {
|
|
249
|
-
// let result;
|
|
250
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
251
|
-
// const balance = "11013356749811";
|
|
252
|
-
// try {
|
|
253
|
-
// result = await pool.removeLiquidity(Dapp.SUSHISWAP, usdc, dai, balance);
|
|
254
|
-
// console.log(result);
|
|
255
|
-
// } catch (e) {
|
|
256
|
-
// console.log(e);
|
|
257
|
-
// }
|
|
258
|
-
// expect(result).not.toBe(null);
|
|
259
|
-
// });
|
|
260
103
|
});
|