@dhedge/v2-sdk 1.9.6 → 1.9.8
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 +213 -76
- package/dist/entities/pool.d.ts +16 -10
- package/dist/test/constants.d.ts +22 -0
- package/dist/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +180 -75
- 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 +180 -75
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +4 -2
- package/src/entities/pool.ts +52 -10
- package/src/test/aerodrome.test.ts +154 -0
- package/src/test/arrakis.test.ts +119 -75
- package/src/test/constants.ts +32 -4
- package/src/test/uniswap.test.ts +101 -72
- package/src/types.ts +2 -1
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/merkle.d.ts +0 -22
- package/src/utils/index.ts +0 -38
- package/src/utils/merkle.ts +0 -172
package/README.md
CHANGED
|
@@ -9,27 +9,76 @@
|
|
|
9
9
|
- Easy-to-use functions to trade assets, provide liquidity or stake assets
|
|
10
10
|
- Useful for creating automated trading bots
|
|
11
11
|
- Use in your Javascript or Typescript project with full Typescript source
|
|
12
|
+
- All protocols and networks of [dHEDGE App](https://dhedge.org/management/create) are supported
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
15
16
|
### Node
|
|
16
17
|
|
|
17
|
-
```
|
|
18
|
+
```bash
|
|
18
19
|
npm install @dhedge/v2-sdk
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
### Yarn
|
|
22
23
|
|
|
23
|
-
```
|
|
24
|
+
```bash
|
|
24
25
|
yarn add @dhedge/v2-sdk
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
## Usage
|
|
28
29
|
|
|
30
|
+
### Table of Contents
|
|
31
|
+
|
|
32
|
+
<ol>
|
|
33
|
+
<li>
|
|
34
|
+
<a href="#initial-setup">Initial setup</a>
|
|
35
|
+
</li>
|
|
36
|
+
<li>
|
|
37
|
+
<a href="#general-pool-management">General Pool Management</a>
|
|
38
|
+
<ul>
|
|
39
|
+
<li><a href="#1-create-pool">Create pool</a></li>
|
|
40
|
+
<li><a href="#2-load-pool">Load pool</a></li>
|
|
41
|
+
<li><a href="#3-get-pool-composition">Get pool composition</a></li>
|
|
42
|
+
<li><a href="#4-change-pool-assets-enabledisable">Change pool assets</a></li>
|
|
43
|
+
<li><a href="#5-set-trader">Set trader</a></li>
|
|
44
|
+
<li><a href="#6-approve-asset-for-deposit">Approve asset for deposit</a></li>
|
|
45
|
+
<li><a href="#7-deposit-asset-into-pool">Deposit asset into pool</a></li>
|
|
46
|
+
<li><a href="#8-withdraw-from-pool">Withdraw from pool</a></li>
|
|
47
|
+
<li><a href="#9-approve-pool-asset-for-trading--staking)">Approve pool asset for trading & staking</a></li>
|
|
48
|
+
<li><a href="#10-trade-pool-assets">Trade pool assets</a></li>
|
|
49
|
+
</ul>
|
|
50
|
+
</li>
|
|
51
|
+
<li>
|
|
52
|
+
<a href="#liquidity">Liquidity</a>
|
|
53
|
+
<ul>
|
|
54
|
+
<li>
|
|
55
|
+
<a href="#uniswap-v2-style">Uniswap-v2 style protocols </a>
|
|
56
|
+
</li>
|
|
57
|
+
<li>
|
|
58
|
+
<a href="#balancer">Balancer</a>
|
|
59
|
+
</li>
|
|
60
|
+
<li>
|
|
61
|
+
<a href="#uniswap-v3-style">Uniswap-v3 style protocols</a>
|
|
62
|
+
</li>
|
|
63
|
+
<li>
|
|
64
|
+
<a href="#velodromev2--ramses">VelodromeV2 / Ramses / Aerodrome</a>
|
|
65
|
+
</li>
|
|
66
|
+
</ul>
|
|
67
|
+
</li>
|
|
68
|
+
<li>
|
|
69
|
+
<a href="#lendingborrowing-aave">Lending/Borrowing Aave</a>
|
|
70
|
+
</li>
|
|
71
|
+
|
|
72
|
+
</ol>
|
|
73
|
+
|
|
74
|
+
<br>
|
|
75
|
+
|
|
29
76
|
### Initial setup
|
|
30
77
|
|
|
78
|
+
---
|
|
79
|
+
|
|
31
80
|
If you want to use 1Inch to trade pool assets you need to apply for an API key at [1Inch Dev Portal](https://docs.1inch.io/docs/aggregation-protocol/introduction).
|
|
32
|
-
Then you need to copy .env.example file to .env and set your
|
|
81
|
+
Then you need to copy .env.example file to .env and set your API key there.
|
|
33
82
|
|
|
34
83
|
```
|
|
35
84
|
ONEINCH_API_KEY=YOUR_API_KEY_FROM_1INCH
|
|
@@ -37,7 +86,7 @@ ONEINCH_API_KEY=YOUR_API_KEY_FROM_1INCH
|
|
|
37
86
|
|
|
38
87
|
Initialize the sdk with an [ethers wallet](https://docs.ethers.io/v5/api/signer/#Wallet) and the network.
|
|
39
88
|
|
|
40
|
-
```
|
|
89
|
+
```ts
|
|
41
90
|
import { Dhedge, Dapp, Network, ethers } from "@dhedge/v2-sdk";
|
|
42
91
|
|
|
43
92
|
const privateKey = "YOUR_PRIVATE_KEY";
|
|
@@ -49,13 +98,17 @@ const walletWithProvider = new ethers.Wallet(privateKey, provider);
|
|
|
49
98
|
const dhedge = new Dhedge(walletWithProvider, Network.POLYGON);
|
|
50
99
|
```
|
|
51
100
|
|
|
52
|
-
|
|
101
|
+
<br>
|
|
102
|
+
|
|
103
|
+
### General Pool Management
|
|
53
104
|
|
|
54
|
-
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
#### 1. Create a pool
|
|
55
108
|
|
|
56
109
|
USDC and DAI enabled assets, but only USDC available for deposit.
|
|
57
110
|
|
|
58
|
-
```
|
|
111
|
+
```ts
|
|
59
112
|
const usdcTokenAddress = "USDC_TOKEN_ADDRESS"
|
|
60
113
|
const daiTokenAddress = "DAI_TOKEN_ADDRESS"
|
|
61
114
|
const pool = await dhedge.createPool(
|
|
@@ -71,24 +124,24 @@ const pool = await dhedge.createPool(
|
|
|
71
124
|
console.log("created pool with address", pool.address)
|
|
72
125
|
```
|
|
73
126
|
|
|
74
|
-
|
|
127
|
+
#### 2. Load pool
|
|
75
128
|
|
|
76
|
-
```
|
|
129
|
+
```ts
|
|
77
130
|
const poolAddress = "YOUR_POOL_ADDRESS"
|
|
78
131
|
const pool = await dhedge.loadPool(poolAddress)
|
|
79
132
|
```
|
|
80
133
|
|
|
81
|
-
|
|
134
|
+
#### 3. Get pool composition
|
|
82
135
|
|
|
83
|
-
```
|
|
136
|
+
```ts
|
|
84
137
|
const composition = await pool.getComposition();
|
|
85
138
|
```
|
|
86
139
|
|
|
87
|
-
|
|
140
|
+
#### 4. Change pool assets (enable/disable)
|
|
88
141
|
|
|
89
142
|
Change pool assets to allow DAI for deposits. Also enable WETH as an asset, but shouldn't be allowed as deposit.
|
|
90
143
|
|
|
91
|
-
```
|
|
144
|
+
```ts
|
|
92
145
|
const enabledAssets = [
|
|
93
146
|
{ asset: "USDC_TOKEN_ADDRESS", isDeposit: true },
|
|
94
147
|
{ asset: "DAI_TOKEN_ADDRESS", isDeposit: true },
|
|
@@ -97,49 +150,49 @@ const enabledAssets = [
|
|
|
97
150
|
const tx = await pool.changeAssets(enabledAssets)
|
|
98
151
|
```
|
|
99
152
|
|
|
100
|
-
|
|
153
|
+
#### 5. Set trader
|
|
101
154
|
|
|
102
155
|
Set an account with trading permissions
|
|
103
156
|
|
|
104
|
-
```
|
|
157
|
+
```ts
|
|
105
158
|
const tx = await pool.setTrader("TRADER_ACCOUNT_ADDRESS")
|
|
106
159
|
```
|
|
107
160
|
|
|
108
|
-
|
|
161
|
+
#### 6. Approve asset for deposit
|
|
109
162
|
|
|
110
163
|
Before depositing an asset into a Pool, it needs to be approved.
|
|
111
164
|
|
|
112
165
|
Approve unlimited amount of USDC to deposit into Pool.
|
|
113
166
|
|
|
114
|
-
```
|
|
167
|
+
```ts
|
|
115
168
|
const tx = await pool.approveDeposit("USDC_TOKEN_ADDRESS", ethers.constants.MaxUint256);
|
|
116
169
|
```
|
|
117
170
|
|
|
118
|
-
|
|
171
|
+
#### 7. Deposit asset into pool
|
|
119
172
|
|
|
120
173
|
Deposit 1 USDC into Pool
|
|
121
174
|
|
|
122
|
-
```
|
|
175
|
+
```ts
|
|
123
176
|
const usdcDepositAmount = "100000"
|
|
124
177
|
const tx = await pool.deposit("USDC_TOKEN_ADDRESS", usdcDepositAmount);
|
|
125
178
|
```
|
|
126
179
|
|
|
127
|
-
|
|
180
|
+
#### 8. Withdraw from pool
|
|
128
181
|
|
|
129
182
|
Withdraw 1.00002975 pool tokens. Note that this cannot be called if set as Trader account
|
|
130
183
|
|
|
131
|
-
```
|
|
184
|
+
```ts
|
|
132
185
|
const poolTokensWithdrawAmount = "1000029750000000000"
|
|
133
186
|
const tx = await pool.withdraw(poolTokensWithdrawAmount);
|
|
134
187
|
```
|
|
135
188
|
|
|
136
|
-
|
|
189
|
+
#### 9. Approve pool asset for trading & staking
|
|
137
190
|
|
|
138
191
|
Before trading an asset on platforms like Sushiswap it needs to be approved.
|
|
139
192
|
|
|
140
193
|
Approve unlimited amount of USDC to trade on Sushiswap
|
|
141
194
|
|
|
142
|
-
```
|
|
195
|
+
```ts
|
|
143
196
|
const tx = await pool.approve(
|
|
144
197
|
Dapp.SUSHISWAP,
|
|
145
198
|
"USDC_TOKEN_ADDRESS",
|
|
@@ -147,11 +200,11 @@ const tx = await pool.approve(
|
|
|
147
200
|
)
|
|
148
201
|
```
|
|
149
202
|
|
|
150
|
-
|
|
203
|
+
#### 10. Trade pool assets
|
|
151
204
|
|
|
152
|
-
Trade 1 USDC into DAI on Sushiswap (other options: QUICKSWAP, BALANCER, or ONEINCH)
|
|
205
|
+
Trade 1 USDC into DAI on Sushiswap (other options: TOROS, QUICKSWAP, BALANCER, or ONEINCH)
|
|
153
206
|
|
|
154
|
-
```
|
|
207
|
+
```ts
|
|
155
208
|
const amountIn = "1000000"
|
|
156
209
|
const slippage = 0.5
|
|
157
210
|
const tx = await pool.trade(
|
|
@@ -165,9 +218,15 @@ const tx = await pool.trade(
|
|
|
165
218
|
|
|
166
219
|
### Liquidity
|
|
167
220
|
|
|
168
|
-
|
|
221
|
+
---
|
|
169
222
|
|
|
170
|
-
|
|
223
|
+
#### Uniswap-v2 style
|
|
224
|
+
|
|
225
|
+
For Uniswap-v2 like protocols, such as sushiswap, we use `addLiquidity`, `removeLiquidity`, `stake`, and `unstake`, and `harvestRewards`
|
|
226
|
+
|
|
227
|
+
1. Add USDC/DAI into a Sushiswap liquidity pool
|
|
228
|
+
|
|
229
|
+
```ts
|
|
171
230
|
const amountUsdc = "1000000"
|
|
172
231
|
const amountDai = "997085"
|
|
173
232
|
const tx = await pool.addLiquidity(
|
|
@@ -179,9 +238,9 @@ const tx = await pool.addLiquidity(
|
|
|
179
238
|
)
|
|
180
239
|
```
|
|
181
240
|
|
|
182
|
-
Remove USDC/DAI worth of 1 Sushiswap LP from the liquidity pool
|
|
241
|
+
2. Remove USDC/DAI worth of 1 Sushiswap LP from the liquidity pool
|
|
183
242
|
|
|
184
|
-
```
|
|
243
|
+
```ts
|
|
185
244
|
const amountSlpUsdcDai = "1000000000000000000"
|
|
186
245
|
const tx = await pool.removeLiquidity(
|
|
187
246
|
Dapp.SUSHISWAP,
|
|
@@ -191,33 +250,9 @@ const tx = await pool.removeLiquidity(
|
|
|
191
250
|
)
|
|
192
251
|
```
|
|
193
252
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
```
|
|
197
|
-
const balancerPoolId = "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a"
|
|
198
|
-
const assets = [WBTC_TOKEN_ADDRESS, USDC_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS];
|
|
199
|
-
const amounts = ["2000", "1000000", "200000000000000"];
|
|
200
|
-
const tx = await pool.joinBalancerPool(balancerPoolId, assets, amounts)
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Remove all tokens from WBTC/USDC/WETH Balancer pool
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
const amount = await dhedge.utils.getBalance(BALANCER_LP_TOKEN_ADDRESS, pool.address)
|
|
207
|
-
const tx = await pool.exitBalancerPool(balancerPoolId, assets, amount)
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Harvest rewards from Balancer
|
|
253
|
+
3. Approve unlimited amound of SLP USDC-DAI token for staking on Sushiswap
|
|
211
254
|
|
|
212
|
-
```
|
|
213
|
-
const tx = await pool.harvestBalancerRewards()
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Staking
|
|
217
|
-
|
|
218
|
-
Approve unlimited amound of SLP USDC-DAI token for staking on Sushiswap
|
|
219
|
-
|
|
220
|
-
```
|
|
255
|
+
```ts
|
|
221
256
|
const tx = await pool.approveStaking(
|
|
222
257
|
Dapp.SUSHISWAP,
|
|
223
258
|
"SLP_USDC_DAI_TOKEN_ADDRESS",
|
|
@@ -225,9 +260,9 @@ const tx = await pool.approveStaking(
|
|
|
225
260
|
)
|
|
226
261
|
```
|
|
227
262
|
|
|
228
|
-
Stake 1 Sushiswap LP USDC/DAI token
|
|
263
|
+
4. Stake 1 Sushiswap LP USDC/DAI token
|
|
229
264
|
|
|
230
|
-
```
|
|
265
|
+
```ts
|
|
231
266
|
const amountSlpUsdcDai = "1000000000000000000"
|
|
232
267
|
const tx = await pool.stake(
|
|
233
268
|
Dapp.SUSHISWAP,
|
|
@@ -236,9 +271,9 @@ const tx = await pool.stake(
|
|
|
236
271
|
)
|
|
237
272
|
```
|
|
238
273
|
|
|
239
|
-
Unstake 1 Sushiswap LP USDC/DAI token
|
|
274
|
+
5. Unstake 1 Sushiswap LP USDC/DAI token
|
|
240
275
|
|
|
241
|
-
```
|
|
276
|
+
```ts
|
|
242
277
|
const amountSlpUsdcDai = "1000000000000000000"
|
|
243
278
|
const tx = await pool.unstake(
|
|
244
279
|
Dapp.SUSHISWAP,
|
|
@@ -247,46 +282,148 @@ const tx = await pool.unstake(
|
|
|
247
282
|
)
|
|
248
283
|
```
|
|
249
284
|
|
|
250
|
-
Harvest rewards from staked Sushiswap LP USDC/DAI tokens
|
|
285
|
+
6. Harvest rewards from staked Sushiswap LP USDC/DAI tokens
|
|
251
286
|
|
|
252
|
-
```
|
|
287
|
+
```ts
|
|
253
288
|
const tx = await pool.harvestRewards(
|
|
254
289
|
Dapp.SUSHISWAP,
|
|
255
290
|
"SLP_USDC_DAI_TOKEN_ADDRESS"
|
|
256
291
|
)
|
|
257
292
|
```
|
|
258
293
|
|
|
259
|
-
|
|
294
|
+
#### Balancer
|
|
295
|
+
|
|
296
|
+
For Balancer, we use `joinBalancerPool`, `exitBalancerPool`, and `harvestBalancerRewards`
|
|
260
297
|
|
|
261
|
-
|
|
298
|
+
1. Add 0.00002 WBTC, 1 USDC and 0.0002 WETH to a WBTC/USDC/WETH Balancer pool
|
|
262
299
|
|
|
300
|
+
```ts
|
|
301
|
+
const balancerPoolId = "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a"
|
|
302
|
+
const assets = [WBTC_TOKEN_ADDRESS, USDC_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS];
|
|
303
|
+
const amounts = ["2000", "1000000", "200000000000000"];
|
|
304
|
+
const tx = await pool.joinBalancerPool(balancerPoolId, assets, amounts)
|
|
263
305
|
```
|
|
264
|
-
|
|
306
|
+
|
|
307
|
+
2. Remove all tokens from WBTC/USDC/WETH Balancer pool
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
const amount = await dhedge.utils.getBalance(BALANCER_LP_TOKEN_ADDRESS, pool.address)
|
|
311
|
+
const tx = await pool.exitBalancerPool(balancerPoolId, assets, amount)
|
|
265
312
|
```
|
|
266
313
|
|
|
267
|
-
|
|
314
|
+
3. Harvest rewards from Balancer
|
|
268
315
|
|
|
316
|
+
```ts
|
|
317
|
+
const tx = await pool.harvestBalancerRewards()
|
|
269
318
|
```
|
|
270
|
-
|
|
319
|
+
|
|
320
|
+
#### Uniswap-v3 style
|
|
321
|
+
|
|
322
|
+
For Arrakis, we use `increaseLiquidity` to stake or increase lp, and `decreaseLiquidity`, and `claimFees`. see example in the [arrakis test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/arrakis.test.ts)
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
For Uniswap v3, we use `approveUniswapV3Liquidity`, `addLiquidityUniswapV3`, `decreaseLiquidity`, `increaseLiquidity`, and `claimFees`.
|
|
327
|
+
|
|
328
|
+
1. Add liquidity of 100 USDC and 0.00043 WETH to a UniswapV3 pool (here price range is used)
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
|
|
332
|
+
await pool.approveUniswapV3Liquidity(
|
|
333
|
+
USDC_ADDRESS,
|
|
334
|
+
ethers.constants.MaxInt256
|
|
335
|
+
);
|
|
336
|
+
await pool.approveUniswapV3Liquidity(
|
|
337
|
+
WETH_ADDRESS,
|
|
338
|
+
ethers.constants.MaxInt256
|
|
339
|
+
);
|
|
340
|
+
const tx = await pool.addLiquidityUniswapV3(
|
|
341
|
+
WETH_ADDRESS
|
|
342
|
+
USDC_ADDRESS,
|
|
343
|
+
'430000000000000', // wethBalance
|
|
344
|
+
'100000000', // usdcBalance
|
|
345
|
+
2000,
|
|
346
|
+
3000,
|
|
347
|
+
null,
|
|
348
|
+
null,
|
|
349
|
+
FeeAmount.MEDIUM,
|
|
350
|
+
)
|
|
271
351
|
```
|
|
272
352
|
|
|
273
|
-
|
|
353
|
+
2. Remove 50% liquidity from the existing pool
|
|
274
354
|
|
|
355
|
+
```ts
|
|
356
|
+
tokenId = await nonfungiblePositionManager.tokenOfOwnerByIndex(pool.address,0).toString();
|
|
357
|
+
const tx = await pool.decreaseLiquidity(
|
|
358
|
+
Dapp.UNISWAPV3,
|
|
359
|
+
tokenId,
|
|
360
|
+
50 // precent
|
|
361
|
+
);
|
|
275
362
|
```
|
|
276
|
-
|
|
363
|
+
|
|
364
|
+
3. Increase liquidity in the existing WETH/USDC pool
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
const result = await pool.increaseLiquidity(
|
|
368
|
+
Dapp.UNISWAPV3,
|
|
369
|
+
tokenId,
|
|
370
|
+
new BigNumber(3000).times(1e6).toFixed(0), // usdc
|
|
371
|
+
new BigNumber(1).times(1e18).toFixed(0) // eth
|
|
372
|
+
);
|
|
277
373
|
```
|
|
278
374
|
|
|
279
|
-
|
|
375
|
+
4. Claim fees
|
|
280
376
|
|
|
377
|
+
```ts
|
|
378
|
+
const tx = await pool.claimFees(Dapp.UNISWAPV3, tokenId);
|
|
281
379
|
```
|
|
282
|
-
|
|
380
|
+
|
|
381
|
+
#### VelodromeV2 / Ramses / Aerodrome
|
|
382
|
+
|
|
383
|
+
For VelodromeV2 / Ramses / Aerodrome , we use `addLiquidityV2`, `stakeInGauge`, `unstakeFromGauge`, `removeLiquidityV2`, and `claimFees`.
|
|
384
|
+
|
|
385
|
+
Add liquidity of 100 USDC and 0.00043 WETH to USDC/WETH Ramses pool
|
|
386
|
+
(for Velodrome just use Dapp.VELODROMEV2, for Aerodrome Dapp.AERODROME). see example in the [arrakis test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/ramses.test.ts), [velodromeV2 test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/velodromeV2.test.ts) and [aerdodrome test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/aerdodrome.test.ts)
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
const tx = await pool.addLiquidityV2(
|
|
390
|
+
Dapp.RAMSES,
|
|
391
|
+
USDC_ADDRESS,
|
|
392
|
+
WETH_ADDRESS,
|
|
393
|
+
'10000000',
|
|
394
|
+
'430000000000000',
|
|
395
|
+
false
|
|
396
|
+
)
|
|
283
397
|
```
|
|
284
398
|
|
|
285
|
-
|
|
399
|
+
<br>
|
|
286
400
|
|
|
401
|
+
### Lending/Borrowing Aave
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
For Aave, we use `lend`, `withdrawDeposit`, `borrow` and `repay`
|
|
406
|
+
|
|
407
|
+
##### 1. Deposit 1 USDC into Aave lending pool
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
const tx = await pool.lend(Dapp.AAVE, USDC_TOKEN_ADDRESS, "1000000")
|
|
287
411
|
```
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
412
|
+
|
|
413
|
+
##### 2. Withdraw 1 USDC from Aave lending pool
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
const tx = await pool.withdrawDeposit(Dapp.AAVE, USDC_TOKEN_ADDRESS, "1000000")
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
##### 3. Borrow 0.0001 WETH from Aave lending pool
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
const tx = await pool.borrow(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
##### 4. Repay 0.0001 WETH to Aave lending pool
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
const tx = await pool.repay(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
|
|
292
429
|
```
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -21,24 +21,27 @@ export declare class Pool {
|
|
|
21
21
|
* @param {string} nasset Address of deposit asset
|
|
22
22
|
* @param {BigNumber | string} amount Amount to be approved
|
|
23
23
|
* @param {any} options Transaction options
|
|
24
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
24
25
|
* @returns {Promise<any>} Transaction
|
|
25
26
|
*/
|
|
26
|
-
approveDeposit(asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
27
|
+
approveDeposit(asset: string, amount: BigNumber | string, options?: any, estimateGas?: boolean): Promise<any>;
|
|
27
28
|
/**
|
|
28
29
|
* Deposit asset into a pool
|
|
29
30
|
* @param {string} asset Address of asset
|
|
30
31
|
* @param {BigNumber | string} amount Amount to be deposited
|
|
31
32
|
* @param {any} options Transaction options
|
|
33
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
32
34
|
* @returns {Promise<any>} Transaction
|
|
33
35
|
*/
|
|
34
|
-
deposit(asset: string, amount: string | BigNumber, options?: any): Promise<any>;
|
|
36
|
+
deposit(asset: string, amount: string | BigNumber, options?: any, estimateGas?: boolean): Promise<any>;
|
|
35
37
|
/**
|
|
36
38
|
* Withdraw assets from a pool
|
|
37
39
|
* @param fundTokenAmount Amount of pool tokens to be withdrawn
|
|
38
40
|
* @param {any} options Transaction options
|
|
41
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
39
42
|
* @returns {Promise<any>} Transaction
|
|
40
43
|
*/
|
|
41
|
-
withdraw(fundTokenAmount: string | BigNumber, options?: any): Promise<any>;
|
|
44
|
+
withdraw(fundTokenAmount: string | BigNumber, options?: any, estimateGas?: boolean): Promise<any>;
|
|
42
45
|
/**
|
|
43
46
|
* Approve the asset for trading and providing liquidity
|
|
44
47
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
@@ -208,16 +211,18 @@ export declare class Pool {
|
|
|
208
211
|
* Change enabled pool assets
|
|
209
212
|
* @param {AssetEnabled[]} assets New pool assets
|
|
210
213
|
* @param {any} options Transaction options
|
|
214
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
211
215
|
* @returns {Promise<any>} Transaction
|
|
212
216
|
*/
|
|
213
|
-
changeAssets(assets: AssetEnabled[], options?: any): Promise<any>;
|
|
217
|
+
changeAssets(assets: AssetEnabled[], options?: any, estimateGas?: boolean): Promise<any>;
|
|
214
218
|
/**
|
|
215
219
|
* Set a new trader with trading permissions
|
|
216
220
|
* @param {string} trader Address trader account
|
|
217
221
|
* @param {any} options Transaction options
|
|
222
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
218
223
|
* @returns {Promise<any>} Transaction
|
|
219
224
|
*/
|
|
220
|
-
setTrader(trader: string, options?: any): Promise<any>;
|
|
225
|
+
setTrader(trader: string, options?: any, estimateGas?: boolean): Promise<any>;
|
|
221
226
|
/**
|
|
222
227
|
* Invest into a Balancer pool
|
|
223
228
|
* @param {string} poolId Balancer pool id
|
|
@@ -363,7 +368,7 @@ export declare class Pool {
|
|
|
363
368
|
removeLiquidityVelodromeV2(assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
|
|
364
369
|
/**
|
|
365
370
|
* Add liquidity to Velodrome V2 or Ramses pool
|
|
366
|
-
* @param {Dapp} dapp VelodromeV2 or
|
|
371
|
+
* @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
|
|
367
372
|
* @param {string} assetA First asset
|
|
368
373
|
* @param {string} assetB Second asset
|
|
369
374
|
* @param {BigNumber | string} amountA Amount first asset
|
|
@@ -373,10 +378,10 @@ export declare class Pool {
|
|
|
373
378
|
* @param {boolean} estimateGas Simulate/estimate gas
|
|
374
379
|
* @returns {Promise<any>} Transaction
|
|
375
380
|
*/
|
|
376
|
-
addLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
|
|
381
|
+
addLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
|
|
377
382
|
/**
|
|
378
383
|
* Remove liquidity from Velodrome V2 or Ramses pool
|
|
379
|
-
* @param {Dapp} dapp VelodromeV2 or
|
|
384
|
+
* @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
|
|
380
385
|
* @param {string} assetA First asset
|
|
381
386
|
* @param {string} assetB Second asset
|
|
382
387
|
* @param {BigNumber | string} amount Amount of LP tokens
|
|
@@ -385,7 +390,7 @@ export declare class Pool {
|
|
|
385
390
|
* @param {boolean} estimateGas Simulate/estimate gas
|
|
386
391
|
* @returns {Promise<any>} Transaction
|
|
387
392
|
*/
|
|
388
|
-
removeLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES, assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
|
|
393
|
+
removeLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME, assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
|
|
389
394
|
/**
|
|
390
395
|
* Trade options on lyra
|
|
391
396
|
* @param {LyraOptionMarket} market Underlying market e.g. eth
|
|
@@ -436,9 +441,10 @@ export declare class Pool {
|
|
|
436
441
|
/**
|
|
437
442
|
* mintManagerFee
|
|
438
443
|
* @param {any} options Transaction options
|
|
444
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
439
445
|
* @returns {Promise<any>} Transaction
|
|
440
446
|
*/
|
|
441
|
-
mintManagerFee(options?: any): Promise<any>;
|
|
447
|
+
mintManagerFee(options?: any, estimateGas?: boolean): Promise<any>;
|
|
442
448
|
/**
|
|
443
449
|
* getAvailableManagerFee
|
|
444
450
|
* @returns {Promise<BigNumber>} fee
|
package/dist/test/constants.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export declare const CONTRACT_ADDRESS: {
|
|
|
27
27
|
WBTC: string;
|
|
28
28
|
ARRAKIS_USDC_WETH_GAUGE: string;
|
|
29
29
|
ARRAKIS_USDC_WETH_LP: string;
|
|
30
|
+
WMATIC: string;
|
|
31
|
+
uniswapV3: {
|
|
32
|
+
nonfungiblePositionManager: string;
|
|
33
|
+
};
|
|
30
34
|
};
|
|
31
35
|
optimism: {
|
|
32
36
|
USDC: string;
|
|
@@ -35,6 +39,12 @@ export declare const CONTRACT_ADDRESS: {
|
|
|
35
39
|
WETH: string;
|
|
36
40
|
WBTC: string;
|
|
37
41
|
KWENTA_ETH_PERP_V2: string;
|
|
42
|
+
uniswapV3: {
|
|
43
|
+
nonfungiblePositionManager: string;
|
|
44
|
+
};
|
|
45
|
+
WMATIC: string;
|
|
46
|
+
ARRAKIS_USDC_WETH_GAUGE: string;
|
|
47
|
+
ARRAKIS_USDC_WETH_LP: string;
|
|
38
48
|
};
|
|
39
49
|
arbitrum: {
|
|
40
50
|
USDC: string;
|
|
@@ -44,12 +54,24 @@ export declare const CONTRACT_ADDRESS: {
|
|
|
44
54
|
WSTETH: string;
|
|
45
55
|
BALANCER_WSTETH_WETH_POOL: string;
|
|
46
56
|
BALANCER_WSTETH_WETH_GAUGE: string;
|
|
57
|
+
uniswapV3: {
|
|
58
|
+
nonfungiblePositionManager: string;
|
|
59
|
+
};
|
|
60
|
+
ARRAKIS_USDC_WETH_GAUGE: string;
|
|
61
|
+
ARRAKIS_USDC_WETH_LP: string;
|
|
62
|
+
WMATIC: string;
|
|
47
63
|
};
|
|
48
64
|
base: {
|
|
49
65
|
USDC: string;
|
|
50
66
|
WETH: string;
|
|
51
67
|
WBTC: string;
|
|
52
68
|
SWETH: string;
|
|
69
|
+
uniswapV3: {
|
|
70
|
+
nonfungiblePositionManager: string;
|
|
71
|
+
};
|
|
72
|
+
ARRAKIS_USDC_WETH_GAUGE: string;
|
|
73
|
+
ARRAKIS_USDC_WETH_LP: string;
|
|
74
|
+
WMATIC: string;
|
|
53
75
|
};
|
|
54
76
|
};
|
|
55
77
|
export declare const MAX_AMOUNT: ethers.BigNumber;
|
package/dist/types.d.ts
CHANGED