@aspan/sdk 0.2.1 → 0.3.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/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,7 +21,6 @@ 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
  {
@@ -55,7 +55,6 @@ export const RouterABI = [
55
55
  { name: "targetLST", type: "address" },
56
56
  { name: "minLSTOut", type: "uint256" },
57
57
  { name: "poolFee", type: "uint24" },
58
- { name: "useV2", type: "bool" },
59
58
  ],
60
59
  },
61
60
  {
@@ -76,6 +75,8 @@ export const RouterABI = [
76
75
  stateMutability: "payable",
77
76
  },
78
77
 
78
+ // ============ Stake+Mint Functions ============
79
+
79
80
  // stakeAndMint
80
81
  {
81
82
  type: "function",
@@ -93,7 +94,25 @@ export const RouterABI = [
93
94
  stateMutability: "payable",
94
95
  },
95
96
 
96
- // ============ Simplified Functions ============
97
+ // stakeAndMintApUSD (simplified)
98
+ {
99
+ type: "function",
100
+ name: "stakeAndMintApUSD",
101
+ inputs: [{ name: "minMintOut", type: "uint256" }],
102
+ outputs: [{ name: "apUSDAmount", type: "uint256" }],
103
+ stateMutability: "payable",
104
+ },
105
+
106
+ // stakeAndMintXBNB (simplified)
107
+ {
108
+ type: "function",
109
+ name: "stakeAndMintXBNB",
110
+ inputs: [{ name: "minMintOut", type: "uint256" }],
111
+ outputs: [{ name: "xBNBAmount", type: "uint256" }],
112
+ stateMutability: "payable",
113
+ },
114
+
115
+ // ============ Simplified Swap+Mint Functions ============
97
116
 
98
117
  // swapAndMintApUSDDefault
99
118
  {
@@ -123,24 +142,6 @@ export const RouterABI = [
123
142
  stateMutability: "payable",
124
143
  },
125
144
 
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
145
  // ============ Direct Mint/Redeem Functions ============
145
146
 
146
147
  // mintApUSD
@@ -195,7 +196,7 @@ export const RouterABI = [
195
196
  stateMutability: "nonpayable",
196
197
  },
197
198
 
198
- // ============ Redeem and Swap Functions ============
199
+ // ============ Redeem + Swap Functions (V3 path) ============
199
200
 
200
201
  // redeemApUSDAndSwap
201
202
  {
@@ -204,11 +205,9 @@ export const RouterABI = [
204
205
  inputs: [
205
206
  { name: "lst", type: "address" },
206
207
  { name: "apUSDAmount", type: "uint256" },
207
- { name: "outputToken", type: "address" },
208
+ { name: "path", type: "bytes" },
208
209
  { name: "minOut", type: "uint256" },
209
210
  { name: "deadline", type: "uint256" },
210
- { name: "useV2", type: "bool" },
211
- { name: "poolFee", type: "uint24" },
212
211
  ],
213
212
  outputs: [{ name: "outputAmount", type: "uint256" }],
214
213
  stateMutability: "nonpayable",
@@ -221,44 +220,14 @@ export const RouterABI = [
221
220
  inputs: [
222
221
  { name: "lst", type: "address" },
223
222
  { name: "xBNBAmount", type: "uint256" },
224
- { name: "outputToken", type: "address" },
223
+ { name: "path", type: "bytes" },
225
224
  { name: "minOut", type: "uint256" },
226
225
  { name: "deadline", type: "uint256" },
227
- { name: "useV2", type: "bool" },
228
- { name: "poolFee", type: "uint24" },
229
226
  ],
230
227
  outputs: [{ name: "outputAmount", type: "uint256" }],
231
228
  stateMutability: "nonpayable",
232
229
  },
233
230
 
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
231
  // ============ Native Unstake Functions ============
263
232
 
264
233
  // redeemApUSDAndRequestUnstake
@@ -296,77 +265,41 @@ export const RouterABI = [
296
265
 
297
266
  // ============ View Functions ============
298
267
 
299
- // defaultLST
300
- {
301
- type: "function",
302
- name: "defaultLST",
303
- inputs: [],
304
- outputs: [{ name: "", type: "address" }],
305
- stateMutability: "view",
306
- },
268
+ // Token addresses
269
+ { type: "function", name: "wbnb", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
270
+ { type: "function", name: "usdt", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
271
+ { type: "function", name: "usdc", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
272
+ { type: "function", name: "slisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
273
+ { type: "function", name: "asBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
274
+ { type: "function", name: "wclisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
275
+ { type: "function", name: "apUSD", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
276
+ { type: "function", name: "xBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
307
277
 
308
- // supportedInputTokens
278
+ // Protocol addresses
279
+ { type: "function", name: "diamond", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
280
+ { type: "function", name: "pancakeV3Router", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
281
+ { type: "function", name: "listaStakeManager", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
282
+ { type: "function", name: "astherusMinter", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
283
+ { type: "function", name: "slisBNBProvider", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
284
+
285
+ // Configuration
286
+ { type: "function", name: "defaultLST", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
309
287
  {
310
288
  type: "function",
311
289
  name: "supportedInputTokens",
312
290
  inputs: [{ name: "token", type: "address" }],
313
- outputs: [{ name: "", type: "bool" }],
291
+ outputs: [{ type: "bool" }],
314
292
  stateMutability: "view",
315
293
  },
316
-
317
- // supportedLSTs
318
294
  {
319
295
  type: "function",
320
296
  name: "supportedLSTs",
321
297
  inputs: [{ name: "lst", type: "address" }],
322
- outputs: [{ name: "", type: "bool" }],
298
+ outputs: [{ type: "bool" }],
323
299
  stateMutability: "view",
324
300
  },
325
301
 
326
- // diamond
327
- {
328
- type: "function",
329
- name: "diamond",
330
- inputs: [],
331
- outputs: [{ name: "", type: "address" }],
332
- stateMutability: "view",
333
- },
334
-
335
- // getExpectedMintOutput
336
- {
337
- type: "function",
338
- name: "getExpectedMintOutput",
339
- inputs: [
340
- { name: "inputToken", type: "address" },
341
- { name: "inputAmount", type: "uint256" },
342
- { name: "targetLST", type: "address" },
343
- { name: "isXBNB", type: "bool" },
344
- ],
345
- outputs: [
346
- { name: "expectedLST", type: "uint256" },
347
- { name: "expectedMint", type: "uint256" },
348
- ],
349
- stateMutability: "view",
350
- },
351
-
352
- // getExpectedRedeemOutput
353
- {
354
- type: "function",
355
- name: "getExpectedRedeemOutput",
356
- inputs: [
357
- { name: "isXBNB", type: "bool" },
358
- { name: "redeemAmount", type: "uint256" },
359
- { name: "lst", type: "address" },
360
- { name: "outputToken", type: "address" },
361
- ],
362
- outputs: [
363
- { name: "expectedLST", type: "uint256" },
364
- { name: "expectedOutput", type: "uint256" },
365
- ],
366
- stateMutability: "view",
367
- },
368
-
369
- // previewMintApUSD
302
+ // Preview functions
370
303
  {
371
304
  type: "function",
372
305
  name: "previewMintApUSD",
@@ -377,8 +310,6 @@ export const RouterABI = [
377
310
  outputs: [{ name: "apUSDAmount", type: "uint256" }],
378
311
  stateMutability: "view",
379
312
  },
380
-
381
- // previewMintXBNB
382
313
  {
383
314
  type: "function",
384
315
  name: "previewMintXBNB",
@@ -389,8 +320,6 @@ export const RouterABI = [
389
320
  outputs: [{ name: "xBNBAmount", type: "uint256" }],
390
321
  stateMutability: "view",
391
322
  },
392
-
393
- // previewRedeemApUSD
394
323
  {
395
324
  type: "function",
396
325
  name: "previewRedeemApUSD",
@@ -401,8 +330,6 @@ export const RouterABI = [
401
330
  outputs: [{ name: "lstAmount", type: "uint256" }],
402
331
  stateMutability: "view",
403
332
  },
404
-
405
- // previewRedeemXBNB
406
333
  {
407
334
  type: "function",
408
335
  name: "previewRedeemXBNB",
@@ -414,16 +341,14 @@ export const RouterABI = [
414
341
  stateMutability: "view",
415
342
  },
416
343
 
417
- // getUserWithdrawalIndices
344
+ // Withdrawal tracking
418
345
  {
419
346
  type: "function",
420
347
  name: "getUserWithdrawalIndices",
421
348
  inputs: [{ name: "user", type: "address" }],
422
- outputs: [{ name: "", type: "uint256[]" }],
349
+ outputs: [{ type: "uint256[]" }],
423
350
  stateMutability: "view",
424
351
  },
425
-
426
- // getWithdrawalStatus
427
352
  {
428
353
  type: "function",
429
354
  name: "getWithdrawalStatus",
@@ -434,123 +359,111 @@ export const RouterABI = [
434
359
  ],
435
360
  stateMutability: "view",
436
361
  },
437
-
438
- // Immutable addresses
439
- {
440
- type: "function",
441
- name: "wbnb",
442
- inputs: [],
443
- outputs: [{ name: "", type: "address" }],
444
- stateMutability: "view",
445
- },
446
- {
447
- type: "function",
448
- name: "usdt",
449
- inputs: [],
450
- outputs: [{ name: "", type: "address" }],
451
- stateMutability: "view",
452
- },
453
362
  {
454
363
  type: "function",
455
- name: "usdc",
456
- inputs: [],
457
- outputs: [{ name: "", type: "address" }],
364
+ name: "withdrawalRequests",
365
+ inputs: [{ name: "index", type: "uint256" }],
366
+ outputs: [
367
+ { name: "user", type: "address" },
368
+ { name: "listaIdx", type: "uint256" },
369
+ { name: "slisBNBAmount", type: "uint256" },
370
+ { name: "claimed", type: "bool" },
371
+ ],
458
372
  stateMutability: "view",
459
373
  },
374
+
375
+ // ============ Admin Functions ============
376
+
377
+ { type: "function", name: "owner", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
460
378
  {
461
379
  type: "function",
462
- name: "slisBNB",
463
- inputs: [],
464
- outputs: [{ name: "", type: "address" }],
465
- stateMutability: "view",
380
+ name: "setDefaultLST",
381
+ inputs: [{ name: "lst", type: "address" }],
382
+ outputs: [],
383
+ stateMutability: "nonpayable",
466
384
  },
467
385
  {
468
386
  type: "function",
469
- name: "asBNB",
470
- inputs: [],
471
- outputs: [{ name: "", type: "address" }],
472
- stateMutability: "view",
387
+ name: "addSupportedInputToken",
388
+ inputs: [{ name: "token", type: "address" }],
389
+ outputs: [],
390
+ stateMutability: "nonpayable",
473
391
  },
474
392
  {
475
393
  type: "function",
476
- name: "wclisBNB",
477
- inputs: [],
478
- outputs: [{ name: "", type: "address" }],
479
- stateMutability: "view",
394
+ name: "addSupportedLST",
395
+ inputs: [{ name: "lst", type: "address" }],
396
+ outputs: [],
397
+ stateMutability: "nonpayable",
480
398
  },
481
399
  {
482
400
  type: "function",
483
- name: "apUSD",
484
- inputs: [],
485
- outputs: [{ name: "", type: "address" }],
486
- stateMutability: "view",
401
+ name: "rescueTokens",
402
+ inputs: [
403
+ { name: "token", type: "address" },
404
+ { name: "amount", type: "uint256" },
405
+ ],
406
+ outputs: [],
407
+ stateMutability: "nonpayable",
487
408
  },
488
409
  {
489
410
  type: "function",
490
- name: "xBNB",
491
- inputs: [],
492
- outputs: [{ name: "", type: "address" }],
493
- stateMutability: "view",
411
+ name: "transferOwnership",
412
+ inputs: [{ name: "newOwner", type: "address" }],
413
+ outputs: [],
414
+ stateMutability: "nonpayable",
494
415
  },
416
+ { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" },
495
417
 
496
418
  // ============ Events ============
497
419
 
498
- // SwapAndMint
499
420
  {
500
421
  type: "event",
501
422
  name: "SwapAndMint",
502
423
  inputs: [
503
424
  { name: "user", type: "address", indexed: true },
504
- { name: "inputToken", type: "address", indexed: true },
425
+ { name: "inputToken", type: "address", indexed: false },
505
426
  { name: "inputAmount", type: "uint256", indexed: false },
506
- { name: "targetLST", type: "address", indexed: true },
427
+ { name: "lst", type: "address", indexed: false },
507
428
  { name: "lstAmount", type: "uint256", indexed: false },
508
429
  { name: "mintedToken", type: "address", indexed: false },
509
430
  { name: "mintedAmount", type: "uint256", indexed: false },
510
431
  ],
511
432
  },
512
-
513
- // StakeAndMint
514
433
  {
515
434
  type: "event",
516
435
  name: "StakeAndMint",
517
436
  inputs: [
518
437
  { name: "user", type: "address", indexed: true },
519
438
  { name: "bnbAmount", type: "uint256", indexed: false },
520
- { name: "targetLST", type: "address", indexed: true },
439
+ { name: "lst", type: "address", indexed: false },
521
440
  { name: "lstAmount", type: "uint256", indexed: false },
522
- { name: "mintedToken", type: "address", indexed: true },
441
+ { name: "mintedToken", type: "address", indexed: false },
523
442
  { name: "mintedAmount", type: "uint256", indexed: false },
524
443
  ],
525
444
  },
526
-
527
- // Mint
528
445
  {
529
446
  type: "event",
530
447
  name: "Mint",
531
448
  inputs: [
532
449
  { name: "user", type: "address", indexed: true },
533
- { name: "lst", type: "address", indexed: true },
450
+ { name: "lst", type: "address", indexed: false },
534
451
  { name: "lstAmount", type: "uint256", indexed: false },
535
- { name: "mintedToken", type: "address", indexed: true },
452
+ { name: "mintedToken", type: "address", indexed: false },
536
453
  { name: "mintedAmount", type: "uint256", indexed: false },
537
454
  ],
538
455
  },
539
-
540
- // Redeem
541
456
  {
542
457
  type: "event",
543
458
  name: "Redeem",
544
459
  inputs: [
545
460
  { name: "user", type: "address", indexed: true },
546
- { name: "redeemedToken", type: "address", indexed: true },
461
+ { name: "redeemedToken", type: "address", indexed: false },
547
462
  { name: "redeemedAmount", type: "uint256", indexed: false },
548
- { name: "lst", type: "address", indexed: true },
463
+ { name: "lst", type: "address", indexed: false },
549
464
  { name: "lstAmount", type: "uint256", indexed: false },
550
465
  ],
551
466
  },
552
-
553
- // RedeemAndSwap
554
467
  {
555
468
  type: "event",
556
469
  name: "RedeemAndSwap",
@@ -560,60 +473,70 @@ export const RouterABI = [
560
473
  { name: "redeemedAmount", type: "uint256", indexed: false },
561
474
  { name: "lst", type: "address", indexed: false },
562
475
  { name: "lstAmount", type: "uint256", indexed: false },
563
- { name: "outputToken", type: "address", indexed: true },
476
+ { name: "outputToken", type: "address", indexed: false },
564
477
  { name: "outputAmount", type: "uint256", indexed: false },
565
478
  ],
566
479
  },
567
-
568
- // UnstakeRequested
569
480
  {
570
481
  type: "event",
571
482
  name: "UnstakeRequested",
572
483
  inputs: [
573
484
  { name: "user", type: "address", indexed: true },
574
- { name: "requestIndex", type: "uint256", indexed: true },
485
+ { name: "requestIndex", type: "uint256", indexed: false },
575
486
  { name: "redeemedToken", type: "address", indexed: false },
576
487
  { name: "redeemedAmount", type: "uint256", indexed: false },
577
488
  { name: "slisBNBAmount", type: "uint256", indexed: false },
578
489
  ],
579
490
  },
580
-
581
- // UnstakeClaimed
582
491
  {
583
492
  type: "event",
584
493
  name: "UnstakeClaimed",
585
494
  inputs: [
586
495
  { name: "user", type: "address", indexed: true },
587
- { name: "requestIndex", type: "uint256", indexed: true },
496
+ { name: "requestIndex", type: "uint256", indexed: false },
588
497
  { name: "bnbAmount", type: "uint256", indexed: false },
589
498
  ],
590
499
  },
591
-
592
- // DefaultLSTUpdated
593
500
  {
594
501
  type: "event",
595
502
  name: "DefaultLSTUpdated",
596
503
  inputs: [
597
- { name: "oldLST", type: "address", indexed: true },
598
- { name: "newLST", type: "address", indexed: true },
504
+ { name: "oldLST", type: "address", indexed: false },
505
+ { name: "newLST", type: "address", indexed: false },
506
+ ],
507
+ },
508
+ {
509
+ type: "event",
510
+ name: "OwnershipTransferred",
511
+ inputs: [
512
+ { name: "previousOwner", type: "address", indexed: true },
513
+ { name: "newOwner", type: "address", indexed: true },
599
514
  ],
600
515
  },
601
516
 
602
517
  // ============ Errors ============
603
518
 
604
- { type: "error", name: "UnsupportedInputToken", inputs: [] },
605
- { type: "error", name: "UnsupportedLST", inputs: [] },
606
519
  { type: "error", name: "DeadlineExpired", inputs: [] },
520
+ { type: "error", name: "DefaultLSTNotSet", inputs: [] },
607
521
  { type: "error", name: "InsufficientOutput", inputs: [] },
608
- { type: "error", name: "ZeroAmount", inputs: [] },
522
+ { type: "error", name: "InvalidPoolFee", inputs: [] },
609
523
  { type: "error", name: "InvalidRecipient", inputs: [] },
610
- { type: "error", name: "SwapFailed", inputs: [] },
524
+ { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
611
525
  { type: "error", name: "MintFailed", inputs: [] },
612
526
  { type: "error", name: "NativeTransferFailed", inputs: [] },
613
- { type: "error", name: "InvalidPoolFee", inputs: [] },
614
- { type: "error", name: "DefaultLSTNotSet", inputs: [] },
615
- { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
616
- { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
617
- { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
618
527
  { type: "error", name: "OnlySlisBNBSupported", inputs: [] },
528
+ { type: "error", name: "SwapFailed", inputs: [] },
529
+ { type: "error", name: "UnsupportedInputToken", inputs: [] },
530
+ { type: "error", name: "UnsupportedLST", inputs: [] },
531
+ { type: "error", name: "V3PoolNotFound", inputs: [] },
532
+ { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
533
+ { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
534
+ { type: "error", name: "ZeroAmount", inputs: [] },
535
+ { type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
536
+ { type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address" }] },
537
+ { type: "error", name: "OwnableUnauthorizedAccount", inputs: [{ name: "account", type: "address" }] },
538
+ { type: "error", name: "SafeERC20FailedOperation", inputs: [{ name: "token", type: "address" }] },
539
+
540
+ // Receive
541
+ { type: "receive", stateMutability: "payable" },
619
542
  ] 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;