@dhedge/v2-sdk 1.10.4 → 1.10.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.10.4",
3
+ "version": "1.10.5",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,486 @@
1
+ [
2
+ {
3
+ "anonymous": false,
4
+ "inputs": [
5
+ {
6
+ "indexed": true,
7
+ "internalType": "uint256",
8
+ "name": "tokenId",
9
+ "type": "uint256"
10
+ },
11
+ {
12
+ "indexed": false,
13
+ "internalType": "address",
14
+ "name": "recipient",
15
+ "type": "address"
16
+ },
17
+ {
18
+ "indexed": false,
19
+ "internalType": "uint256",
20
+ "name": "amount0",
21
+ "type": "uint256"
22
+ },
23
+ {
24
+ "indexed": false,
25
+ "internalType": "uint256",
26
+ "name": "amount1",
27
+ "type": "uint256"
28
+ }
29
+ ],
30
+ "name": "Collect",
31
+ "type": "event"
32
+ },
33
+ {
34
+ "anonymous": false,
35
+ "inputs": [
36
+ {
37
+ "indexed": true,
38
+ "internalType": "uint256",
39
+ "name": "tokenId",
40
+ "type": "uint256"
41
+ },
42
+ {
43
+ "indexed": false,
44
+ "internalType": "uint128",
45
+ "name": "liquidity",
46
+ "type": "uint128"
47
+ },
48
+ {
49
+ "indexed": false,
50
+ "internalType": "uint256",
51
+ "name": "amount0",
52
+ "type": "uint256"
53
+ },
54
+ {
55
+ "indexed": false,
56
+ "internalType": "uint256",
57
+ "name": "amount1",
58
+ "type": "uint256"
59
+ }
60
+ ],
61
+ "name": "DecreaseLiquidity",
62
+ "type": "event"
63
+ },
64
+ {
65
+ "anonymous": false,
66
+ "inputs": [
67
+ {
68
+ "indexed": true,
69
+ "internalType": "uint256",
70
+ "name": "tokenId",
71
+ "type": "uint256"
72
+ },
73
+ {
74
+ "indexed": false,
75
+ "internalType": "uint128",
76
+ "name": "liquidity",
77
+ "type": "uint128"
78
+ },
79
+ {
80
+ "indexed": false,
81
+ "internalType": "uint256",
82
+ "name": "amount0",
83
+ "type": "uint256"
84
+ },
85
+ {
86
+ "indexed": false,
87
+ "internalType": "uint256",
88
+ "name": "amount1",
89
+ "type": "uint256"
90
+ }
91
+ ],
92
+ "name": "IncreaseLiquidity",
93
+ "type": "event"
94
+ },
95
+ {
96
+ "inputs": [
97
+ {
98
+ "internalType": "uint256",
99
+ "name": "tokenId",
100
+ "type": "uint256"
101
+ }
102
+ ],
103
+ "name": "burn",
104
+ "outputs": [],
105
+ "stateMutability": "payable",
106
+ "type": "function"
107
+ },
108
+ {
109
+ "inputs": [
110
+ {
111
+ "components": [
112
+ {
113
+ "internalType": "uint256",
114
+ "name": "tokenId",
115
+ "type": "uint256"
116
+ },
117
+ {
118
+ "internalType": "address",
119
+ "name": "recipient",
120
+ "type": "address"
121
+ },
122
+ {
123
+ "internalType": "uint128",
124
+ "name": "amount0Max",
125
+ "type": "uint128"
126
+ },
127
+ {
128
+ "internalType": "uint128",
129
+ "name": "amount1Max",
130
+ "type": "uint128"
131
+ }
132
+ ],
133
+ "internalType": "struct IRamsesNonfungiblePositionManager.CollectParams",
134
+ "name": "params",
135
+ "type": "tuple"
136
+ }
137
+ ],
138
+ "name": "collect",
139
+ "outputs": [
140
+ {
141
+ "internalType": "uint256",
142
+ "name": "amount0",
143
+ "type": "uint256"
144
+ },
145
+ {
146
+ "internalType": "uint256",
147
+ "name": "amount1",
148
+ "type": "uint256"
149
+ }
150
+ ],
151
+ "stateMutability": "payable",
152
+ "type": "function"
153
+ },
154
+ {
155
+ "inputs": [
156
+ {
157
+ "components": [
158
+ {
159
+ "internalType": "uint256",
160
+ "name": "tokenId",
161
+ "type": "uint256"
162
+ },
163
+ {
164
+ "internalType": "uint128",
165
+ "name": "liquidity",
166
+ "type": "uint128"
167
+ },
168
+ {
169
+ "internalType": "uint256",
170
+ "name": "amount0Min",
171
+ "type": "uint256"
172
+ },
173
+ {
174
+ "internalType": "uint256",
175
+ "name": "amount1Min",
176
+ "type": "uint256"
177
+ },
178
+ {
179
+ "internalType": "uint256",
180
+ "name": "deadline",
181
+ "type": "uint256"
182
+ }
183
+ ],
184
+ "internalType": "struct IRamsesNonfungiblePositionManager.DecreaseLiquidityParams",
185
+ "name": "params",
186
+ "type": "tuple"
187
+ }
188
+ ],
189
+ "name": "decreaseLiquidity",
190
+ "outputs": [
191
+ {
192
+ "internalType": "uint256",
193
+ "name": "amount0",
194
+ "type": "uint256"
195
+ },
196
+ {
197
+ "internalType": "uint256",
198
+ "name": "amount1",
199
+ "type": "uint256"
200
+ }
201
+ ],
202
+ "stateMutability": "payable",
203
+ "type": "function"
204
+ },
205
+ {
206
+ "inputs": [],
207
+ "name": "factory",
208
+ "outputs": [
209
+ {
210
+ "internalType": "address",
211
+ "name": "",
212
+ "type": "address"
213
+ }
214
+ ],
215
+ "stateMutability": "view",
216
+ "type": "function"
217
+ },
218
+ {
219
+ "inputs": [
220
+ {
221
+ "internalType": "uint256",
222
+ "name": "tokenId",
223
+ "type": "uint256"
224
+ },
225
+ {
226
+ "internalType": "address[]",
227
+ "name": "tokens",
228
+ "type": "address[]"
229
+ }
230
+ ],
231
+ "name": "getReward",
232
+ "outputs": [],
233
+ "stateMutability": "nonpayable",
234
+ "type": "function"
235
+ },
236
+ {
237
+ "inputs": [
238
+ {
239
+ "components": [
240
+ {
241
+ "internalType": "uint256",
242
+ "name": "tokenId",
243
+ "type": "uint256"
244
+ },
245
+ {
246
+ "internalType": "uint256",
247
+ "name": "amount0Desired",
248
+ "type": "uint256"
249
+ },
250
+ {
251
+ "internalType": "uint256",
252
+ "name": "amount1Desired",
253
+ "type": "uint256"
254
+ },
255
+ {
256
+ "internalType": "uint256",
257
+ "name": "amount0Min",
258
+ "type": "uint256"
259
+ },
260
+ {
261
+ "internalType": "uint256",
262
+ "name": "amount1Min",
263
+ "type": "uint256"
264
+ },
265
+ {
266
+ "internalType": "uint256",
267
+ "name": "deadline",
268
+ "type": "uint256"
269
+ }
270
+ ],
271
+ "internalType": "struct IRamsesNonfungiblePositionManager.IncreaseLiquidityParams",
272
+ "name": "params",
273
+ "type": "tuple"
274
+ }
275
+ ],
276
+ "name": "increaseLiquidity",
277
+ "outputs": [
278
+ {
279
+ "internalType": "uint128",
280
+ "name": "liquidity",
281
+ "type": "uint128"
282
+ },
283
+ {
284
+ "internalType": "uint256",
285
+ "name": "amount0",
286
+ "type": "uint256"
287
+ },
288
+ {
289
+ "internalType": "uint256",
290
+ "name": "amount1",
291
+ "type": "uint256"
292
+ }
293
+ ],
294
+ "stateMutability": "payable",
295
+ "type": "function"
296
+ },
297
+ {
298
+ "inputs": [
299
+ {
300
+ "components": [
301
+ {
302
+ "internalType": "address",
303
+ "name": "token0",
304
+ "type": "address"
305
+ },
306
+ {
307
+ "internalType": "address",
308
+ "name": "token1",
309
+ "type": "address"
310
+ },
311
+ {
312
+ "internalType": "uint24",
313
+ "name": "fee",
314
+ "type": "uint24"
315
+ },
316
+ {
317
+ "internalType": "int24",
318
+ "name": "tickLower",
319
+ "type": "int24"
320
+ },
321
+ {
322
+ "internalType": "int24",
323
+ "name": "tickUpper",
324
+ "type": "int24"
325
+ },
326
+ {
327
+ "internalType": "uint256",
328
+ "name": "amount0Desired",
329
+ "type": "uint256"
330
+ },
331
+ {
332
+ "internalType": "uint256",
333
+ "name": "amount1Desired",
334
+ "type": "uint256"
335
+ },
336
+ {
337
+ "internalType": "uint256",
338
+ "name": "amount0Min",
339
+ "type": "uint256"
340
+ },
341
+ {
342
+ "internalType": "uint256",
343
+ "name": "amount1Min",
344
+ "type": "uint256"
345
+ },
346
+ {
347
+ "internalType": "address",
348
+ "name": "recipient",
349
+ "type": "address"
350
+ },
351
+ {
352
+ "internalType": "uint256",
353
+ "name": "deadline",
354
+ "type": "uint256"
355
+ },
356
+ {
357
+ "internalType": "uint256",
358
+ "name": "veRamTokenId",
359
+ "type": "uint256"
360
+ }
361
+ ],
362
+ "internalType": "struct IRamsesNonfungiblePositionManager.MintParams",
363
+ "name": "params",
364
+ "type": "tuple"
365
+ }
366
+ ],
367
+ "name": "mint",
368
+ "outputs": [
369
+ {
370
+ "internalType": "uint256",
371
+ "name": "tokenId",
372
+ "type": "uint256"
373
+ },
374
+ {
375
+ "internalType": "uint128",
376
+ "name": "liquidity",
377
+ "type": "uint128"
378
+ },
379
+ {
380
+ "internalType": "uint256",
381
+ "name": "amount0",
382
+ "type": "uint256"
383
+ },
384
+ {
385
+ "internalType": "uint256",
386
+ "name": "amount1",
387
+ "type": "uint256"
388
+ }
389
+ ],
390
+ "stateMutability": "payable",
391
+ "type": "function"
392
+ },
393
+ {
394
+ "inputs": [
395
+ {
396
+ "internalType": "uint256",
397
+ "name": "tokenId",
398
+ "type": "uint256"
399
+ }
400
+ ],
401
+ "name": "positions",
402
+ "outputs": [
403
+ {
404
+ "internalType": "uint96",
405
+ "name": "nonce",
406
+ "type": "uint96"
407
+ },
408
+ {
409
+ "internalType": "address",
410
+ "name": "operator",
411
+ "type": "address"
412
+ },
413
+ {
414
+ "internalType": "address",
415
+ "name": "token0",
416
+ "type": "address"
417
+ },
418
+ {
419
+ "internalType": "address",
420
+ "name": "token1",
421
+ "type": "address"
422
+ },
423
+ {
424
+ "internalType": "uint24",
425
+ "name": "fee",
426
+ "type": "uint24"
427
+ },
428
+ {
429
+ "internalType": "int24",
430
+ "name": "tickLower",
431
+ "type": "int24"
432
+ },
433
+ {
434
+ "internalType": "int24",
435
+ "name": "tickUpper",
436
+ "type": "int24"
437
+ },
438
+ {
439
+ "internalType": "uint128",
440
+ "name": "liquidity",
441
+ "type": "uint128"
442
+ },
443
+ {
444
+ "internalType": "uint256",
445
+ "name": "feeGrowthInside0LastX128",
446
+ "type": "uint256"
447
+ },
448
+ {
449
+ "internalType": "uint256",
450
+ "name": "feeGrowthInside1LastX128",
451
+ "type": "uint256"
452
+ },
453
+ {
454
+ "internalType": "uint128",
455
+ "name": "tokensOwed0",
456
+ "type": "uint128"
457
+ },
458
+ {
459
+ "internalType": "uint128",
460
+ "name": "tokensOwed1",
461
+ "type": "uint128"
462
+ }
463
+ ],
464
+ "stateMutability": "view",
465
+ "type": "function"
466
+ },
467
+ {
468
+ "inputs": [
469
+ {
470
+ "internalType": "address",
471
+ "name": "owner",
472
+ "type": "address"
473
+ }
474
+ ],
475
+ "name": "balanceOf",
476
+ "outputs": [
477
+ {
478
+ "internalType": "uint256",
479
+ "name": "",
480
+ "type": "uint256"
481
+ }
482
+ ],
483
+ "stateMutability": "view",
484
+ "type": "function"
485
+ }
486
+ ]
package/src/config.ts CHANGED
@@ -110,7 +110,8 @@ export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
110
110
  [Dapp.VELODROMECL]: "0x416b433906b1B72FA758e166e239c43d68dC6F29"
