@dhedge/v2-sdk 1.5.4 → 1.7.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 +2 -1
- package/dist/entities/pool.d.ts +21 -1
- package/dist/entities/utils.d.ts +7 -2
- package/dist/services/lyra/markets.d.ts +6 -0
- package/dist/services/lyra/positions.d.ts +2 -0
- package/dist/services/lyra/quote.d.ts +4 -0
- package/dist/services/lyra/trade.d.ts +4 -0
- package/dist/services/lyra/tradeOptionType.d.ts +3 -0
- package/dist/test/constants.d.ts +1 -0
- package/dist/types.d.ts +20 -1
- package/dist/v2-sdk.cjs.development.js +4202 -12
- 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 +4200 -11
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +6 -2
- package/src/abi/IOptionMArketWrapper.json +1038 -0
- package/src/abi/IOptionMarket.json +1473 -0
- package/src/abi/IOptionToken.json +1671 -0
- package/src/config.ts +10 -5
- package/src/entities/pool.ts +61 -1
- package/src/entities/utils.ts +45 -2
- package/src/services/lyra/markets.ts +52 -0
- package/src/services/lyra/positions.ts +19 -0
- package/src/services/lyra/quote.ts +12 -0
- package/src/services/lyra/trade.ts +101 -0
- package/src/services/lyra/tradeOptionType.ts +19 -0
- package/src/test/constants.ts +1 -0
- package/src/test/lyra.test.ts +163 -0
- package/src/test/pool.test.ts +1 -1
- package/src/test/toros.test.ts +1 -1
- package/src/test/txOptions.ts +1 -1
- package/src/test/uniswap.test.ts +1 -1
- package/src/test/velodrome.test.ts +1 -1
- package/src/test/wallet.ts +8 -0
- package/src/types.ts +20 -1
- package/src/test/sushi.test.ts +0 -173
package/src/test/sushi.test.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Dhedge } from "..";
|
|
2
|
-
import { Dapp, Network } from "../types";
|
|
3
|
-
|
|
4
|
-
import { wallet } from "./wallet";
|
|
5
|
-
|
|
6
|
-
import { BAL, TEST_POOL, USDT } from "./constants";
|
|
7
|
-
|
|
8
|
-
const myPool = "0x3e5f7e9e7dc3bc3086ccebd5eb59a0a4a29d881b";
|
|
9
|
-
// const weth = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
10
|
-
// //const usdt = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
11
|
-
// //const dai = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
|
|
12
|
-
// const usdc = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
13
|
-
// const wbtc = "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6";
|
|
14
|
-
//const sushi = "0x0b3F868E0BE5597D5DB7fEB59E1CADBb0fdDa50a";
|
|
15
|
-
// const wmatic = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
|
|
16
|
-
// const lpUsdcWeth = "0x34965ba0ac2451A34a0471F04CCa3F990b8dea27";
|
|
17
|
-
//const lpUsdcDai = "0xCD578F016888B57F1b1e3f887f392F0159E26747";
|
|
18
|
-
//const amusdc = "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F";
|
|
19
|
-
//const lpUsdcUsdt = "0x4b1f1e2435a9c96f7330faea190ef6a7c8d70001";
|
|
20
|
-
// const tradeAmountUsdc = "1000000";
|
|
21
|
-
// const liquidityAmountUsdt = "1000000";
|
|
22
|
-
// const lpUsdcWETHAmount = "10951027354";
|
|
23
|
-
// const depositAmountUsdc = "100000";
|
|
24
|
-
|
|
25
|
-
let dhedge: Dhedge;
|
|
26
|
-
|
|
27
|
-
jest.setTimeout(100000);
|
|
28
|
-
|
|
29
|
-
// const options = {
|
|
30
|
-
// gasLimit: 5000000,
|
|
31
|
-
// gasPrice: ethers.utils.parseUnits("35", "gwei")
|
|
32
|
-
// };
|
|
33
|
-
|
|
34
|
-
describe("pool", () => {
|
|
35
|
-
beforeAll(() => {
|
|
36
|
-
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("adds Liquidity into a WETH/USDT pool on sushi", async () => {
|
|
40
|
-
let result;
|
|
41
|
-
const pool = await dhedge.loadPool(myPool);
|
|
42
|
-
const liquidityAmountWETH = await dhedge.utils.getLpAmount(
|
|
43
|
-
Dapp.SUSHISWAP,
|
|
44
|
-
USDT,
|
|
45
|
-
WETH,
|
|
46
|
-
liquidityAmountUsdt
|
|
47
|
-
);
|
|
48
|
-
try {
|
|
49
|
-
result = await pool.addLiquidity(
|
|
50
|
-
Dapp.SUSHISWAP,
|
|
51
|
-
usdt,
|
|
52
|
-
weth,
|
|
53
|
-
liquidityAmountUsdt,
|
|
54
|
-
liquidityAmountWETH
|
|
55
|
-
);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.log(e);
|
|
58
|
-
}
|
|
59
|
-
expect(result).not.toBe(null);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// it("approves unlimited LP USDC/WETH on sushiswap for staking", async () => {
|
|
63
|
-
// let result;
|
|
64
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
65
|
-
// try {
|
|
66
|
-
// result = await pool.approveStaking(
|
|
67
|
-
// Dapp.SUSHISWAP,
|
|
68
|
-
// lpUsdcDai,
|
|
69
|
-
// ethers.constants.MaxUint256
|
|
70
|
-
// );
|
|
71
|
-
// } catch (e) {
|
|
72
|
-
// console.log(e);
|
|
73
|
-
// }
|
|
74
|
-
// expect(result).not.toBe(null);
|
|
75
|
-
// });
|
|
76
|
-
|
|
77
|
-
// it("deposit 0.1 USDC into Pool", async () => {
|
|
78
|
-
// let result;
|
|
79
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
80
|
-
// try {
|
|
81
|
-
// result = await pool.deposit(usdc, depositAmountUsdc);
|
|
82
|
-
// } catch (e) {
|
|
83
|
-
// console.log(e);
|
|
84
|
-
// }
|
|
85
|
-
// expect(result).not.toBe(null);
|
|
86
|
-
// });
|
|
87
|
-
|
|
88
|
-
// it("adds LpUSDCWETH to enabled assets", async () => {
|
|
89
|
-
// let result;
|
|
90
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
91
|
-
// const newAssets: AssetEnabled[] = [
|
|
92
|
-
// { asset: usdc, isDeposit: true },
|
|
93
|
-
// { asset: weth, isDeposit: true },
|
|
94
|
-
// { asset: usdt, isDeposit: true },
|
|
95
|
-
// { asset: lpUsdcWeth, isDeposit: false }
|
|
96
|
-
// ];
|
|
97
|
-
// try {
|
|
98
|
-
// result = await pool.changeAssets(newAssets);
|
|
99
|
-
// console.log(result);
|
|
100
|
-
// } catch (e) {
|
|
101
|
-
// console.log(e);
|
|
102
|
-
// }
|
|
103
|
-
// expect(result).not.toBe(null);
|
|
104
|
-
// });
|
|
105
|
-
|
|
106
|
-
// it("unStakes USDC/DAI LP on sushi", async () => {
|
|
107
|
-
// let result;
|
|
108
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
109
|
-
// const balance = "11013356749811";
|
|
110
|
-
// try {
|
|
111
|
-
// result = await pool.unStake(Dapp.SUSHISWAP, lpUsdcDai, balance);
|
|
112
|
-
// console.log(result);
|
|
113
|
-
// } catch (e) {
|
|
114
|
-
// console.log(e);
|
|
115
|
-
// }
|
|
116
|
-
// expect(result).not.toBe(null);
|
|
117
|
-
// });
|
|
118
|
-
|
|
119
|
-
// it("trades entire sushi balance into usdc", async () => {
|
|
120
|
-
// let result: FundComposition[] = [];
|
|
121
|
-
// let tx;
|
|
122
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
123
|
-
// try {
|
|
124
|
-
// result = await pool.getComposition();
|
|
125
|
-
// const sushiBalance = result.find(e => e.asset === sushi)?.balance;
|
|
126
|
-
// if (sushiBalance) {
|
|
127
|
-
// tx = await pool.trade(Dapp.SUSHISWAP, sushi, usdc, sushiBalance);
|
|
128
|
-
// console.log(tx);
|
|
129
|
-
// }
|
|
130
|
-
// } catch (e) {
|
|
131
|
-
// console.log(e);
|
|
132
|
-
// }
|
|
133
|
-
// expect(result.length).toBeGreaterThan(0);
|
|
134
|
-
// });
|
|
135
|
-
|
|
136
|
-
// it("harvests USDC/DAI LP Farm on sushi", async () => {
|
|
137
|
-
// let result;
|
|
138
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
139
|
-
// try {
|
|
140
|
-
// result = await pool.harvestRewards(Dapp.SUSHISWAP, lpUsdcdai);
|
|
141
|
-
// } catch (e) {
|
|
142
|
-
// console.log(e);
|
|
143
|
-
// }
|
|
144
|
-
// expect(result).not.toBe(null);
|
|
145
|
-
// });
|
|
146
|
-
|
|
147
|
-
// it("sets a trader account", async () => {
|
|
148
|
-
// let result;
|
|
149
|
-
// const newTrader = "0xC52D9a9D9b05a01887871216fF02bA4235e8503d";
|
|
150
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
151
|
-
// try {
|
|
152
|
-
// result = await pool.setTrader(newTrader);
|
|
153
|
-
// console.log(result);
|
|
154
|
-
// } catch (e) {
|
|
155
|
-
// console.log(e);
|
|
156
|
-
// }
|
|
157
|
-
// expect(result).not.toBe(null);
|
|
158
|
-
// });
|
|
159
|
-
|
|
160
|
-
// it("removes liquidity from USDC/DAI LP on sushi", async () => {
|
|
161
|
-
// let result;
|
|
162
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
163
|
-
// const balance = "11013356749811";
|
|
164
|
-
// try {
|
|
165
|
-
// result = await pool.removeLiquidity(Dapp.SUSHISWAP, usdc, dai, balance);
|
|
166
|
-
// console.log(result);
|
|
167
|
-
// } catch (e) {
|
|
168
|
-
// console.log(e);
|
|
169
|
-
// }
|
|
170
|
-
// expect(result).not.toBe(null);
|
|
171
|
-
// });
|
|
172
|
-
|
|
173
|
-
});
|