@aspan/sdk 0.3.1 → 0.4.1
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 +310 -512
- package/dist/index.d.mts +303 -323
- package/dist/index.d.ts +303 -323
- package/dist/index.js +298 -381
- package/dist/index.mjs +297 -381
- package/package.json +1 -1
- package/src/__tests__/fork.test.ts +2 -2
- package/src/__tests__/router.test.ts +145 -89
- package/src/abi/diamond.ts +74 -0
- package/src/abi/router.ts +60 -191
- package/src/abi/sApUSD.ts +100 -0
- package/src/bot/config.ts +51 -1
- package/src/bot/index.ts +69 -1
- package/src/bot/services/fee-manager.ts +303 -0
- package/src/bot/services/risk-keeper.ts +519 -0
- package/src/client.ts +109 -0
- package/src/index.ts +22 -5
- package/src/router.ts +58 -216
- package/src/types.ts +60 -43
package/src/router.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aspan Router Client
|
|
3
3
|
* TypeScript client for interacting with the AspanRouter periphery contract
|
|
4
|
+
* Updated: 2026-02-04 (v2.0.0 - consolidated API)
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -22,11 +23,10 @@ import type {
|
|
|
22
23
|
SwapAndMintParams,
|
|
23
24
|
StakeAndMintParams,
|
|
24
25
|
SwapAndMintDefaultParams,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
RouterRedeemApUSDParams,
|
|
28
|
-
RouterRedeemXBNBParams,
|
|
26
|
+
RouterMintParams2,
|
|
27
|
+
RouterRedeemParams,
|
|
29
28
|
RouterRedeemAndSwapParams,
|
|
29
|
+
RouterRedeemAndUnstakeParams,
|
|
30
30
|
WithdrawalRequestInfo,
|
|
31
31
|
} from "./types";
|
|
32
32
|
|
|
@@ -117,50 +117,32 @@ export class AspanRouterReadClient {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* Preview
|
|
120
|
+
* Preview mint output for a given LST amount
|
|
121
|
+
* @param lst LST token address
|
|
122
|
+
* @param lstAmount Amount of LST
|
|
123
|
+
* @param mintXBNB true = preview xBNB mint, false = preview apUSD mint
|
|
121
124
|
*/
|
|
122
|
-
async
|
|
125
|
+
async previewMint(lst: Address, lstAmount: bigint, mintXBNB: boolean): Promise<bigint> {
|
|
123
126
|
return this.publicClient.readContract({
|
|
124
127
|
address: this.routerAddress,
|
|
125
128
|
abi: RouterABI,
|
|
126
|
-
functionName: "
|
|
127
|
-
args: [lst, lstAmount],
|
|
129
|
+
functionName: "previewMint",
|
|
130
|
+
args: [lst, lstAmount, mintXBNB],
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
/**
|
|
132
|
-
* Preview
|
|
135
|
+
* Preview redeem output
|
|
136
|
+
* @param lst LST token to receive
|
|
137
|
+
* @param redeemXBNB true = redeem xBNB, false = redeem apUSD
|
|
138
|
+
* @param amount Amount of apUSD/xBNB to redeem
|
|
133
139
|
*/
|
|
134
|
-
async
|
|
140
|
+
async previewRedeem(lst: Address, redeemXBNB: boolean, amount: bigint): Promise<bigint> {
|
|
135
141
|
return this.publicClient.readContract({
|
|
136
142
|
address: this.routerAddress,
|
|
137
143
|
abi: RouterABI,
|
|
138
|
-
functionName: "
|
|
139
|
-
args: [lst,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Preview LST output for redeeming apUSD
|
|
145
|
-
*/
|
|
146
|
-
async previewRedeemApUSD(lst: Address, apUSDAmount: bigint): Promise<bigint> {
|
|
147
|
-
return this.publicClient.readContract({
|
|
148
|
-
address: this.routerAddress,
|
|
149
|
-
abi: RouterABI,
|
|
150
|
-
functionName: "previewRedeemApUSD",
|
|
151
|
-
args: [lst, apUSDAmount],
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Preview LST output for redeeming xBNB
|
|
157
|
-
*/
|
|
158
|
-
async previewRedeemXBNB(lst: Address, xBNBAmount: bigint): Promise<bigint> {
|
|
159
|
-
return this.publicClient.readContract({
|
|
160
|
-
address: this.routerAddress,
|
|
161
|
-
abi: RouterABI,
|
|
162
|
-
functionName: "previewRedeemXBNB",
|
|
163
|
-
args: [lst, xBNBAmount],
|
|
144
|
+
functionName: "previewRedeem",
|
|
145
|
+
args: [lst, redeemXBNB, amount],
|
|
164
146
|
});
|
|
165
147
|
}
|
|
166
148
|
|
|
@@ -290,9 +272,11 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
290
272
|
// ============ Core Functions ============
|
|
291
273
|
|
|
292
274
|
/**
|
|
293
|
-
* Swap input token to LST and mint apUSD
|
|
275
|
+
* Swap input token to LST and mint apUSD or xBNB
|
|
276
|
+
* @param params.swapParams Swap configuration
|
|
277
|
+
* @param params.mintParams Mint configuration (mintXBNB determines output token)
|
|
294
278
|
*/
|
|
295
|
-
async
|
|
279
|
+
async swapAndMint(params: SwapAndMintParams): Promise<Hash> {
|
|
296
280
|
const value =
|
|
297
281
|
params.swapParams.inputToken === zeroAddress
|
|
298
282
|
? params.swapParams.inputAmount
|
|
@@ -303,7 +287,7 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
303
287
|
account: this.walletClient.account!,
|
|
304
288
|
address: this.routerAddress,
|
|
305
289
|
abi: RouterABI,
|
|
306
|
-
functionName: "
|
|
290
|
+
functionName: "swapAndMint",
|
|
307
291
|
args: [
|
|
308
292
|
{
|
|
309
293
|
inputToken: params.swapParams.inputToken,
|
|
@@ -313,7 +297,7 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
313
297
|
poolFee: params.swapParams.poolFee,
|
|
314
298
|
},
|
|
315
299
|
{
|
|
316
|
-
mintXBNB:
|
|
300
|
+
mintXBNB: params.mintParams.mintXBNB,
|
|
317
301
|
minMintOut: params.mintParams.minMintOut,
|
|
318
302
|
recipient: params.mintParams.recipient,
|
|
319
303
|
deadline: params.mintParams.deadline,
|
|
@@ -324,34 +308,25 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
324
308
|
}
|
|
325
309
|
|
|
326
310
|
/**
|
|
327
|
-
* Swap input token
|
|
311
|
+
* Swap input token and mint using default LST (simplified)
|
|
312
|
+
* @param params.mintXBNB true = mint xBNB, false = mint apUSD
|
|
328
313
|
*/
|
|
329
|
-
async
|
|
314
|
+
async swapAndMintDefault(params: SwapAndMintDefaultParams): Promise<Hash> {
|
|
330
315
|
const value =
|
|
331
|
-
params.
|
|
332
|
-
? params.swapParams.inputAmount
|
|
333
|
-
: 0n;
|
|
316
|
+
params.inputToken === zeroAddress ? params.value ?? params.inputAmount : 0n;
|
|
334
317
|
|
|
335
318
|
return this.walletClient.writeContract({
|
|
336
319
|
chain: this.chain,
|
|
337
320
|
account: this.walletClient.account!,
|
|
338
321
|
address: this.routerAddress,
|
|
339
322
|
abi: RouterABI,
|
|
340
|
-
functionName: "
|
|
323
|
+
functionName: "swapAndMintDefault",
|
|
341
324
|
args: [
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
poolFee: params.swapParams.poolFee,
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
mintXBNB: true, // swapAndMintXBNB always mints xBNB
|
|
351
|
-
minMintOut: params.mintParams.minMintOut,
|
|
352
|
-
recipient: params.mintParams.recipient,
|
|
353
|
-
deadline: params.mintParams.deadline,
|
|
354
|
-
},
|
|
325
|
+
params.inputToken,
|
|
326
|
+
params.inputAmount,
|
|
327
|
+
params.mintXBNB,
|
|
328
|
+
params.minMintOut,
|
|
329
|
+
params.deadline,
|
|
355
330
|
],
|
|
356
331
|
value,
|
|
357
332
|
});
|
|
@@ -359,6 +334,7 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
359
334
|
|
|
360
335
|
/**
|
|
361
336
|
* Stake native BNB directly to LST and mint
|
|
337
|
+
* @param params.isXBNB true = mint xBNB, false = mint apUSD
|
|
362
338
|
*/
|
|
363
339
|
async stakeAndMint(params: StakeAndMintParams): Promise<Hash> {
|
|
364
340
|
return this.walletClient.writeContract({
|
|
@@ -377,182 +353,61 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
377
353
|
});
|
|
378
354
|
}
|
|
379
355
|
|
|
380
|
-
// ============ Simplified Functions ============
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Swap input token and mint apUSD using default LST
|
|
384
|
-
*/
|
|
385
|
-
async swapAndMintApUSDDefault(params: SwapAndMintDefaultParams): Promise<Hash> {
|
|
386
|
-
const value =
|
|
387
|
-
params.inputToken === zeroAddress ? params.value ?? params.inputAmount : 0n;
|
|
388
|
-
|
|
389
|
-
return this.walletClient.writeContract({
|
|
390
|
-
chain: this.chain,
|
|
391
|
-
account: this.walletClient.account!,
|
|
392
|
-
address: this.routerAddress,
|
|
393
|
-
abi: RouterABI,
|
|
394
|
-
functionName: "swapAndMintApUSDDefault",
|
|
395
|
-
args: [
|
|
396
|
-
params.inputToken,
|
|
397
|
-
params.inputAmount,
|
|
398
|
-
params.minMintOut,
|
|
399
|
-
params.deadline,
|
|
400
|
-
],
|
|
401
|
-
value,
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Swap input token and mint xBNB using default LST
|
|
407
|
-
*/
|
|
408
|
-
async swapAndMintXBNBDefault(params: SwapAndMintDefaultParams): Promise<Hash> {
|
|
409
|
-
const value =
|
|
410
|
-
params.inputToken === zeroAddress ? params.value ?? params.inputAmount : 0n;
|
|
411
|
-
|
|
412
|
-
return this.walletClient.writeContract({
|
|
413
|
-
chain: this.chain,
|
|
414
|
-
account: this.walletClient.account!,
|
|
415
|
-
address: this.routerAddress,
|
|
416
|
-
abi: RouterABI,
|
|
417
|
-
functionName: "swapAndMintXBNBDefault",
|
|
418
|
-
args: [
|
|
419
|
-
params.inputToken,
|
|
420
|
-
params.inputAmount,
|
|
421
|
-
params.minMintOut,
|
|
422
|
-
params.deadline,
|
|
423
|
-
],
|
|
424
|
-
value,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Stake native BNB and mint apUSD using default LST
|
|
430
|
-
*/
|
|
431
|
-
async stakeAndMintApUSD(minMintOut: bigint, value: bigint): Promise<Hash> {
|
|
432
|
-
return this.walletClient.writeContract({
|
|
433
|
-
chain: this.chain,
|
|
434
|
-
account: this.walletClient.account!,
|
|
435
|
-
address: this.routerAddress,
|
|
436
|
-
abi: RouterABI,
|
|
437
|
-
functionName: "stakeAndMintApUSD",
|
|
438
|
-
args: [minMintOut],
|
|
439
|
-
value,
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Stake native BNB and mint xBNB using default LST
|
|
445
|
-
*/
|
|
446
|
-
async stakeAndMintXBNB(minMintOut: bigint, value: bigint): Promise<Hash> {
|
|
447
|
-
return this.walletClient.writeContract({
|
|
448
|
-
chain: this.chain,
|
|
449
|
-
account: this.walletClient.account!,
|
|
450
|
-
address: this.routerAddress,
|
|
451
|
-
abi: RouterABI,
|
|
452
|
-
functionName: "stakeAndMintXBNB",
|
|
453
|
-
args: [minMintOut],
|
|
454
|
-
value,
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
|
|
458
356
|
// ============ Direct Mint/Redeem Functions ============
|
|
459
357
|
|
|
460
358
|
/**
|
|
461
|
-
* Mint apUSD by providing LST directly (no swap)
|
|
462
|
-
|
|
463
|
-
async mintApUSD(params: RouterMintApUSDParams): Promise<Hash> {
|
|
464
|
-
return this.walletClient.writeContract({
|
|
465
|
-
chain: this.chain,
|
|
466
|
-
account: this.walletClient.account!,
|
|
467
|
-
address: this.routerAddress,
|
|
468
|
-
abi: RouterABI,
|
|
469
|
-
functionName: "mintApUSD",
|
|
470
|
-
args: [params.lst, params.lstAmount, params.minOut ?? 0n],
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Mint xBNB by providing LST directly (no swap)
|
|
359
|
+
* Mint apUSD or xBNB by providing LST directly (no swap)
|
|
360
|
+
* @param params.mintXBNB true = mint xBNB, false = mint apUSD
|
|
476
361
|
*/
|
|
477
|
-
async
|
|
362
|
+
async mint(params: RouterMintParams2): Promise<Hash> {
|
|
478
363
|
return this.walletClient.writeContract({
|
|
479
364
|
chain: this.chain,
|
|
480
365
|
account: this.walletClient.account!,
|
|
481
366
|
address: this.routerAddress,
|
|
482
367
|
abi: RouterABI,
|
|
483
|
-
functionName: "
|
|
484
|
-
args: [params.lst, params.lstAmount, params.minOut ?? 0n],
|
|
368
|
+
functionName: "mint",
|
|
369
|
+
args: [params.lst, params.lstAmount, params.mintXBNB, params.minOut ?? 0n],
|
|
485
370
|
});
|
|
486
371
|
}
|
|
487
372
|
|
|
488
373
|
/**
|
|
489
|
-
* Redeem apUSD for LST (no swap)
|
|
374
|
+
* Redeem apUSD or xBNB for LST (no swap)
|
|
375
|
+
* @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
|
|
490
376
|
*/
|
|
491
|
-
async
|
|
377
|
+
async redeem(params: RouterRedeemParams): Promise<Hash> {
|
|
492
378
|
return this.walletClient.writeContract({
|
|
493
379
|
chain: this.chain,
|
|
494
380
|
account: this.walletClient.account!,
|
|
495
381
|
address: this.routerAddress,
|
|
496
382
|
abi: RouterABI,
|
|
497
|
-
functionName: "
|
|
498
|
-
args: [params.lst, params.
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Redeem xBNB for LST (no swap)
|
|
504
|
-
*/
|
|
505
|
-
async redeemXBNB(params: RouterRedeemXBNBParams): Promise<Hash> {
|
|
506
|
-
return this.walletClient.writeContract({
|
|
507
|
-
chain: this.chain,
|
|
508
|
-
account: this.walletClient.account!,
|
|
509
|
-
address: this.routerAddress,
|
|
510
|
-
abi: RouterABI,
|
|
511
|
-
functionName: "redeemXBNB",
|
|
512
|
-
args: [params.lst, params.xBNBAmount, params.minOut ?? 0n],
|
|
383
|
+
functionName: "redeem",
|
|
384
|
+
args: [params.lst, params.redeemXBNB, params.amount, params.minOut ?? 0n],
|
|
513
385
|
});
|
|
514
386
|
}
|
|
515
387
|
|
|
516
388
|
// ============ Redeem and Swap Functions ============
|
|
517
389
|
|
|
518
390
|
/**
|
|
519
|
-
* Redeem apUSD and swap LST to output token via V3 path
|
|
520
|
-
* @param params.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return this.walletClient.writeContract({
|
|
524
|
-
chain: this.chain,
|
|
525
|
-
account: this.walletClient.account!,
|
|
526
|
-
address: this.routerAddress,
|
|
527
|
-
abi: RouterABI,
|
|
528
|
-
functionName: "redeemApUSDAndSwap",
|
|
529
|
-
args: [
|
|
530
|
-
params.lst,
|
|
531
|
-
params.amount,
|
|
532
|
-
params.path,
|
|
533
|
-
params.minOut,
|
|
534
|
-
params.deadline,
|
|
535
|
-
],
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Redeem xBNB and swap LST to output token via V3 path
|
|
541
|
-
* @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
|
|
391
|
+
* Redeem apUSD/xBNB and swap LST to output token via V3 path
|
|
392
|
+
* @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
|
|
393
|
+
* @param params.path PancakeSwap V3 encoded path (use encodeV3Path helper)
|
|
394
|
+
* @param params.unwrapBNB If true and output is WBNB, unwrap to native BNB
|
|
542
395
|
*/
|
|
543
|
-
async
|
|
396
|
+
async redeemAndSwap(params: RouterRedeemAndSwapParams): Promise<Hash> {
|
|
544
397
|
return this.walletClient.writeContract({
|
|
545
398
|
chain: this.chain,
|
|
546
399
|
account: this.walletClient.account!,
|
|
547
400
|
address: this.routerAddress,
|
|
548
401
|
abi: RouterABI,
|
|
549
|
-
functionName: "
|
|
402
|
+
functionName: "redeemAndSwap",
|
|
550
403
|
args: [
|
|
551
404
|
params.lst,
|
|
405
|
+
params.redeemXBNB,
|
|
552
406
|
params.amount,
|
|
553
407
|
params.path,
|
|
554
408
|
params.minOut,
|
|
555
409
|
params.deadline,
|
|
410
|
+
params.unwrapBNB,
|
|
556
411
|
],
|
|
557
412
|
});
|
|
558
413
|
}
|
|
@@ -560,30 +415,17 @@ export class AspanRouterClient extends AspanRouterReadClient {
|
|
|
560
415
|
// ============ Native Unstake Functions ============
|
|
561
416
|
|
|
562
417
|
/**
|
|
563
|
-
* Redeem apUSD and request native unstake from Lista (starts unbonding period)
|
|
564
|
-
|
|
565
|
-
async redeemApUSDAndRequestUnstake(apUSDAmount: bigint): Promise<Hash> {
|
|
566
|
-
return this.walletClient.writeContract({
|
|
567
|
-
chain: this.chain,
|
|
568
|
-
account: this.walletClient.account!,
|
|
569
|
-
address: this.routerAddress,
|
|
570
|
-
abi: RouterABI,
|
|
571
|
-
functionName: "redeemApUSDAndRequestUnstake",
|
|
572
|
-
args: [apUSDAmount],
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Redeem xBNB and request native unstake from Lista (starts unbonding period)
|
|
418
|
+
* Redeem apUSD/xBNB and request native unstake from Lista (starts unbonding period)
|
|
419
|
+
* @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
|
|
578
420
|
*/
|
|
579
|
-
async
|
|
421
|
+
async redeemAndRequestUnstake(params: RouterRedeemAndUnstakeParams): Promise<Hash> {
|
|
580
422
|
return this.walletClient.writeContract({
|
|
581
423
|
chain: this.chain,
|
|
582
424
|
account: this.walletClient.account!,
|
|
583
425
|
address: this.routerAddress,
|
|
584
426
|
abi: RouterABI,
|
|
585
|
-
functionName: "
|
|
586
|
-
args: [
|
|
427
|
+
functionName: "redeemAndRequestUnstake",
|
|
428
|
+
args: [params.redeemXBNB, params.amount],
|
|
587
429
|
});
|
|
588
430
|
}
|
|
589
431
|
|
package/src/types.ts
CHANGED
|
@@ -272,7 +272,7 @@ export interface RouterMintParams {
|
|
|
272
272
|
deadline: bigint;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
/** Parameters for swapAndMint
|
|
275
|
+
/** Parameters for swapAndMint function */
|
|
276
276
|
export interface SwapAndMintParams {
|
|
277
277
|
swapParams: RouterSwapParams;
|
|
278
278
|
mintParams: RouterMintParams;
|
|
@@ -292,12 +292,14 @@ export interface StakeAndMintParams {
|
|
|
292
292
|
value: bigint;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
/** Parameters for
|
|
295
|
+
/** Parameters for swapAndMintDefault function */
|
|
296
296
|
export interface SwapAndMintDefaultParams {
|
|
297
297
|
/** Input token address (address(0) for native BNB) */
|
|
298
298
|
inputToken: Address;
|
|
299
299
|
/** Amount of input token */
|
|
300
300
|
inputAmount: bigint;
|
|
301
|
+
/** true = mint xBNB, false = mint apUSD */
|
|
302
|
+
mintXBNB: boolean;
|
|
301
303
|
/** Minimum output to receive */
|
|
302
304
|
minMintOut: bigint;
|
|
303
305
|
/** Transaction deadline timestamp */
|
|
@@ -306,55 +308,41 @@ export interface SwapAndMintDefaultParams {
|
|
|
306
308
|
value?: bigint;
|
|
307
309
|
}
|
|
308
310
|
|
|
309
|
-
/** Parameters for router
|
|
310
|
-
export interface
|
|
311
|
-
/** LST token address */
|
|
312
|
-
lst: Address;
|
|
313
|
-
/** Amount of LST to deposit */
|
|
314
|
-
lstAmount: bigint;
|
|
315
|
-
/** Minimum apUSD to receive */
|
|
316
|
-
minOut?: bigint;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/** Parameters for router direct mint xBNB functions */
|
|
320
|
-
export interface RouterMintXBNBParams {
|
|
311
|
+
/** Parameters for router mint function (unified) */
|
|
312
|
+
export interface RouterMintParams2 {
|
|
321
313
|
/** LST token address */
|
|
322
314
|
lst: Address;
|
|
323
315
|
/** Amount of LST to deposit */
|
|
324
316
|
lstAmount: bigint;
|
|
325
|
-
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
/** Parameters for router redeem apUSD functions */
|
|
330
|
-
export interface RouterRedeemApUSDParams {
|
|
331
|
-
/** LST token to receive */
|
|
332
|
-
lst: Address;
|
|
333
|
-
/** Amount of apUSD to redeem */
|
|
334
|
-
apUSDAmount: bigint;
|
|
335
|
-
/** Minimum LST to receive */
|
|
317
|
+
/** true = mint xBNB, false = mint apUSD */
|
|
318
|
+
mintXBNB: boolean;
|
|
319
|
+
/** Minimum output to receive */
|
|
336
320
|
minOut?: bigint;
|
|
337
321
|
}
|
|
338
322
|
|
|
339
|
-
/** Parameters for router redeem
|
|
340
|
-
export interface
|
|
323
|
+
/** Parameters for router redeem function (unified) */
|
|
324
|
+
export interface RouterRedeemParams {
|
|
341
325
|
/** LST token to receive */
|
|
342
326
|
lst: Address;
|
|
343
|
-
/**
|
|
344
|
-
|
|
327
|
+
/** true = redeem xBNB, false = redeem apUSD */
|
|
328
|
+
redeemXBNB: boolean;
|
|
329
|
+
/** Amount of apUSD/xBNB to redeem */
|
|
330
|
+
amount: bigint;
|
|
345
331
|
/** Minimum LST to receive */
|
|
346
332
|
minOut?: bigint;
|
|
347
333
|
}
|
|
348
334
|
|
|
349
|
-
/** Parameters for redeemAndSwap
|
|
335
|
+
/** Parameters for redeemAndSwap function (unified with unwrapBNB) */
|
|
350
336
|
export interface RouterRedeemAndSwapParams {
|
|
351
337
|
/** LST to redeem */
|
|
352
338
|
lst: Address;
|
|
339
|
+
/** true = redeem xBNB, false = redeem apUSD */
|
|
340
|
+
redeemXBNB: boolean;
|
|
353
341
|
/** Amount to redeem (apUSD or xBNB) */
|
|
354
342
|
amount: bigint;
|
|
355
343
|
/**
|
|
356
344
|
* PancakeSwap V3 encoded swap path (LST → ... → outputToken)
|
|
357
|
-
* Use encodeV3Path() helper
|
|
345
|
+
* Use encodeV3Path() helper
|
|
358
346
|
* Example: slisBNB → WBNB → USDT
|
|
359
347
|
*/
|
|
360
348
|
path: `0x${string}`;
|
|
@@ -362,6 +350,16 @@ export interface RouterRedeemAndSwapParams {
|
|
|
362
350
|
minOut: bigint;
|
|
363
351
|
/** Transaction deadline timestamp */
|
|
364
352
|
deadline: bigint;
|
|
353
|
+
/** If true and output is WBNB, unwrap to native BNB */
|
|
354
|
+
unwrapBNB: boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Parameters for redeemAndRequestUnstake function (unified) */
|
|
358
|
+
export interface RouterRedeemAndUnstakeParams {
|
|
359
|
+
/** true = redeem xBNB, false = redeem apUSD */
|
|
360
|
+
redeemXBNB: boolean;
|
|
361
|
+
/** Amount to redeem (apUSD or xBNB) */
|
|
362
|
+
amount: bigint;
|
|
365
363
|
}
|
|
366
364
|
|
|
367
365
|
/**
|
|
@@ -384,18 +382,6 @@ export function encodeV3Path(tokens: Address[], fees: number[]): `0x${string}` {
|
|
|
384
382
|
return `0x${path}`;
|
|
385
383
|
}
|
|
386
384
|
|
|
387
|
-
/** Parameters for redeemAndUnstake functions */
|
|
388
|
-
export interface RouterRedeemAndUnstakeParams {
|
|
389
|
-
/** LST to redeem */
|
|
390
|
-
lst: Address;
|
|
391
|
-
/** Amount to redeem (apUSD or xBNB) */
|
|
392
|
-
amount: bigint;
|
|
393
|
-
/** Minimum BNB to receive */
|
|
394
|
-
minBNBOut: bigint;
|
|
395
|
-
/** Transaction deadline timestamp */
|
|
396
|
-
deadline: bigint;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
385
|
/** Withdrawal request status */
|
|
400
386
|
export interface WithdrawalRequestInfo {
|
|
401
387
|
/** Whether the request can be claimed */
|
|
@@ -479,3 +465,34 @@ export interface UnstakeClaimedEvent {
|
|
|
479
465
|
requestIndex: bigint;
|
|
480
466
|
bnbAmount: bigint;
|
|
481
467
|
}
|
|
468
|
+
|
|
469
|
+
// ============ Legacy Types (deprecated) ============
|
|
470
|
+
// These are kept for backwards compatibility but should not be used in new code
|
|
471
|
+
|
|
472
|
+
/** @deprecated Use RouterMintParams2 instead */
|
|
473
|
+
export interface RouterMintApUSDParams {
|
|
474
|
+
lst: Address;
|
|
475
|
+
lstAmount: bigint;
|
|
476
|
+
minOut?: bigint;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** @deprecated Use RouterMintParams2 instead */
|
|
480
|
+
export interface RouterMintXBNBParams {
|
|
481
|
+
lst: Address;
|
|
482
|
+
lstAmount: bigint;
|
|
483
|
+
minOut?: bigint;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** @deprecated Use RouterRedeemParams instead */
|
|
487
|
+
export interface RouterRedeemApUSDParams {
|
|
488
|
+
lst: Address;
|
|
489
|
+
apUSDAmount: bigint;
|
|
490
|
+
minOut?: bigint;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** @deprecated Use RouterRedeemParams instead */
|
|
494
|
+
export interface RouterRedeemXBNBParams {
|
|
495
|
+
lst: Address;
|
|
496
|
+
xBNBAmount: bigint;
|
|
497
|
+
minOut?: bigint;
|
|
498
|
+
}
|