@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/README.md +32 -25
- package/dist/index.d.mts +325 -217
- package/dist/index.d.ts +325 -217
- package/dist/index.js +213 -208
- package/dist/index.mjs +212 -208
- package/package.json +1 -1
- package/src/__tests__/router.test.ts +378 -0
- package/src/abi/router.ts +153 -167
- package/src/index.ts +3 -2
- package/src/router.ts +48 -62
- package/src/types.ts +28 -12
package/dist/index.mjs
CHANGED
|
@@ -1422,7 +1422,7 @@ import { bsc as bsc2, bscTestnet as bscTestnet2 } from "viem/chains";
|
|
|
1422
1422
|
|
|
1423
1423
|
// src/abi/router.ts
|
|
1424
1424
|
var RouterABI = [
|
|
1425
|
-
// ============ Core Functions ============
|
|
1425
|
+
// ============ Core Swap+Mint Functions ============
|
|
1426
1426
|
// swapAndMintApUSD
|
|
1427
1427
|
{
|
|
1428
1428
|
type: "function",
|
|
@@ -1436,15 +1436,13 @@ var RouterABI = [
|
|
|
1436
1436
|
{ name: "inputAmount", type: "uint256" },
|
|
1437
1437
|
{ name: "targetLST", type: "address" },
|
|
1438
1438
|
{ name: "minLSTOut", type: "uint256" },
|
|
1439
|
-
{ name: "poolFee", type: "uint24" }
|
|
1440
|
-
{ name: "useV2", type: "bool" }
|
|
1439
|
+
{ name: "poolFee", type: "uint24" }
|
|
1441
1440
|
]
|
|
1442
1441
|
},
|
|
1443
1442
|
{
|
|
1444
1443
|
name: "mintParams",
|
|
1445
1444
|
type: "tuple",
|
|
1446
1445
|
components: [
|
|
1447
|
-
{ name: "mintXBNB", type: "bool" },
|
|
1448
1446
|
{ name: "minMintOut", type: "uint256" },
|
|
1449
1447
|
{ name: "recipient", type: "address" },
|
|
1450
1448
|
{ name: "deadline", type: "uint256" }
|
|
@@ -1470,15 +1468,13 @@ var RouterABI = [
|
|
|
1470
1468
|
{ name: "inputAmount", type: "uint256" },
|
|
1471
1469
|
{ name: "targetLST", type: "address" },
|
|
1472
1470
|
{ name: "minLSTOut", type: "uint256" },
|
|
1473
|
-
{ name: "poolFee", type: "uint24" }
|
|
1474
|
-
{ name: "useV2", type: "bool" }
|
|
1471
|
+
{ name: "poolFee", type: "uint24" }
|
|
1475
1472
|
]
|
|
1476
1473
|
},
|
|
1477
1474
|
{
|
|
1478
1475
|
name: "mintParams",
|
|
1479
1476
|
type: "tuple",
|
|
1480
1477
|
components: [
|
|
1481
|
-
{ name: "mintXBNB", type: "bool" },
|
|
1482
1478
|
{ name: "minMintOut", type: "uint256" },
|
|
1483
1479
|
{ name: "recipient", type: "address" },
|
|
1484
1480
|
{ name: "deadline", type: "uint256" }
|
|
@@ -1491,13 +1487,14 @@ var RouterABI = [
|
|
|
1491
1487
|
],
|
|
1492
1488
|
stateMutability: "payable"
|
|
1493
1489
|
},
|
|
1490
|
+
// ============ Stake+Mint Functions ============
|
|
1494
1491
|
// stakeAndMint
|
|
1495
1492
|
{
|
|
1496
1493
|
type: "function",
|
|
1497
1494
|
name: "stakeAndMint",
|
|
1498
1495
|
inputs: [
|
|
1499
1496
|
{ name: "targetLST", type: "address" },
|
|
1500
|
-
{ name: "
|
|
1497
|
+
{ name: "isXBNB", type: "bool" },
|
|
1501
1498
|
{ name: "minMintOut", type: "uint256" },
|
|
1502
1499
|
{ name: "deadline", type: "uint256" }
|
|
1503
1500
|
],
|
|
@@ -1507,7 +1504,23 @@ var RouterABI = [
|
|
|
1507
1504
|
],
|
|
1508
1505
|
stateMutability: "payable"
|
|
1509
1506
|
},
|
|
1510
|
-
//
|
|
1507
|
+
// stakeAndMintApUSD (simplified)
|
|
1508
|
+
{
|
|
1509
|
+
type: "function",
|
|
1510
|
+
name: "stakeAndMintApUSD",
|
|
1511
|
+
inputs: [{ name: "minMintOut", type: "uint256" }],
|
|
1512
|
+
outputs: [{ name: "apUSDAmount", type: "uint256" }],
|
|
1513
|
+
stateMutability: "payable"
|
|
1514
|
+
},
|
|
1515
|
+
// stakeAndMintXBNB (simplified)
|
|
1516
|
+
{
|
|
1517
|
+
type: "function",
|
|
1518
|
+
name: "stakeAndMintXBNB",
|
|
1519
|
+
inputs: [{ name: "minMintOut", type: "uint256" }],
|
|
1520
|
+
outputs: [{ name: "xBNBAmount", type: "uint256" }],
|
|
1521
|
+
stateMutability: "payable"
|
|
1522
|
+
},
|
|
1523
|
+
// ============ Simplified Swap+Mint Functions ============
|
|
1511
1524
|
// swapAndMintApUSDDefault
|
|
1512
1525
|
{
|
|
1513
1526
|
type: "function",
|
|
@@ -1534,22 +1547,6 @@ var RouterABI = [
|
|
|
1534
1547
|
outputs: [{ name: "xBNBAmount", type: "uint256" }],
|
|
1535
1548
|
stateMutability: "payable"
|
|
1536
1549
|
},
|
|
1537
|
-
// stakeAndMintApUSD
|
|
1538
|
-
{
|
|
1539
|
-
type: "function",
|
|
1540
|
-
name: "stakeAndMintApUSD",
|
|
1541
|
-
inputs: [{ name: "minMintOut", type: "uint256" }],
|
|
1542
|
-
outputs: [{ name: "apUSDAmount", type: "uint256" }],
|
|
1543
|
-
stateMutability: "payable"
|
|
1544
|
-
},
|
|
1545
|
-
// stakeAndMintXBNB
|
|
1546
|
-
{
|
|
1547
|
-
type: "function",
|
|
1548
|
-
name: "stakeAndMintXBNB",
|
|
1549
|
-
inputs: [{ name: "minMintOut", type: "uint256" }],
|
|
1550
|
-
outputs: [{ name: "xBNBAmount", type: "uint256" }],
|
|
1551
|
-
stateMutability: "payable"
|
|
1552
|
-
},
|
|
1553
1550
|
// ============ Direct Mint/Redeem Functions ============
|
|
1554
1551
|
// mintApUSD
|
|
1555
1552
|
{
|
|
@@ -1599,7 +1596,7 @@ var RouterABI = [
|
|
|
1599
1596
|
outputs: [{ name: "lstAmount", type: "uint256" }],
|
|
1600
1597
|
stateMutability: "nonpayable"
|
|
1601
1598
|
},
|
|
1602
|
-
// ============ Redeem
|
|
1599
|
+
// ============ Redeem + Swap Functions (V3 path) ============
|
|
1603
1600
|
// redeemApUSDAndSwap
|
|
1604
1601
|
{
|
|
1605
1602
|
type: "function",
|
|
@@ -1607,11 +1604,9 @@ var RouterABI = [
|
|
|
1607
1604
|
inputs: [
|
|
1608
1605
|
{ name: "lst", type: "address" },
|
|
1609
1606
|
{ name: "apUSDAmount", type: "uint256" },
|
|
1610
|
-
{ name: "
|
|
1607
|
+
{ name: "path", type: "bytes" },
|
|
1611
1608
|
{ name: "minOut", type: "uint256" },
|
|
1612
|
-
{ name: "deadline", type: "uint256" }
|
|
1613
|
-
{ name: "useV2", type: "bool" },
|
|
1614
|
-
{ name: "poolFee", type: "uint24" }
|
|
1609
|
+
{ name: "deadline", type: "uint256" }
|
|
1615
1610
|
],
|
|
1616
1611
|
outputs: [{ name: "outputAmount", type: "uint256" }],
|
|
1617
1612
|
stateMutability: "nonpayable"
|
|
@@ -1623,39 +1618,11 @@ var RouterABI = [
|
|
|
1623
1618
|
inputs: [
|
|
1624
1619
|
{ name: "lst", type: "address" },
|
|
1625
1620
|
{ name: "xBNBAmount", type: "uint256" },
|
|
1626
|
-
{ name: "
|
|
1621
|
+
{ name: "path", type: "bytes" },
|
|
1627
1622
|
{ name: "minOut", type: "uint256" },
|
|
1628
|
-
{ name: "deadline", type: "uint256" },
|
|
1629
|
-
{ name: "useV2", type: "bool" },
|
|
1630
|
-
{ name: "poolFee", type: "uint24" }
|
|
1631
|
-
],
|
|
1632
|
-
outputs: [{ name: "outputAmount", type: "uint256" }],
|
|
1633
|
-
stateMutability: "nonpayable"
|
|
1634
|
-
},
|
|
1635
|
-
// redeemApUSDAndUnstake
|
|
1636
|
-
{
|
|
1637
|
-
type: "function",
|
|
1638
|
-
name: "redeemApUSDAndUnstake",
|
|
1639
|
-
inputs: [
|
|
1640
|
-
{ name: "lst", type: "address" },
|
|
1641
|
-
{ name: "apUSDAmount", type: "uint256" },
|
|
1642
|
-
{ name: "minBNBOut", type: "uint256" },
|
|
1643
1623
|
{ name: "deadline", type: "uint256" }
|
|
1644
1624
|
],
|
|
1645
|
-
outputs: [{ name: "
|
|
1646
|
-
stateMutability: "nonpayable"
|
|
1647
|
-
},
|
|
1648
|
-
// redeemXBNBAndUnstake
|
|
1649
|
-
{
|
|
1650
|
-
type: "function",
|
|
1651
|
-
name: "redeemXBNBAndUnstake",
|
|
1652
|
-
inputs: [
|
|
1653
|
-
{ name: "lst", type: "address" },
|
|
1654
|
-
{ name: "xBNBAmount", type: "uint256" },
|
|
1655
|
-
{ name: "minBNBOut", type: "uint256" },
|
|
1656
|
-
{ name: "deadline", type: "uint256" }
|
|
1657
|
-
],
|
|
1658
|
-
outputs: [{ name: "bnbAmount", type: "uint256" }],
|
|
1625
|
+
outputs: [{ name: "outputAmount", type: "uint256" }],
|
|
1659
1626
|
stateMutability: "nonpayable"
|
|
1660
1627
|
},
|
|
1661
1628
|
// ============ Native Unstake Functions ============
|
|
@@ -1690,183 +1657,197 @@ var RouterABI = [
|
|
|
1690
1657
|
stateMutability: "nonpayable"
|
|
1691
1658
|
},
|
|
1692
1659
|
// ============ View Functions ============
|
|
1693
|
-
//
|
|
1694
|
-
{
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
},
|
|
1701
|
-
|
|
1660
|
+
// Token addresses
|
|
1661
|
+
{ type: "function", name: "wbnb", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1662
|
+
{ type: "function", name: "usdt", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1663
|
+
{ type: "function", name: "usdc", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1664
|
+
{ type: "function", name: "slisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1665
|
+
{ type: "function", name: "asBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1666
|
+
{ type: "function", name: "wclisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1667
|
+
{ type: "function", name: "apUSD", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1668
|
+
{ type: "function", name: "xBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1669
|
+
// Protocol addresses
|
|
1670
|
+
{ type: "function", name: "diamond", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1671
|
+
{ type: "function", name: "pancakeV3Router", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1672
|
+
{ type: "function", name: "listaStakeManager", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1673
|
+
{ type: "function", name: "astherusMinter", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1674
|
+
{ type: "function", name: "slisBNBProvider", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1675
|
+
// Configuration
|
|
1676
|
+
{ type: "function", name: "defaultLST", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1702
1677
|
{
|
|
1703
1678
|
type: "function",
|
|
1704
1679
|
name: "supportedInputTokens",
|
|
1705
1680
|
inputs: [{ name: "token", type: "address" }],
|
|
1706
|
-
outputs: [{
|
|
1681
|
+
outputs: [{ type: "bool" }],
|
|
1707
1682
|
stateMutability: "view"
|
|
1708
1683
|
},
|
|
1709
|
-
// supportedLSTs
|
|
1710
1684
|
{
|
|
1711
1685
|
type: "function",
|
|
1712
1686
|
name: "supportedLSTs",
|
|
1713
1687
|
inputs: [{ name: "lst", type: "address" }],
|
|
1714
|
-
outputs: [{
|
|
1688
|
+
outputs: [{ type: "bool" }],
|
|
1715
1689
|
stateMutability: "view"
|
|
1716
1690
|
},
|
|
1717
|
-
//
|
|
1691
|
+
// Preview functions
|
|
1718
1692
|
{
|
|
1719
1693
|
type: "function",
|
|
1720
|
-
name: "
|
|
1721
|
-
inputs: [
|
|
1722
|
-
|
|
1694
|
+
name: "previewMintApUSD",
|
|
1695
|
+
inputs: [
|
|
1696
|
+
{ name: "lst", type: "address" },
|
|
1697
|
+
{ name: "lstAmount", type: "uint256" }
|
|
1698
|
+
],
|
|
1699
|
+
outputs: [{ name: "apUSDAmount", type: "uint256" }],
|
|
1723
1700
|
stateMutability: "view"
|
|
1724
1701
|
},
|
|
1725
|
-
// getExpectedOutput
|
|
1726
1702
|
{
|
|
1727
1703
|
type: "function",
|
|
1728
|
-
name: "
|
|
1704
|
+
name: "previewMintXBNB",
|
|
1729
1705
|
inputs: [
|
|
1730
|
-
{ name: "
|
|
1731
|
-
{ name: "
|
|
1732
|
-
{ name: "targetLST", type: "address" },
|
|
1733
|
-
{ name: "mintXBNB", type: "bool" }
|
|
1734
|
-
],
|
|
1735
|
-
outputs: [
|
|
1736
|
-
{ name: "expectedLST", type: "uint256" },
|
|
1737
|
-
{ name: "expectedMint", type: "uint256" }
|
|
1706
|
+
{ name: "lst", type: "address" },
|
|
1707
|
+
{ name: "lstAmount", type: "uint256" }
|
|
1738
1708
|
],
|
|
1709
|
+
outputs: [{ name: "xBNBAmount", type: "uint256" }],
|
|
1739
1710
|
stateMutability: "view"
|
|
1740
1711
|
},
|
|
1741
|
-
// getUserWithdrawalIndices
|
|
1742
1712
|
{
|
|
1743
1713
|
type: "function",
|
|
1744
|
-
name: "
|
|
1745
|
-
inputs: [
|
|
1746
|
-
|
|
1714
|
+
name: "previewRedeemApUSD",
|
|
1715
|
+
inputs: [
|
|
1716
|
+
{ name: "lst", type: "address" },
|
|
1717
|
+
{ name: "apUSDAmount", type: "uint256" }
|
|
1718
|
+
],
|
|
1719
|
+
outputs: [{ name: "lstAmount", type: "uint256" }],
|
|
1747
1720
|
stateMutability: "view"
|
|
1748
1721
|
},
|
|
1749
|
-
// getWithdrawalStatus
|
|
1750
1722
|
{
|
|
1751
1723
|
type: "function",
|
|
1752
|
-
name: "
|
|
1753
|
-
inputs: [
|
|
1754
|
-
|
|
1755
|
-
{ name: "
|
|
1756
|
-
{ name: "bnbAmount", type: "uint256" }
|
|
1724
|
+
name: "previewRedeemXBNB",
|
|
1725
|
+
inputs: [
|
|
1726
|
+
{ name: "lst", type: "address" },
|
|
1727
|
+
{ name: "xBNBAmount", type: "uint256" }
|
|
1757
1728
|
],
|
|
1729
|
+
outputs: [{ name: "lstAmount", type: "uint256" }],
|
|
1758
1730
|
stateMutability: "view"
|
|
1759
1731
|
},
|
|
1760
|
-
//
|
|
1732
|
+
// Withdrawal tracking
|
|
1761
1733
|
{
|
|
1762
1734
|
type: "function",
|
|
1763
|
-
name: "
|
|
1764
|
-
inputs: [],
|
|
1765
|
-
outputs: [{
|
|
1735
|
+
name: "getUserWithdrawalIndices",
|
|
1736
|
+
inputs: [{ name: "user", type: "address" }],
|
|
1737
|
+
outputs: [{ type: "uint256[]" }],
|
|
1766
1738
|
stateMutability: "view"
|
|
1767
1739
|
},
|
|
1768
1740
|
{
|
|
1769
1741
|
type: "function",
|
|
1770
|
-
name: "
|
|
1771
|
-
inputs: [],
|
|
1772
|
-
outputs: [
|
|
1742
|
+
name: "getWithdrawalStatus",
|
|
1743
|
+
inputs: [{ name: "requestIndex", type: "uint256" }],
|
|
1744
|
+
outputs: [
|
|
1745
|
+
{ name: "isClaimable", type: "bool" },
|
|
1746
|
+
{ name: "bnbAmount", type: "uint256" }
|
|
1747
|
+
],
|
|
1773
1748
|
stateMutability: "view"
|
|
1774
1749
|
},
|
|
1775
1750
|
{
|
|
1776
1751
|
type: "function",
|
|
1777
|
-
name: "
|
|
1778
|
-
inputs: [],
|
|
1779
|
-
outputs: [
|
|
1752
|
+
name: "withdrawalRequests",
|
|
1753
|
+
inputs: [{ name: "index", type: "uint256" }],
|
|
1754
|
+
outputs: [
|
|
1755
|
+
{ name: "user", type: "address" },
|
|
1756
|
+
{ name: "listaIdx", type: "uint256" },
|
|
1757
|
+
{ name: "slisBNBAmount", type: "uint256" },
|
|
1758
|
+
{ name: "claimed", type: "bool" }
|
|
1759
|
+
],
|
|
1780
1760
|
stateMutability: "view"
|
|
1781
1761
|
},
|
|
1762
|
+
// ============ Admin Functions ============
|
|
1763
|
+
{ type: "function", name: "owner", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
|
|
1782
1764
|
{
|
|
1783
1765
|
type: "function",
|
|
1784
|
-
name: "
|
|
1785
|
-
inputs: [],
|
|
1786
|
-
outputs: [
|
|
1787
|
-
stateMutability: "
|
|
1766
|
+
name: "setDefaultLST",
|
|
1767
|
+
inputs: [{ name: "lst", type: "address" }],
|
|
1768
|
+
outputs: [],
|
|
1769
|
+
stateMutability: "nonpayable"
|
|
1788
1770
|
},
|
|
1789
1771
|
{
|
|
1790
1772
|
type: "function",
|
|
1791
|
-
name: "
|
|
1792
|
-
inputs: [],
|
|
1793
|
-
outputs: [
|
|
1794
|
-
stateMutability: "
|
|
1773
|
+
name: "addSupportedInputToken",
|
|
1774
|
+
inputs: [{ name: "token", type: "address" }],
|
|
1775
|
+
outputs: [],
|
|
1776
|
+
stateMutability: "nonpayable"
|
|
1795
1777
|
},
|
|
1796
1778
|
{
|
|
1797
1779
|
type: "function",
|
|
1798
|
-
name: "
|
|
1799
|
-
inputs: [],
|
|
1800
|
-
outputs: [
|
|
1801
|
-
stateMutability: "
|
|
1780
|
+
name: "addSupportedLST",
|
|
1781
|
+
inputs: [{ name: "lst", type: "address" }],
|
|
1782
|
+
outputs: [],
|
|
1783
|
+
stateMutability: "nonpayable"
|
|
1802
1784
|
},
|
|
1803
1785
|
{
|
|
1804
1786
|
type: "function",
|
|
1805
|
-
name: "
|
|
1806
|
-
inputs: [
|
|
1807
|
-
|
|
1808
|
-
|
|
1787
|
+
name: "rescueTokens",
|
|
1788
|
+
inputs: [
|
|
1789
|
+
{ name: "token", type: "address" },
|
|
1790
|
+
{ name: "amount", type: "uint256" }
|
|
1791
|
+
],
|
|
1792
|
+
outputs: [],
|
|
1793
|
+
stateMutability: "nonpayable"
|
|
1809
1794
|
},
|
|
1810
1795
|
{
|
|
1811
1796
|
type: "function",
|
|
1812
|
-
name: "
|
|
1813
|
-
inputs: [],
|
|
1814
|
-
outputs: [
|
|
1815
|
-
stateMutability: "
|
|
1797
|
+
name: "transferOwnership",
|
|
1798
|
+
inputs: [{ name: "newOwner", type: "address" }],
|
|
1799
|
+
outputs: [],
|
|
1800
|
+
stateMutability: "nonpayable"
|
|
1816
1801
|
},
|
|
1802
|
+
{ type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" },
|
|
1817
1803
|
// ============ Events ============
|
|
1818
|
-
// SwapAndMint
|
|
1819
1804
|
{
|
|
1820
1805
|
type: "event",
|
|
1821
1806
|
name: "SwapAndMint",
|
|
1822
1807
|
inputs: [
|
|
1823
1808
|
{ name: "user", type: "address", indexed: true },
|
|
1824
|
-
{ name: "inputToken", type: "address", indexed:
|
|
1809
|
+
{ name: "inputToken", type: "address", indexed: false },
|
|
1825
1810
|
{ name: "inputAmount", type: "uint256", indexed: false },
|
|
1826
|
-
{ name: "
|
|
1811
|
+
{ name: "lst", type: "address", indexed: false },
|
|
1827
1812
|
{ name: "lstAmount", type: "uint256", indexed: false },
|
|
1828
1813
|
{ name: "mintedToken", type: "address", indexed: false },
|
|
1829
1814
|
{ name: "mintedAmount", type: "uint256", indexed: false }
|
|
1830
1815
|
]
|
|
1831
1816
|
},
|
|
1832
|
-
// StakeAndMint
|
|
1833
1817
|
{
|
|
1834
1818
|
type: "event",
|
|
1835
1819
|
name: "StakeAndMint",
|
|
1836
1820
|
inputs: [
|
|
1837
1821
|
{ name: "user", type: "address", indexed: true },
|
|
1838
1822
|
{ name: "bnbAmount", type: "uint256", indexed: false },
|
|
1839
|
-
{ name: "
|
|
1823
|
+
{ name: "lst", type: "address", indexed: false },
|
|
1840
1824
|
{ name: "lstAmount", type: "uint256", indexed: false },
|
|
1841
|
-
{ name: "mintedToken", type: "address", indexed:
|
|
1825
|
+
{ name: "mintedToken", type: "address", indexed: false },
|
|
1842
1826
|
{ name: "mintedAmount", type: "uint256", indexed: false }
|
|
1843
1827
|
]
|
|
1844
1828
|
},
|
|
1845
|
-
// Mint
|
|
1846
1829
|
{
|
|
1847
1830
|
type: "event",
|
|
1848
1831
|
name: "Mint",
|
|
1849
1832
|
inputs: [
|
|
1850
1833
|
{ name: "user", type: "address", indexed: true },
|
|
1851
|
-
{ name: "lst", type: "address", indexed:
|
|
1834
|
+
{ name: "lst", type: "address", indexed: false },
|
|
1852
1835
|
{ name: "lstAmount", type: "uint256", indexed: false },
|
|
1853
|
-
{ name: "mintedToken", type: "address", indexed:
|
|
1836
|
+
{ name: "mintedToken", type: "address", indexed: false },
|
|
1854
1837
|
{ name: "mintedAmount", type: "uint256", indexed: false }
|
|
1855
1838
|
]
|
|
1856
1839
|
},
|
|
1857
|
-
// Redeem
|
|
1858
1840
|
{
|
|
1859
1841
|
type: "event",
|
|
1860
1842
|
name: "Redeem",
|
|
1861
1843
|
inputs: [
|
|
1862
1844
|
{ name: "user", type: "address", indexed: true },
|
|
1863
|
-
{ name: "redeemedToken", type: "address", indexed:
|
|
1845
|
+
{ name: "redeemedToken", type: "address", indexed: false },
|
|
1864
1846
|
{ name: "redeemedAmount", type: "uint256", indexed: false },
|
|
1865
|
-
{ name: "lst", type: "address", indexed:
|
|
1847
|
+
{ name: "lst", type: "address", indexed: false },
|
|
1866
1848
|
{ name: "lstAmount", type: "uint256", indexed: false }
|
|
1867
1849
|
]
|
|
1868
1850
|
},
|
|
1869
|
-
// RedeemAndSwap
|
|
1870
1851
|
{
|
|
1871
1852
|
type: "event",
|
|
1872
1853
|
name: "RedeemAndSwap",
|
|
@@ -1876,57 +1857,69 @@ var RouterABI = [
|
|
|
1876
1857
|
{ name: "redeemedAmount", type: "uint256", indexed: false },
|
|
1877
1858
|
{ name: "lst", type: "address", indexed: false },
|
|
1878
1859
|
{ name: "lstAmount", type: "uint256", indexed: false },
|
|
1879
|
-
{ name: "outputToken", type: "address", indexed:
|
|
1860
|
+
{ name: "outputToken", type: "address", indexed: false },
|
|
1880
1861
|
{ name: "outputAmount", type: "uint256", indexed: false }
|
|
1881
1862
|
]
|
|
1882
1863
|
},
|
|
1883
|
-
// UnstakeRequested
|
|
1884
1864
|
{
|
|
1885
1865
|
type: "event",
|
|
1886
1866
|
name: "UnstakeRequested",
|
|
1887
1867
|
inputs: [
|
|
1888
1868
|
{ name: "user", type: "address", indexed: true },
|
|
1889
|
-
{ name: "requestIndex", type: "uint256", indexed:
|
|
1869
|
+
{ name: "requestIndex", type: "uint256", indexed: false },
|
|
1890
1870
|
{ name: "redeemedToken", type: "address", indexed: false },
|
|
1891
1871
|
{ name: "redeemedAmount", type: "uint256", indexed: false },
|
|
1892
1872
|
{ name: "slisBNBAmount", type: "uint256", indexed: false }
|
|
1893
1873
|
]
|
|
1894
1874
|
},
|
|
1895
|
-
// UnstakeClaimed
|
|
1896
1875
|
{
|
|
1897
1876
|
type: "event",
|
|
1898
1877
|
name: "UnstakeClaimed",
|
|
1899
1878
|
inputs: [
|
|
1900
1879
|
{ name: "user", type: "address", indexed: true },
|
|
1901
|
-
{ name: "requestIndex", type: "uint256", indexed:
|
|
1880
|
+
{ name: "requestIndex", type: "uint256", indexed: false },
|
|
1902
1881
|
{ name: "bnbAmount", type: "uint256", indexed: false }
|
|
1903
1882
|
]
|
|
1904
1883
|
},
|
|
1905
|
-
// DefaultLSTUpdated
|
|
1906
1884
|
{
|
|
1907
1885
|
type: "event",
|
|
1908
1886
|
name: "DefaultLSTUpdated",
|
|
1909
1887
|
inputs: [
|
|
1910
|
-
{ name: "oldLST", type: "address", indexed:
|
|
1911
|
-
{ name: "newLST", type: "address", indexed:
|
|
1888
|
+
{ name: "oldLST", type: "address", indexed: false },
|
|
1889
|
+
{ name: "newLST", type: "address", indexed: false }
|
|
1890
|
+
]
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
type: "event",
|
|
1894
|
+
name: "OwnershipTransferred",
|
|
1895
|
+
inputs: [
|
|
1896
|
+
{ name: "previousOwner", type: "address", indexed: true },
|
|
1897
|
+
{ name: "newOwner", type: "address", indexed: true }
|
|
1912
1898
|
]
|
|
1913
1899
|
},
|
|
1914
1900
|
// ============ Errors ============
|
|
1915
|
-
{ type: "error", name: "UnsupportedInputToken", inputs: [] },
|
|
1916
|
-
{ type: "error", name: "UnsupportedLST", inputs: [] },
|
|
1917
1901
|
{ type: "error", name: "DeadlineExpired", inputs: [] },
|
|
1902
|
+
{ type: "error", name: "DefaultLSTNotSet", inputs: [] },
|
|
1918
1903
|
{ type: "error", name: "InsufficientOutput", inputs: [] },
|
|
1919
|
-
{ type: "error", name: "
|
|
1904
|
+
{ type: "error", name: "InvalidPoolFee", inputs: [] },
|
|
1920
1905
|
{ type: "error", name: "InvalidRecipient", inputs: [] },
|
|
1921
|
-
{ type: "error", name: "
|
|
1906
|
+
{ type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
|
|
1922
1907
|
{ type: "error", name: "MintFailed", inputs: [] },
|
|
1923
1908
|
{ type: "error", name: "NativeTransferFailed", inputs: [] },
|
|
1924
|
-
{ type: "error", name: "
|
|
1925
|
-
{ type: "error", name: "
|
|
1926
|
-
{ type: "error", name: "
|
|
1927
|
-
{ type: "error", name: "
|
|
1909
|
+
{ type: "error", name: "OnlySlisBNBSupported", inputs: [] },
|
|
1910
|
+
{ type: "error", name: "SwapFailed", inputs: [] },
|
|
1911
|
+
{ type: "error", name: "UnsupportedInputToken", inputs: [] },
|
|
1912
|
+
{ type: "error", name: "UnsupportedLST", inputs: [] },
|
|
1913
|
+
{ type: "error", name: "V3PoolNotFound", inputs: [] },
|
|
1928
1914
|
{ type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
|
|
1929
|
-
{ type: "error", name: "
|
|
1915
|
+
{ type: "error", name: "WithdrawalNotClaimable", inputs: [] },
|
|
1916
|
+
{ type: "error", name: "ZeroAmount", inputs: [] },
|
|
1917
|
+
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
|
|
1918
|
+
{ type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address" }] },
|
|
1919
|
+
{ type: "error", name: "OwnableUnauthorizedAccount", inputs: [{ name: "account", type: "address" }] },
|
|
1920
|
+
{ type: "error", name: "SafeERC20FailedOperation", inputs: [{ name: "token", type: "address" }] },
|
|
1921
|
+
// Receive
|
|
1922
|
+
{ type: "receive", stateMutability: "payable" }
|
|
1930
1923
|
];
|
|
1931
1924
|
|
|
1932
1925
|
// src/router.ts
|
|
@@ -1986,19 +1979,48 @@ var AspanRouterReadClient = class {
|
|
|
1986
1979
|
});
|
|
1987
1980
|
}
|
|
1988
1981
|
/**
|
|
1989
|
-
*
|
|
1982
|
+
* Preview apUSD mint output for a given LST amount
|
|
1990
1983
|
*/
|
|
1991
|
-
async
|
|
1992
|
-
|
|
1984
|
+
async previewMintApUSD(lst, lstAmount) {
|
|
1985
|
+
return this.publicClient.readContract({
|
|
1993
1986
|
address: this.routerAddress,
|
|
1994
1987
|
abi: RouterABI,
|
|
1995
|
-
functionName: "
|
|
1996
|
-
args: [
|
|
1988
|
+
functionName: "previewMintApUSD",
|
|
1989
|
+
args: [lst, lstAmount]
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Preview xBNB mint output for a given LST amount
|
|
1994
|
+
*/
|
|
1995
|
+
async previewMintXBNB(lst, lstAmount) {
|
|
1996
|
+
return this.publicClient.readContract({
|
|
1997
|
+
address: this.routerAddress,
|
|
1998
|
+
abi: RouterABI,
|
|
1999
|
+
functionName: "previewMintXBNB",
|
|
2000
|
+
args: [lst, lstAmount]
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Preview LST output for redeeming apUSD
|
|
2005
|
+
*/
|
|
2006
|
+
async previewRedeemApUSD(lst, apUSDAmount) {
|
|
2007
|
+
return this.publicClient.readContract({
|
|
2008
|
+
address: this.routerAddress,
|
|
2009
|
+
abi: RouterABI,
|
|
2010
|
+
functionName: "previewRedeemApUSD",
|
|
2011
|
+
args: [lst, apUSDAmount]
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Preview LST output for redeeming xBNB
|
|
2016
|
+
*/
|
|
2017
|
+
async previewRedeemXBNB(lst, xBNBAmount) {
|
|
2018
|
+
return this.publicClient.readContract({
|
|
2019
|
+
address: this.routerAddress,
|
|
2020
|
+
abi: RouterABI,
|
|
2021
|
+
functionName: "previewRedeemXBNB",
|
|
2022
|
+
args: [lst, xBNBAmount]
|
|
1997
2023
|
});
|
|
1998
|
-
return {
|
|
1999
|
-
expectedLST: result[0],
|
|
2000
|
-
expectedMint: result[1]
|
|
2001
|
-
};
|
|
2002
2024
|
}
|
|
2003
2025
|
/**
|
|
2004
2026
|
* Get user's withdrawal request indices
|
|
@@ -2119,11 +2141,9 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2119
2141
|
inputAmount: params.swapParams.inputAmount,
|
|
2120
2142
|
targetLST: params.swapParams.targetLST,
|
|
2121
2143
|
minLSTOut: params.swapParams.minLSTOut,
|
|
2122
|
-
poolFee: params.swapParams.poolFee
|
|
2123
|
-
useV2: params.swapParams.useV2
|
|
2144
|
+
poolFee: params.swapParams.poolFee
|
|
2124
2145
|
},
|
|
2125
2146
|
{
|
|
2126
|
-
mintXBNB: params.mintParams.mintXBNB,
|
|
2127
2147
|
minMintOut: params.mintParams.minMintOut,
|
|
2128
2148
|
recipient: params.mintParams.recipient,
|
|
2129
2149
|
deadline: params.mintParams.deadline
|
|
@@ -2149,11 +2169,9 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2149
2169
|
inputAmount: params.swapParams.inputAmount,
|
|
2150
2170
|
targetLST: params.swapParams.targetLST,
|
|
2151
2171
|
minLSTOut: params.swapParams.minLSTOut,
|
|
2152
|
-
poolFee: params.swapParams.poolFee
|
|
2153
|
-
useV2: params.swapParams.useV2
|
|
2172
|
+
poolFee: params.swapParams.poolFee
|
|
2154
2173
|
},
|
|
2155
2174
|
{
|
|
2156
|
-
mintXBNB: params.mintParams.mintXBNB,
|
|
2157
2175
|
minMintOut: params.mintParams.minMintOut,
|
|
2158
2176
|
recipient: params.mintParams.recipient,
|
|
2159
2177
|
deadline: params.mintParams.deadline
|
|
@@ -2174,7 +2192,7 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2174
2192
|
functionName: "stakeAndMint",
|
|
2175
2193
|
args: [
|
|
2176
2194
|
params.targetLST,
|
|
2177
|
-
params.
|
|
2195
|
+
params.isXBNB,
|
|
2178
2196
|
params.minMintOut,
|
|
2179
2197
|
params.deadline
|
|
2180
2198
|
],
|
|
@@ -2305,7 +2323,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2305
2323
|
}
|
|
2306
2324
|
// ============ Redeem and Swap Functions ============
|
|
2307
2325
|
/**
|
|
2308
|
-
* Redeem apUSD and swap LST to output token
|
|
2326
|
+
* Redeem apUSD and swap LST to output token via V3 path
|
|
2327
|
+
* @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
|
|
2309
2328
|
*/
|
|
2310
2329
|
async redeemApUSDAndSwap(params) {
|
|
2311
2330
|
return this.walletClient.writeContract({
|
|
@@ -2317,16 +2336,15 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2317
2336
|
args: [
|
|
2318
2337
|
params.lst,
|
|
2319
2338
|
params.amount,
|
|
2320
|
-
params.
|
|
2339
|
+
params.path,
|
|
2321
2340
|
params.minOut,
|
|
2322
|
-
params.deadline
|
|
2323
|
-
params.useV2,
|
|
2324
|
-
params.poolFee
|
|
2341
|
+
params.deadline
|
|
2325
2342
|
]
|
|
2326
2343
|
});
|
|
2327
2344
|
}
|
|
2328
2345
|
/**
|
|
2329
|
-
* Redeem xBNB and swap LST to output token
|
|
2346
|
+
* Redeem xBNB and swap LST to output token via V3 path
|
|
2347
|
+
* @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
|
|
2330
2348
|
*/
|
|
2331
2349
|
async redeemXBNBAndSwap(params) {
|
|
2332
2350
|
return this.walletClient.writeContract({
|
|
@@ -2338,40 +2356,12 @@ var AspanRouterClient = class extends AspanRouterReadClient {
|
|
|
2338
2356
|
args: [
|
|
2339
2357
|
params.lst,
|
|
2340
2358
|
params.amount,
|
|
2341
|
-
params.
|
|
2359
|
+
params.path,
|
|
2342
2360
|
params.minOut,
|
|
2343
|
-
params.deadline
|
|
2344
|
-
params.useV2,
|
|
2345
|
-
params.poolFee
|
|
2361
|
+
params.deadline
|
|
2346
2362
|
]
|
|
2347
2363
|
});
|
|
2348
2364
|
}
|
|
2349
|
-
/**
|
|
2350
|
-
* Redeem apUSD and instantly unstake LST to native BNB via DEX
|
|
2351
|
-
*/
|
|
2352
|
-
async redeemApUSDAndUnstake(params) {
|
|
2353
|
-
return this.walletClient.writeContract({
|
|
2354
|
-
chain: this.chain,
|
|
2355
|
-
account: this.walletClient.account,
|
|
2356
|
-
address: this.routerAddress,
|
|
2357
|
-
abi: RouterABI,
|
|
2358
|
-
functionName: "redeemApUSDAndUnstake",
|
|
2359
|
-
args: [params.lst, params.amount, params.minBNBOut, params.deadline]
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
/**
|
|
2363
|
-
* Redeem xBNB and instantly unstake LST to native BNB via DEX
|
|
2364
|
-
*/
|
|
2365
|
-
async redeemXBNBAndUnstake(params) {
|
|
2366
|
-
return this.walletClient.writeContract({
|
|
2367
|
-
chain: this.chain,
|
|
2368
|
-
account: this.walletClient.account,
|
|
2369
|
-
address: this.routerAddress,
|
|
2370
|
-
abi: RouterABI,
|
|
2371
|
-
functionName: "redeemXBNBAndUnstake",
|
|
2372
|
-
args: [params.lst, params.amount, params.minBNBOut, params.deadline]
|
|
2373
|
-
});
|
|
2374
|
-
}
|
|
2375
2365
|
// ============ Native Unstake Functions ============
|
|
2376
2366
|
/**
|
|
2377
2367
|
* Redeem apUSD and request native unstake from Lista (starts unbonding period)
|
|
@@ -2451,6 +2441,19 @@ function createRouterTestnetClient(routerAddress, account, rpcUrl) {
|
|
|
2451
2441
|
});
|
|
2452
2442
|
}
|
|
2453
2443
|
|
|
2444
|
+
// src/types.ts
|
|
2445
|
+
function encodeV3Path(tokens, fees) {
|
|
2446
|
+
if (tokens.length < 2) throw new Error("Path must have at least 2 tokens");
|
|
2447
|
+
if (fees.length !== tokens.length - 1) throw new Error("Fees length must be tokens.length - 1");
|
|
2448
|
+
let path = tokens[0].toLowerCase().slice(2);
|
|
2449
|
+
for (let i = 0; i < fees.length; i++) {
|
|
2450
|
+
const feeHex = fees[i].toString(16).padStart(6, "0");
|
|
2451
|
+
path += feeHex;
|
|
2452
|
+
path += tokens[i + 1].toLowerCase().slice(2);
|
|
2453
|
+
}
|
|
2454
|
+
return `0x${path}`;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2454
2457
|
// src/index.ts
|
|
2455
2458
|
var PRECISION = 10n ** 18n;
|
|
2456
2459
|
var BPS_PRECISION = 10000n;
|
|
@@ -2505,6 +2508,7 @@ export {
|
|
|
2505
2508
|
createRouterReadClient,
|
|
2506
2509
|
createRouterTestnetClient,
|
|
2507
2510
|
createRouterTestnetReadClient,
|
|
2511
|
+
encodeV3Path,
|
|
2508
2512
|
formatAmount,
|
|
2509
2513
|
formatCR,
|
|
2510
2514
|
formatFeeBPS,
|