111
111
  },
112
112
  [Network.ARBITRUM]: {
113
- [Dapp.UNISWAPV3]: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
113
+ [Dapp.UNISWAPV3]: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88",
114
+ [Dapp.RAMSESCL]: "0xAA277CB7914b7e5514946Da92cb9De332Ce610EF"
114
115
  },
115
116
  [Network.BASE]: {
116
117
  [Dapp.UNISWAPV3]: "0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1",
@@ -64,7 +64,8 @@ import { getZeroExTradeTxData } from "../services/zeroEx/zeroExTrade";
64
64
  import { getOneInchSwapTxData } from "../services/oneInch";
65
65
  import {
66
66
  getCreateVestTxData,
67
- getExitVestTxData
67
+ getExitVestTxData,
68
+ getRewardsTxDta
68
69
  } from "../services/ramses/vesting";
69
70
  import { getPoolTxOrGasEstimate } from "../utils/contract";
70
71
  import {
@@ -1038,7 +1039,7 @@ export class Pool {
1038
1039
 
1039
1040
  /**
1040
1041
  * Create UniswapV3 liquidity pool
1041
- * @param {dapp} Platform UniswapV3, VelodromeCL or AerodromeCL
1042
+ * @param {dapp} Platform UniswapV3, VelodromeCL, AerodromeCL or RamesesCL
1042
1043
  * @param {string} assetA First asset
1043
1044
  * @param {string} assetB Second asset
1044
1045
  * @param {BigNumber | string} amountA Amount first asset
@@ -1053,7 +1054,7 @@ export class Pool {
1053
1054
  * @returns {Promise<any>} Transaction
1054
1055
  */
1055
1056
  async addLiquidityUniswapV3(
1056
- dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL,
1057
+ dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL | Dapp.RAMSESCL,
1057
1058
  assetA: string,
1058
1059
  assetB: string,
1059
1060
  amountA: BigNumber | string,
@@ -1121,6 +1122,7 @@ export class Pool {
1121
1122
  let txData;
1122
1123
  switch (dapp) {
1123
1124
  case Dapp.UNISWAPV3:
1125
+ case Dapp.RAMSESCL:
1124
1126
  dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
1125
1127
  break;
1126
1128
  case Dapp.VELODROMECL:
@@ -1178,6 +1180,7 @@ export class Pool {
1178
1180
  let txData;
1179
1181
  switch (dapp) {
1180
1182
  case Dapp.UNISWAPV3:
1183
+ case Dapp.RAMSESCL:
1181
1184
  dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
1182
1185
  break;
1183
1186
  case Dapp.VELODROMECL:
@@ -1239,6 +1242,7 @@ export class Pool {
1239
1242
  );
1240
1243
  switch (dapp) {
1241
1244
  case Dapp.UNISWAPV3:
1245
+ case Dapp.RAMSESCL:
1242
1246
  contractAddress = nonfungiblePositionManagerAddress[this.network][dapp];
1243
1247
  txData = iNonfungiblePositionManager.encodeFunctionData(
1244
1248
  Transaction.COLLECT,
@@ -1288,6 +1292,34 @@ export class Pool {
1288
1292
  return tx;
1289
1293
  }
1290
1294
 
1295
+ /**
1296
+ * Get rewards of an NFT position
1297
+ * @param {Dapp} dapp Platform e.g. Ramses CL
1298
+ * @param {string} tokenId Token Id
1299
+ * @param {string[]} rewards Reward tokens
1300
+ * @param {any} options Transaction option
1301
+ * @param {boolean} estimateGas Simulate/estimate gas
1302
+ * @returns {Promise<any>} Transaction
1303
+ */
1304
+ async getRewards(
1305
+ dapp: Dapp,
1306
+ tokenId: string,
1307
+ rewards: string[],
1308
+ options: any = null,
1309
+ estimateGas = false
1310
+ ): Promise<any> {
1311
+ const tx = await getPoolTxOrGasEstimate(
1312
+ this,
1313
+ [
1314
+ nonfungiblePositionManagerAddress[this.network][dapp],
1315
+ getRewardsTxDta(tokenId, rewards),
1316
+ options
1317
+ ],
1318
+ estimateGas
1319
+ );
1320
+ return tx;
1321
+ }
1322
+
1291
1323
  /**
1292
1324
  * Trade an asset into another asset
1293
1325
  * @param {Dapp} dapp Platform like Sushiswap or Uniswap
@@ -1,8 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { BigNumber, ethers } from "ethers";
3
3
  import IXRam from "../../abi/IXRam.json";
4
+ import IRamsesNonfungiblePositionManager from "../../abi/IRamsesNonfungiblePositionManager.json";
4
5
 
5
6
  const iXRam = new ethers.utils.Interface(IXRam.abi);
7
+ const iRamsesNonfungiblePositionManager = new ethers.utils.Interface(
8
+ IRamsesNonfungiblePositionManager
9
+ );
6
10
 
7
11
  export function getCreateVestTxData(amount: BigNumber | string): string {
8
12
  return iXRam.encodeFunctionData("createVest", [amount]);
@@ -11,3 +15,10 @@ export function getCreateVestTxData(amount: BigNumber | string): string {
11
15
  export function getExitVestTxData(vestId: number): string {
12
16
  return iXRam.encodeFunctionData("exitVest", [vestId, false]);
13
17
  }
18
+
19
+ export function getRewardsTxDta(tokenId: string, rewards: string[]): string {
20
+ return iRamsesNonfungiblePositionManager.encodeFunctionData("getReward", [
21
+ tokenId,
22
+ rewards
23
+ ]);
24
+ }
@@ -19,6 +19,7 @@ import {
19
19
  } from "../../config";
20
20
  import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
21
21
  import IVeldodromePositionManager from "../../abi/IVelodromeNonfungiblePositionManager.json";
22
+ import IRamsesPositionManager from "../../abi/IRamsesNonfungiblePositionManager.json";
22
23
  import IArrakisV1RouterStaking from "../../abi/IArrakisV1RouterStaking.json";
23
24
  import { getDeadline } from "../../utils/deadline";
24
25
  import BigNumber from "bignumber.js";
@@ -70,7 +71,7 @@ export function tryParseTick(
70
71
  }
71
72
 
72
73
  export async function getUniswapV3MintTxData(
73
- dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL,
74
+ dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL | Dapp.RAMSESCL,
74
75
  pool: Pool,
75
76
  assetA: string,
76
77
  assetB: string,
@@ -154,6 +155,13 @@ export async function getUniswapV3MintTxData(
154
155
  mintParams.push(0);
155
156
  }
156
157
 
158
+ if (dapp === Dapp.RAMSESCL) {
159
+ iNonfungiblePositionManager = new ethers.utils.Interface(
160
+ IRamsesPositionManager
161
+ );
162
+ mintParams.push(0);
163
+ }
164
+
157
165
  return iNonfungiblePositionManager.encodeFunctionData(Transaction.MINT, [
158
166
  mintParams
159
167
  ]);
@@ -162,7 +170,7 @@ export async function getUniswapV3MintTxData(
162
170
  }
163
171
 
164
172
  export async function getUniswapV3Liquidity(
165
- dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL,
173
+ dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL | Dapp.AERODROMECL | Dapp.RAMSESCL,
166
174
  tokenId: string,
167
175
  pool: Pool
168
176
  ): Promise<BigNumber> {
@@ -187,7 +195,8 @@ export async function getIncreaseLiquidityTxData(
187
195
  if (
188
196
  dapp === Dapp.UNISWAPV3 ||
189
197
  dapp === Dapp.VELODROMECL ||
190
- dapp === Dapp.AERODROMECL
198
+ dapp === Dapp.AERODROMECL ||
199
+ dapp === Dapp.RAMSESCL
191
200
  ) {
192
201
  const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
193
202
  txData = abi.encodeFunctionData(Transaction.INCREASE_LIQUIDITY, [
@@ -221,7 +230,8 @@ export async function getDecreaseLiquidityTxData(
221
230
  if (
222
231
  dapp === Dapp.UNISWAPV3 ||
223
232
  dapp === Dapp.VELODROMECL ||
224
- dapp === Dapp.AERODROMECL
233
+ dapp === Dapp.AERODROMECL ||
234
+ dapp === Dapp.RAMSESCL
225
235
  ) {
226
236
  const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
227
237
  const liquidity = (await getUniswapV3Liquidity(dapp, tokenId, pool))
@@ -41,7 +41,7 @@ export const KWENTA_ETH_PERP_V2 = "0x2b3bb4c683bfc5239b029131eef3b1d214478d93";
41
41
  export const TEST_POOL = {
42
42
  [Network.POLYGON]: "0x699fd4d6eadb216704c7e355cfa0a12f51813163",
43
43
  [Network.OPTIMISM]: "0x12573bfdf764ab9d52aca20e2827497a66829716",
44
- [Network.ARBITRUM]: "0x2dc2f936c8b6619facc69355d65dd93d2f4cc2bd",
44
+ [Network.ARBITRUM]: "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14",
45
45
  [Network.BASE]: "0x4842b42F68524383F609aa46eAfc18c1459cE3cD"
46
46
  };
47
47