@aspan/sdk 0.2.0 → 0.2.2

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/src/abi/router.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * AspanRouter ABI
3
3
  * Periphery contract for one-click swap+mint operations
4
+ * Updated: 2025-01-31
4
5
  */
5
6
 
6
7
  export const RouterABI = [
7
- // ============ Core Functions ============
8
+ // ============ Core Swap+Mint Functions ============
8
9
 
9
10
  // swapAndMintApUSD
10
11
  {
@@ -20,14 +21,12 @@ export const RouterABI = [
20
21
  { name: "targetLST", type: "address" },
21
22
  { name: "minLSTOut", type: "uint256" },
22
23
  { name: "poolFee", type: "uint24" },
23
- { name: "useV2", type: "bool" },
24
24
  ],
25
25
  },
26
26
  {
27
27
  name: "mintParams",
28
28
  type: "tuple",
29
29
  components: [
30
- { name: "mintXBNB", type: "bool" },
31
30
  { name: "minMintOut", type: "uint256" },
32
31
  { name: "recipient", type: "address" },
33
32
  { name: "deadline", type: "uint256" },
@@ -55,14 +54,12 @@ export const RouterABI = [
55
54
  { name: "targetLST", type: "address" },
56
55
  { name: "minLSTOut", type: "uint256" },
57
56
  { name: "poolFee", type: "uint24" },
58
- { name: "useV2", type: "bool" },
59
57
  ],
60
58
  },
61
59
  {
62
60
  name: "mintParams",
63
61
  type: "tuple",
64
62
  components: [
65
- { name: "mintXBNB", type: "bool" },
66
63
  { name: "minMintOut", type: "uint256" },
67
64
  { name: "recipient", type: "address" },
68
65
  { name: "deadline", type: "uint256" },
@@ -76,13 +73,15 @@ export const RouterABI = [
76
73
  stateMutability: "payable",
77
74
  },
78
75
 
76
+ // ============ Stake+Mint Functions ============
77
+
79
78
  // stakeAndMint
80
79
  {
81
80
  type: "function",
82
81
  name: "stakeAndMint",
83
82
  inputs: [
84
83
  { name: "targetLST", type: "address" },
85
- { name: "mintXBNB", type: "bool" },
84
+ { name: "isXBNB", type: "bool" },
86
85
  { name: "minMintOut", type: "uint256" },
87
86
  { name: "deadline", type: "uint256" },
88
87
  ],
@@ -93,7 +92,25 @@ export const RouterABI = [
93
92
  stateMutability: "payable",
94
93
  },
95
94
 
96
- // ============ Simplified Functions ============
95
+ // stakeAndMintApUSD (simplified)
96
+ {
97
+ type: "function",
98
+ name: "stakeAndMintApUSD",
99
+ inputs: [{ name: "minMintOut", type: "uint256" }],
100
+ outputs: [{ name: "apUSDAmount", type: "uint256" }],
101
+ stateMutability: "payable",
102
+ },
103
+
104
+ // stakeAndMintXBNB (simplified)
105
+ {
106
+ type: "function",
107
+ name: "stakeAndMintXBNB",
108
+ inputs: [{ name: "minMintOut", type: "uint256" }],
109
+ outputs: [{ name: "xBNBAmount", type: "uint256" }],
110
+ stateMutability: "payable",
111
+ },
112
+
113
+ // ============ Simplified Swap+Mint Functions ============
97
114
 
98
115
  // swapAndMintApUSDDefault
99
116
  {
@@ -123,24 +140,6 @@ export const RouterABI = [
123
140
  stateMutability: "payable",
124
141
  },
125
142
 
126
- // stakeAndMintApUSD
127
- {
128
- type: "function",
129
- name: "stakeAndMintApUSD",
130
- inputs: [{ name: "minMintOut", type: "uint256" }],
131
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
132
- stateMutability: "payable",
133
- },
134
-
135
- // stakeAndMintXBNB
136
- {
137
- type: "function",
138
- name: "stakeAndMintXBNB",
139
- inputs: [{ name: "minMintOut", type: "uint256" }],
140
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
141
- stateMutability: "payable",
142
- },
143
-
144
143
  // ============ Direct Mint/Redeem Functions ============
145
144
 
146
145
  // mintApUSD
@@ -195,7 +194,7 @@ export const RouterABI = [
195
194
  stateMutability: "nonpayable",
196
195
  },
197
196
 
198
- // ============ Redeem and Swap Functions ============
197
+ // ============ Redeem + Swap Functions (V3 path) ============
199
198
 
200
199
  // redeemApUSDAndSwap
201
200
  {
@@ -204,11 +203,9 @@ export const RouterABI = [
204
203
  inputs: [
205
204
  { name: "lst", type: "address" },
206
205
  { name: "apUSDAmount", type: "uint256" },
207
- { name: "outputToken", type: "address" },
206
+ { name: "path", type: "bytes" },
208
207
  { name: "minOut", type: "uint256" },
209
208
  { name: "deadline", type: "uint256" },
210
- { name: "useV2", type: "bool" },
211
- { name: "poolFee", type: "uint24" },
212
209
  ],
213
210
  outputs: [{ name: "outputAmount", type: "uint256" }],
214
211
  stateMutability: "nonpayable",
@@ -221,44 +218,14 @@ export const RouterABI = [
221
218
  inputs: [
222
219
  { name: "lst", type: "address" },
223
220
  { name: "xBNBAmount", type: "uint256" },
224
- { name: "outputToken", type: "address" },
221
+ { name: "path", type: "bytes" },
225
222
  { name: "minOut", type: "uint256" },
226
223
  { name: "deadline", type: "uint256" },
227
- { name: "useV2", type: "bool" },
228
- { name: "poolFee", type: "uint24" },
229
224
  ],
230
225
  outputs: [{ name: "outputAmount", type: "uint256" }],
231
226
  stateMutability: "nonpayable",
232
227
  },
233
228
 
234
- // redeemApUSDAndUnstake
235
- {
236
- type: "function",
237
- name: "redeemApUSDAndUnstake",
238
- inputs: [
239
- { name: "lst", type: "address" },
240
- { name: "apUSDAmount", type: "uint256" },
241
- { name: "minBNBOut", type: "uint256" },
242
- { name: "deadline", type: "uint256" },
243
- ],
244
- outputs: [{ name: "bnbAmount", type: "uint256" }],
245
- stateMutability: "nonpayable",
246
- },
247
-
248
- // redeemXBNBAndUnstake
249
- {
250
- type: "function",
251
- name: "redeemXBNBAndUnstake",
252
- inputs: [
253
- { name: "lst", type: "address" },
254
- { name: "xBNBAmount", type: "uint256" },
255
- { name: "minBNBOut", type: "uint256" },
256
- { name: "deadline", type: "uint256" },
257
- ],
258
- outputs: [{ name: "bnbAmount", type: "uint256" }],
259
- stateMutability: "nonpayable",
260
- },
261
-
262
229
  // ============ Native Unstake Functions ============
263
230
 
264
231
  // redeemApUSDAndRequestUnstake
@@ -296,196 +263,205 @@ export const RouterABI = [
296
263
 
297
264
  // ============ View Functions ============
298
265
 
299
- // defaultLST
300
- {
301
- type: "function",
302
- name: "defaultLST",
303
- inputs: [],
304
- outputs: [{ name: "", type: "address" }],
305
- stateMutability: "view",
306
- },
266
+ // Token addresses
267
+ { type: "function", name: "wbnb", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
268
+ { type: "function", name: "usdt", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
269
+ { type: "function", name: "usdc", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
270
+ { type: "function", name: "slisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
271
+ { type: "function", name: "asBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
272
+ { type: "function", name: "wclisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
273
+ { type: "function", name: "apUSD", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
274
+ { type: "function", name: "xBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
275
+
276
+ // Protocol addresses
277
+ { type: "function", name: "diamond", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
278
+ { type: "function", name: "pancakeV3Router", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
279
+ { type: "function", name: "listaStakeManager", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
280
+ { type: "function", name: "astherusMinter", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
281
+ { type: "function", name: "slisBNBProvider", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
307
282
 
308
- // supportedInputTokens
283
+ // Configuration
284
+ { type: "function", name: "defaultLST", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
309
285
  {
310
286
  type: "function",
311
287
  name: "supportedInputTokens",
312
288
  inputs: [{ name: "token", type: "address" }],
313
- outputs: [{ name: "", type: "bool" }],
289
+ outputs: [{ type: "bool" }],
314
290
  stateMutability: "view",
315
291
  },
316
-
317
- // supportedLSTs
318
292
  {
319
293
  type: "function",
320
294
  name: "supportedLSTs",
321
295
  inputs: [{ name: "lst", type: "address" }],
322
- outputs: [{ name: "", type: "bool" }],
296
+ outputs: [{ type: "bool" }],
323
297
  stateMutability: "view",
324
298
  },
325
299
 
326
- // diamond
300
+ // Preview functions
327
301
  {
328
302
  type: "function",
329
- name: "diamond",
330
- inputs: [],
331
- outputs: [{ name: "", type: "address" }],
303
+ name: "previewMintApUSD",
304
+ inputs: [
305
+ { name: "lst", type: "address" },
306
+ { name: "lstAmount", type: "uint256" },
307
+ ],
308
+ outputs: [{ name: "apUSDAmount", type: "uint256" }],
332
309
  stateMutability: "view",
333
310
  },
334
-
335
- // getExpectedOutput
336
311
  {
337
312
  type: "function",
338
- name: "getExpectedOutput",
313
+ name: "previewMintXBNB",
339
314
  inputs: [
340
- { name: "inputToken", type: "address" },
341
- { name: "inputAmount", type: "uint256" },
342
- { name: "targetLST", type: "address" },
343
- { name: "mintXBNB", type: "bool" },
344
- ],
345
- outputs: [
346
- { name: "expectedLST", type: "uint256" },
347
- { name: "expectedMint", type: "uint256" },
315
+ { name: "lst", type: "address" },
316
+ { name: "lstAmount", type: "uint256" },
348
317
  ],
318
+ outputs: [{ name: "xBNBAmount", type: "uint256" }],
349
319
  stateMutability: "view",
350
320
  },
351
-
352
- // getUserWithdrawalIndices
353
321
  {
354
322
  type: "function",
355
- name: "getUserWithdrawalIndices",
356
- inputs: [{ name: "user", type: "address" }],
357
- outputs: [{ name: "", type: "uint256[]" }],
323
+ name: "previewRedeemApUSD",
324
+ inputs: [
325
+ { name: "lst", type: "address" },
326
+ { name: "apUSDAmount", type: "uint256" },
327
+ ],
328
+ outputs: [{ name: "lstAmount", type: "uint256" }],
358
329
  stateMutability: "view",
359
330
  },
360
-
361
- // getWithdrawalStatus
362
331
  {
363
332
  type: "function",
364
- name: "getWithdrawalStatus",
365
- inputs: [{ name: "requestIndex", type: "uint256" }],
366
- outputs: [
367
- { name: "isClaimable", type: "bool" },
368
- { name: "bnbAmount", type: "uint256" },
333
+ name: "previewRedeemXBNB",
334
+ inputs: [
335
+ { name: "lst", type: "address" },
336
+ { name: "xBNBAmount", type: "uint256" },
369
337
  ],
338
+ outputs: [{ name: "lstAmount", type: "uint256" }],
370
339
  stateMutability: "view",
371
340
  },
372
341
 
373
- // Immutable addresses
342
+ // Withdrawal tracking
374
343
  {
375
344
  type: "function",
376
- name: "wbnb",
377
- inputs: [],
378
- outputs: [{ name: "", type: "address" }],
345
+ name: "getUserWithdrawalIndices",
346
+ inputs: [{ name: "user", type: "address" }],
347
+ outputs: [{ type: "uint256[]" }],
379
348
  stateMutability: "view",
380
349
  },
381
350
  {
382
351
  type: "function",
383
- name: "usdt",
384
- inputs: [],
385
- outputs: [{ name: "", type: "address" }],
352
+ name: "getWithdrawalStatus",
353
+ inputs: [{ name: "requestIndex", type: "uint256" }],
354
+ outputs: [
355
+ { name: "isClaimable", type: "bool" },
356
+ { name: "bnbAmount", type: "uint256" },
357
+ ],
386
358
  stateMutability: "view",
387
359
  },
388
360
  {
389
361
  type: "function",
390
- name: "usdc",
391
- inputs: [],
392
- outputs: [{ name: "", type: "address" }],
362
+ name: "withdrawalRequests",
363
+ inputs: [{ name: "index", type: "uint256" }],
364
+ outputs: [
365
+ { name: "user", type: "address" },
366
+ { name: "listaIdx", type: "uint256" },
367
+ { name: "slisBNBAmount", type: "uint256" },
368
+ { name: "claimed", type: "bool" },
369
+ ],
393
370
  stateMutability: "view",
394
371
  },
372
+
373
+ // ============ Admin Functions ============
374
+
375
+ { type: "function", name: "owner", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
395
376
  {
396
377
  type: "function",
397
- name: "slisBNB",
398
- inputs: [],
399
- outputs: [{ name: "", type: "address" }],
400
- stateMutability: "view",
378
+ name: "setDefaultLST",
379
+ inputs: [{ name: "lst", type: "address" }],
380
+ outputs: [],
381
+ stateMutability: "nonpayable",
401
382
  },
402
383
  {
403
384
  type: "function",
404
- name: "asBNB",
405
- inputs: [],
406
- outputs: [{ name: "", type: "address" }],
407
- stateMutability: "view",
385
+ name: "addSupportedInputToken",
386
+ inputs: [{ name: "token", type: "address" }],
387
+ outputs: [],
388
+ stateMutability: "nonpayable",
408
389
  },
409
390
  {
410
391
  type: "function",
411
- name: "wclisBNB",
412
- inputs: [],
413
- outputs: [{ name: "", type: "address" }],
414
- stateMutability: "view",
392
+ name: "addSupportedLST",
393
+ inputs: [{ name: "lst", type: "address" }],
394
+ outputs: [],
395
+ stateMutability: "nonpayable",
415
396
  },
416
397
  {
417
398
  type: "function",
418
- name: "apUSD",
419
- inputs: [],
420
- outputs: [{ name: "", type: "address" }],
421
- stateMutability: "view",
399
+ name: "rescueTokens",
400
+ inputs: [
401
+ { name: "token", type: "address" },
402
+ { name: "amount", type: "uint256" },
403
+ ],
404
+ outputs: [],
405
+ stateMutability: "nonpayable",
422
406
  },
423
407
  {
424
408
  type: "function",
425
- name: "xBNB",
426
- inputs: [],
427
- outputs: [{ name: "", type: "address" }],
428
- stateMutability: "view",
409
+ name: "transferOwnership",
410
+ inputs: [{ name: "newOwner", type: "address" }],
411
+ outputs: [],
412
+ stateMutability: "nonpayable",
429
413
  },
414
+ { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" },
430
415
 
431
416
  // ============ Events ============
432
417
 
433
- // SwapAndMint
434
418
  {
435
419
  type: "event",
436
420
  name: "SwapAndMint",
437
421
  inputs: [
438
422
  { name: "user", type: "address", indexed: true },
439
- { name: "inputToken", type: "address", indexed: true },
423
+ { name: "inputToken", type: "address", indexed: false },
440
424
  { name: "inputAmount", type: "uint256", indexed: false },
441
- { name: "targetLST", type: "address", indexed: true },
425
+ { name: "lst", type: "address", indexed: false },
442
426
  { name: "lstAmount", type: "uint256", indexed: false },
443
427
  { name: "mintedToken", type: "address", indexed: false },
444
428
  { name: "mintedAmount", type: "uint256", indexed: false },
445
429
  ],
446
430
  },
447
-
448
- // StakeAndMint
449
431
  {
450
432
  type: "event",
451
433
  name: "StakeAndMint",
452
434
  inputs: [
453
435
  { name: "user", type: "address", indexed: true },
454
436
  { name: "bnbAmount", type: "uint256", indexed: false },
455
- { name: "targetLST", type: "address", indexed: true },
437
+ { name: "lst", type: "address", indexed: false },
456
438
  { name: "lstAmount", type: "uint256", indexed: false },
457
- { name: "mintedToken", type: "address", indexed: true },
439
+ { name: "mintedToken", type: "address", indexed: false },
458
440
  { name: "mintedAmount", type: "uint256", indexed: false },
459
441
  ],
460
442
  },
461
-
462
- // Mint
463
443
  {
464
444
  type: "event",
465
445
  name: "Mint",
466
446
  inputs: [
467
447
  { name: "user", type: "address", indexed: true },
468
- { name: "lst", type: "address", indexed: true },
448
+ { name: "lst", type: "address", indexed: false },
469
449
  { name: "lstAmount", type: "uint256", indexed: false },
470
- { name: "mintedToken", type: "address", indexed: true },
450
+ { name: "mintedToken", type: "address", indexed: false },
471
451
  { name: "mintedAmount", type: "uint256", indexed: false },
472
452
  ],
473
453
  },
474
-
475
- // Redeem
476
454
  {
477
455
  type: "event",
478
456
  name: "Redeem",
479
457
  inputs: [
480
458
  { name: "user", type: "address", indexed: true },
481
- { name: "redeemedToken", type: "address", indexed: true },
459
+ { name: "redeemedToken", type: "address", indexed: false },
482
460
  { name: "redeemedAmount", type: "uint256", indexed: false },
483
- { name: "lst", type: "address", indexed: true },
461
+ { name: "lst", type: "address", indexed: false },
484
462
  { name: "lstAmount", type: "uint256", indexed: false },
485
463
  ],
486
464
  },
487
-
488
- // RedeemAndSwap
489
465
  {
490
466
  type: "event",
491
467
  name: "RedeemAndSwap",
@@ -495,60 +471,70 @@ export const RouterABI = [
495
471
  { name: "redeemedAmount", type: "uint256", indexed: false },
496
472
  { name: "lst", type: "address", indexed: false },
497
473
  { name: "lstAmount", type: "uint256", indexed: false },
498
- { name: "outputToken", type: "address", indexed: true },
474
+ { name: "outputToken", type: "address", indexed: false },
499
475
  { name: "outputAmount", type: "uint256", indexed: false },
500
476
  ],
501
477
  },
502
-
503
- // UnstakeRequested
504
478
  {
505
479
  type: "event",
506
480
  name: "UnstakeRequested",
507
481
  inputs: [
508
482
  { name: "user", type: "address", indexed: true },
509
- { name: "requestIndex", type: "uint256", indexed: true },
483
+ { name: "requestIndex", type: "uint256", indexed: false },
510
484
  { name: "redeemedToken", type: "address", indexed: false },
511
485
  { name: "redeemedAmount", type: "uint256", indexed: false },
512
486
  { name: "slisBNBAmount", type: "uint256", indexed: false },
513
487
  ],
514
488
  },
515
-
516
- // UnstakeClaimed
517
489
  {
518
490
  type: "event",
519
491
  name: "UnstakeClaimed",
520
492
  inputs: [
521
493
  { name: "user", type: "address", indexed: true },
522
- { name: "requestIndex", type: "uint256", indexed: true },
494
+ { name: "requestIndex", type: "uint256", indexed: false },
523
495
  { name: "bnbAmount", type: "uint256", indexed: false },
524
496
  ],
525
497
  },
526
-
527
- // DefaultLSTUpdated
528
498
  {
529
499
  type: "event",
530
500
  name: "DefaultLSTUpdated",
531
501
  inputs: [
532
- { name: "oldLST", type: "address", indexed: true },
533
- { name: "newLST", type: "address", indexed: true },
502
+ { name: "oldLST", type: "address", indexed: false },
503
+ { name: "newLST", type: "address", indexed: false },
504
+ ],
505
+ },
506
+ {
507
+ type: "event",
508
+ name: "OwnershipTransferred",
509
+ inputs: [
510
+ { name: "previousOwner", type: "address", indexed: true },
511
+ { name: "newOwner", type: "address", indexed: true },
534
512
  ],
535
513
  },
536
514
 
537
515
  // ============ Errors ============
538
516
 
539
- { type: "error", name: "UnsupportedInputToken", inputs: [] },
540
- { type: "error", name: "UnsupportedLST", inputs: [] },
541
517
  { type: "error", name: "DeadlineExpired", inputs: [] },
518
+ { type: "error", name: "DefaultLSTNotSet", inputs: [] },
542
519
  { type: "error", name: "InsufficientOutput", inputs: [] },
543
- { type: "error", name: "ZeroAmount", inputs: [] },
520
+ { type: "error", name: "InvalidPoolFee", inputs: [] },
544
521
  { type: "error", name: "InvalidRecipient", inputs: [] },
545
- { type: "error", name: "SwapFailed", inputs: [] },
522
+ { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
546
523
  { type: "error", name: "MintFailed", inputs: [] },
547
524
  { type: "error", name: "NativeTransferFailed", inputs: [] },
548
- { type: "error", name: "InvalidPoolFee", inputs: [] },
549
- { type: "error", name: "DefaultLSTNotSet", inputs: [] },
550
- { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
551
- { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
552
- { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
553
525
  { type: "error", name: "OnlySlisBNBSupported", inputs: [] },
526
+ { type: "error", name: "SwapFailed", inputs: [] },
527
+ { type: "error", name: "UnsupportedInputToken", inputs: [] },
528
+ { type: "error", name: "UnsupportedLST", inputs: [] },
529
+ { type: "error", name: "V3PoolNotFound", inputs: [] },
530
+ { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
531
+ { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
532
+ { type: "error", name: "ZeroAmount", inputs: [] },
533
+ { type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
534
+ { type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address" }] },
535
+ { type: "error", name: "OwnableUnauthorizedAccount", inputs: [{ name: "account", type: "address" }] },
536
+ { type: "error", name: "SafeERC20FailedOperation", inputs: [{ name: "token", type: "address" }] },
537
+
538
+ // Receive
539
+ { type: "receive", stateMutability: "payable" },
554
540
  ] as const;
package/src/index.ts CHANGED
@@ -77,9 +77,7 @@ export type {
77
77
  RouterRedeemApUSDParams,
78
78
  RouterRedeemXBNBParams,
79
79
  RouterRedeemAndSwapParams,
80
- RouterRedeemAndUnstakeParams,
81
80
  WithdrawalRequestInfo,
82
- ExpectedOutput,
83
81
  // Router events
84
82
  SwapAndMintEvent,
85
83
  StakeAndMintEvent,
@@ -94,6 +92,9 @@ export type {
94
92
  export { DiamondABI } from "./abi/diamond";
95
93
  export { RouterABI } from "./abi/router";
96
94
 
95
+ // ============ V3 Path Encoding ============
96
+ export { encodeV3Path } from "./types";
97
+
97
98
  // ============ Constants ============
98
99
  export const PRECISION = 10n ** 18n;
99
100
  export const BPS_PRECISION = 10000n;