@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/dist/index.js CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  createRouterReadClient: () => createRouterReadClient,
39
39
  createRouterTestnetClient: () => createRouterTestnetClient,
40
40
  createRouterTestnetReadClient: () => createRouterTestnetReadClient,
41
+ encodeV3Path: () => encodeV3Path,
41
42
  formatAmount: () => formatAmount,
42
43
  formatCR: () => formatCR,
43
44
  formatFeeBPS: () => formatFeeBPS,
@@ -1461,7 +1462,7 @@ var import_chains2 = require("viem/chains");
1461
1462
 
1462
1463
  // src/abi/router.ts
1463
1464
  var RouterABI = [
1464
- // ============ Core Functions ============
1465
+ // ============ Core Swap+Mint Functions ============
1465
1466
  // swapAndMintApUSD
1466
1467
  {
1467
1468
  type: "function",
@@ -1475,15 +1476,13 @@ var RouterABI = [
1475
1476
  { name: "inputAmount", type: "uint256" },
1476
1477
  { name: "targetLST", type: "address" },
1477
1478
  { name: "minLSTOut", type: "uint256" },
1478
- { name: "poolFee", type: "uint24" },
1479
- { name: "useV2", type: "bool" }
1479
+ { name: "poolFee", type: "uint24" }
1480
1480
  ]
1481
1481
  },
1482
1482
  {
1483
1483
  name: "mintParams",
1484
1484
  type: "tuple",
1485
1485
  components: [
1486
- { name: "mintXBNB", type: "bool" },
1487
1486
  { name: "minMintOut", type: "uint256" },
1488
1487
  { name: "recipient", type: "address" },
1489
1488
  { name: "deadline", type: "uint256" }
@@ -1509,15 +1508,13 @@ var RouterABI = [
1509
1508
  { name: "inputAmount", type: "uint256" },
1510
1509
  { name: "targetLST", type: "address" },
1511
1510
  { name: "minLSTOut", type: "uint256" },
1512
- { name: "poolFee", type: "uint24" },
1513
- { name: "useV2", type: "bool" }
1511
+ { name: "poolFee", type: "uint24" }
1514
1512
  ]
1515
1513
  },
1516
1514
  {
1517
1515
  name: "mintParams",
1518
1516
  type: "tuple",
1519
1517
  components: [
1520
- { name: "mintXBNB", type: "bool" },
1521
1518
  { name: "minMintOut", type: "uint256" },
1522
1519
  { name: "recipient", type: "address" },
1523
1520
  { name: "deadline", type: "uint256" }
@@ -1530,13 +1527,14 @@ var RouterABI = [
1530
1527
  ],
1531
1528
  stateMutability: "payable"
1532
1529
  },
1530
+ // ============ Stake+Mint Functions ============
1533
1531
  // stakeAndMint
1534
1532
  {
1535
1533
  type: "function",
1536
1534
  name: "stakeAndMint",
1537
1535
  inputs: [
1538
1536
  { name: "targetLST", type: "address" },
1539
- { name: "mintXBNB", type: "bool" },
1537
+ { name: "isXBNB", type: "bool" },
1540
1538
  { name: "minMintOut", type: "uint256" },
1541
1539
  { name: "deadline", type: "uint256" }
1542
1540
  ],
@@ -1546,7 +1544,23 @@ var RouterABI = [
1546
1544
  ],
1547
1545
  stateMutability: "payable"
1548
1546
  },
1549
- // ============ Simplified Functions ============
1547
+ // stakeAndMintApUSD (simplified)
1548
+ {
1549
+ type: "function",
1550
+ name: "stakeAndMintApUSD",
1551
+ inputs: [{ name: "minMintOut", type: "uint256" }],
1552
+ outputs: [{ name: "apUSDAmount", type: "uint256" }],
1553
+ stateMutability: "payable"
1554
+ },
1555
+ // stakeAndMintXBNB (simplified)
1556
+ {
1557
+ type: "function",
1558
+ name: "stakeAndMintXBNB",
1559
+ inputs: [{ name: "minMintOut", type: "uint256" }],
1560
+ outputs: [{ name: "xBNBAmount", type: "uint256" }],
1561
+ stateMutability: "payable"
1562
+ },
1563
+ // ============ Simplified Swap+Mint Functions ============
1550
1564
  // swapAndMintApUSDDefault
1551
1565
  {
1552
1566
  type: "function",
@@ -1573,22 +1587,6 @@ var RouterABI = [
1573
1587
  outputs: [{ name: "xBNBAmount", type: "uint256" }],
1574
1588
  stateMutability: "payable"
1575
1589
  },
1576
- // stakeAndMintApUSD
1577
- {
1578
- type: "function",
1579
- name: "stakeAndMintApUSD",
1580
- inputs: [{ name: "minMintOut", type: "uint256" }],
1581
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
1582
- stateMutability: "payable"
1583
- },
1584
- // stakeAndMintXBNB
1585
- {
1586
- type: "function",
1587
- name: "stakeAndMintXBNB",
1588
- inputs: [{ name: "minMintOut", type: "uint256" }],
1589
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
1590
- stateMutability: "payable"
1591
- },
1592
1590
  // ============ Direct Mint/Redeem Functions ============
1593
1591
  // mintApUSD
1594
1592
  {
@@ -1638,7 +1636,7 @@ var RouterABI = [
1638
1636
  outputs: [{ name: "lstAmount", type: "uint256" }],
1639
1637
  stateMutability: "nonpayable"
1640
1638
  },
1641
- // ============ Redeem and Swap Functions ============
1639
+ // ============ Redeem + Swap Functions (V3 path) ============
1642
1640
  // redeemApUSDAndSwap
1643
1641
  {
1644
1642
  type: "function",
@@ -1646,11 +1644,9 @@ var RouterABI = [
1646
1644
  inputs: [
1647
1645
  { name: "lst", type: "address" },
1648
1646
  { name: "apUSDAmount", type: "uint256" },
1649
- { name: "outputToken", type: "address" },
1647
+ { name: "path", type: "bytes" },
1650
1648
  { name: "minOut", type: "uint256" },
1651
- { name: "deadline", type: "uint256" },
1652
- { name: "useV2", type: "bool" },
1653
- { name: "poolFee", type: "uint24" }
1649
+ { name: "deadline", type: "uint256" }
1654
1650
  ],
1655
1651
  outputs: [{ name: "outputAmount", type: "uint256" }],
1656
1652
  stateMutability: "nonpayable"
@@ -1662,39 +1658,11 @@ var RouterABI = [
1662
1658
  inputs: [
1663
1659
  { name: "lst", type: "address" },
1664
1660
  { name: "xBNBAmount", type: "uint256" },
1665
- { name: "outputToken", type: "address" },
1661
+ { name: "path", type: "bytes" },
1666
1662
  { name: "minOut", type: "uint256" },
1667
- { name: "deadline", type: "uint256" },
1668
- { name: "useV2", type: "bool" },
1669
- { name: "poolFee", type: "uint24" }
1670
- ],
1671
- outputs: [{ name: "outputAmount", type: "uint256" }],
1672
- stateMutability: "nonpayable"
1673
- },
1674
- // redeemApUSDAndUnstake
1675
- {
1676
- type: "function",
1677
- name: "redeemApUSDAndUnstake",
1678
- inputs: [
1679
- { name: "lst", type: "address" },
1680
- { name: "apUSDAmount", type: "uint256" },
1681
- { name: "minBNBOut", type: "uint256" },
1682
1663
  { name: "deadline", type: "uint256" }
1683
1664
  ],
1684
- outputs: [{ name: "bnbAmount", type: "uint256" }],
1685
- stateMutability: "nonpayable"
1686
- },
1687
- // redeemXBNBAndUnstake
1688
- {
1689
- type: "function",
1690
- name: "redeemXBNBAndUnstake",
1691
- inputs: [
1692
- { name: "lst", type: "address" },
1693
- { name: "xBNBAmount", type: "uint256" },
1694
- { name: "minBNBOut", type: "uint256" },
1695
- { name: "deadline", type: "uint256" }
1696
- ],
1697
- outputs: [{ name: "bnbAmount", type: "uint256" }],
1665
+ outputs: [{ name: "outputAmount", type: "uint256" }],
1698
1666
  stateMutability: "nonpayable"
1699
1667
  },
1700
1668
  // ============ Native Unstake Functions ============
@@ -1729,183 +1697,197 @@ var RouterABI = [
1729
1697
  stateMutability: "nonpayable"
1730
1698
  },
1731
1699
  // ============ View Functions ============
1732
- // defaultLST
1733
- {
1734
- type: "function",
1735
- name: "defaultLST",
1736
- inputs: [],
1737
- outputs: [{ name: "", type: "address" }],
1738
- stateMutability: "view"
1739
- },
1740
- // supportedInputTokens
1700
+ // Token addresses
1701
+ { type: "function", name: "wbnb", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1702
+ { type: "function", name: "usdt", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1703
+ { type: "function", name: "usdc", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1704
+ { type: "function", name: "slisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1705
+ { type: "function", name: "asBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1706
+ { type: "function", name: "wclisBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1707
+ { type: "function", name: "apUSD", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1708
+ { type: "function", name: "xBNB", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1709
+ // Protocol addresses
1710
+ { type: "function", name: "diamond", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1711
+ { type: "function", name: "pancakeV3Router", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1712
+ { type: "function", name: "listaStakeManager", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1713
+ { type: "function", name: "astherusMinter", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1714
+ { type: "function", name: "slisBNBProvider", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1715
+ // Configuration
1716
+ { type: "function", name: "defaultLST", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1741
1717
  {
1742
1718
  type: "function",
1743
1719
  name: "supportedInputTokens",
1744
1720
  inputs: [{ name: "token", type: "address" }],
1745
- outputs: [{ name: "", type: "bool" }],
1721
+ outputs: [{ type: "bool" }],
1746
1722
  stateMutability: "view"
1747
1723
  },
1748
- // supportedLSTs
1749
1724
  {
1750
1725
  type: "function",
1751
1726
  name: "supportedLSTs",
1752
1727
  inputs: [{ name: "lst", type: "address" }],
1753
- outputs: [{ name: "", type: "bool" }],
1728
+ outputs: [{ type: "bool" }],
1754
1729
  stateMutability: "view"
1755
1730
  },
1756
- // diamond
1731
+ // Preview functions
1757
1732
  {
1758
1733
  type: "function",
1759
- name: "diamond",
1760
- inputs: [],
1761
- outputs: [{ name: "", type: "address" }],
1734
+ name: "previewMintApUSD",
1735
+ inputs: [
1736
+ { name: "lst", type: "address" },
1737
+ { name: "lstAmount", type: "uint256" }
1738
+ ],
1739
+ outputs: [{ name: "apUSDAmount", type: "uint256" }],
1762
1740
  stateMutability: "view"
1763
1741
  },
1764
- // getExpectedOutput
1765
1742
  {
1766
1743
  type: "function",
1767
- name: "getExpectedOutput",
1744
+ name: "previewMintXBNB",
1768
1745
  inputs: [
1769
- { name: "inputToken", type: "address" },
1770
- { name: "inputAmount", type: "uint256" },
1771
- { name: "targetLST", type: "address" },
1772
- { name: "mintXBNB", type: "bool" }
1773
- ],
1774
- outputs: [
1775
- { name: "expectedLST", type: "uint256" },
1776
- { name: "expectedMint", type: "uint256" }
1746
+ { name: "lst", type: "address" },
1747
+ { name: "lstAmount", type: "uint256" }
1777
1748
  ],
1749
+ outputs: [{ name: "xBNBAmount", type: "uint256" }],
1778
1750
  stateMutability: "view"
1779
1751
  },
1780
- // getUserWithdrawalIndices
1781
1752
  {
1782
1753
  type: "function",
1783
- name: "getUserWithdrawalIndices",
1784
- inputs: [{ name: "user", type: "address" }],
1785
- outputs: [{ name: "", type: "uint256[]" }],
1754
+ name: "previewRedeemApUSD",
1755
+ inputs: [
1756
+ { name: "lst", type: "address" },
1757
+ { name: "apUSDAmount", type: "uint256" }
1758
+ ],
1759
+ outputs: [{ name: "lstAmount", type: "uint256" }],
1786
1760
  stateMutability: "view"
1787
1761
  },
1788
- // getWithdrawalStatus
1789
1762
  {
1790
1763
  type: "function",
1791
- name: "getWithdrawalStatus",
1792
- inputs: [{ name: "requestIndex", type: "uint256" }],
1793
- outputs: [
1794
- { name: "isClaimable", type: "bool" },
1795
- { name: "bnbAmount", type: "uint256" }
1764
+ name: "previewRedeemXBNB",
1765
+ inputs: [
1766
+ { name: "lst", type: "address" },
1767
+ { name: "xBNBAmount", type: "uint256" }
1796
1768
  ],
1769
+ outputs: [{ name: "lstAmount", type: "uint256" }],
1797
1770
  stateMutability: "view"
1798
1771
  },
1799
- // Immutable addresses
1772
+ // Withdrawal tracking
1800
1773
  {
1801
1774
  type: "function",
1802
- name: "wbnb",
1803
- inputs: [],
1804
- outputs: [{ name: "", type: "address" }],
1775
+ name: "getUserWithdrawalIndices",
1776
+ inputs: [{ name: "user", type: "address" }],
1777
+ outputs: [{ type: "uint256[]" }],
1805
1778
  stateMutability: "view"
1806
1779
  },
1807
1780
  {
1808
1781
  type: "function",
1809
- name: "usdt",
1810
- inputs: [],
1811
- outputs: [{ name: "", type: "address" }],
1782
+ name: "getWithdrawalStatus",
1783
+ inputs: [{ name: "requestIndex", type: "uint256" }],
1784
+ outputs: [
1785
+ { name: "isClaimable", type: "bool" },
1786
+ { name: "bnbAmount", type: "uint256" }
1787
+ ],
1812
1788
  stateMutability: "view"
1813
1789
  },
1814
1790
  {
1815
1791
  type: "function",
1816
- name: "usdc",
1817
- inputs: [],
1818
- outputs: [{ name: "", type: "address" }],
1792
+ name: "withdrawalRequests",
1793
+ inputs: [{ name: "index", type: "uint256" }],
1794
+ outputs: [
1795
+ { name: "user", type: "address" },
1796
+ { name: "listaIdx", type: "uint256" },
1797
+ { name: "slisBNBAmount", type: "uint256" },
1798
+ { name: "claimed", type: "bool" }
1799
+ ],
1819
1800
  stateMutability: "view"
1820
1801
  },
1802
+ // ============ Admin Functions ============
1803
+ { type: "function", name: "owner", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" },
1821
1804
  {
1822
1805
  type: "function",
1823
- name: "slisBNB",
1824
- inputs: [],
1825
- outputs: [{ name: "", type: "address" }],
1826
- stateMutability: "view"
1806
+ name: "setDefaultLST",
1807
+ inputs: [{ name: "lst", type: "address" }],
1808
+ outputs: [],
1809
+ stateMutability: "nonpayable"
1827
1810
  },
1828
1811
  {
1829
1812
  type: "function",
1830
- name: "asBNB",
1831
- inputs: [],
1832
- outputs: [{ name: "", type: "address" }],
1833
- stateMutability: "view"
1813
+ name: "addSupportedInputToken",
1814
+ inputs: [{ name: "token", type: "address" }],
1815
+ outputs: [],
1816
+ stateMutability: "nonpayable"
1834
1817
  },
1835
1818
  {
1836
1819
  type: "function",
1837
- name: "wclisBNB",
1838
- inputs: [],
1839
- outputs: [{ name: "", type: "address" }],
1840
- stateMutability: "view"
1820
+ name: "addSupportedLST",
1821
+ inputs: [{ name: "lst", type: "address" }],
1822
+ outputs: [],
1823
+ stateMutability: "nonpayable"
1841
1824
  },
1842
1825
  {
1843
1826
  type: "function",
1844
- name: "apUSD",
1845
- inputs: [],
1846
- outputs: [{ name: "", type: "address" }],
1847
- stateMutability: "view"
1827
+ name: "rescueTokens",
1828
+ inputs: [
1829
+ { name: "token", type: "address" },
1830
+ { name: "amount", type: "uint256" }
1831
+ ],
1832
+ outputs: [],
1833
+ stateMutability: "nonpayable"
1848
1834
  },
1849
1835
  {
1850
1836
  type: "function",
1851
- name: "xBNB",
1852
- inputs: [],
1853
- outputs: [{ name: "", type: "address" }],
1854
- stateMutability: "view"
1837
+ name: "transferOwnership",
1838
+ inputs: [{ name: "newOwner", type: "address" }],
1839
+ outputs: [],
1840
+ stateMutability: "nonpayable"
1855
1841
  },
1842
+ { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" },
1856
1843
  // ============ Events ============
1857
- // SwapAndMint
1858
1844
  {
1859
1845
  type: "event",
1860
1846
  name: "SwapAndMint",
1861
1847
  inputs: [
1862
1848
  { name: "user", type: "address", indexed: true },
1863
- { name: "inputToken", type: "address", indexed: true },
1849
+ { name: "inputToken", type: "address", indexed: false },
1864
1850
  { name: "inputAmount", type: "uint256", indexed: false },
1865
- { name: "targetLST", type: "address", indexed: true },
1851
+ { name: "lst", type: "address", indexed: false },
1866
1852
  { name: "lstAmount", type: "uint256", indexed: false },
1867
1853
  { name: "mintedToken", type: "address", indexed: false },
1868
1854
  { name: "mintedAmount", type: "uint256", indexed: false }
1869
1855
  ]
1870
1856
  },
1871
- // StakeAndMint
1872
1857
  {
1873
1858
  type: "event",
1874
1859
  name: "StakeAndMint",
1875
1860
  inputs: [
1876
1861
  { name: "user", type: "address", indexed: true },
1877
1862
  { name: "bnbAmount", type: "uint256", indexed: false },
1878
- { name: "targetLST", type: "address", indexed: true },
1863
+ { name: "lst", type: "address", indexed: false },
1879
1864
  { name: "lstAmount", type: "uint256", indexed: false },
1880
- { name: "mintedToken", type: "address", indexed: true },
1865
+ { name: "mintedToken", type: "address", indexed: false },
1881
1866
  { name: "mintedAmount", type: "uint256", indexed: false }
1882
1867
  ]
1883
1868
  },
1884
- // Mint
1885
1869
  {
1886
1870
  type: "event",
1887
1871
  name: "Mint",
1888
1872
  inputs: [
1889
1873
  { name: "user", type: "address", indexed: true },
1890
- { name: "lst", type: "address", indexed: true },
1874
+ { name: "lst", type: "address", indexed: false },
1891
1875
  { name: "lstAmount", type: "uint256", indexed: false },
1892
- { name: "mintedToken", type: "address", indexed: true },
1876
+ { name: "mintedToken", type: "address", indexed: false },
1893
1877
  { name: "mintedAmount", type: "uint256", indexed: false }
1894
1878
  ]
1895
1879
  },
1896
- // Redeem
1897
1880
  {
1898
1881
  type: "event",
1899
1882
  name: "Redeem",
1900
1883
  inputs: [
1901
1884
  { name: "user", type: "address", indexed: true },
1902
- { name: "redeemedToken", type: "address", indexed: true },
1885
+ { name: "redeemedToken", type: "address", indexed: false },
1903
1886
  { name: "redeemedAmount", type: "uint256", indexed: false },
1904
- { name: "lst", type: "address", indexed: true },
1887
+ { name: "lst", type: "address", indexed: false },
1905
1888
  { name: "lstAmount", type: "uint256", indexed: false }
1906
1889
  ]
1907
1890
  },
1908
- // RedeemAndSwap
1909
1891
  {
1910
1892
  type: "event",
1911
1893
  name: "RedeemAndSwap",
@@ -1915,57 +1897,69 @@ var RouterABI = [
1915
1897
  { name: "redeemedAmount", type: "uint256", indexed: false },
1916
1898
  { name: "lst", type: "address", indexed: false },
1917
1899
  { name: "lstAmount", type: "uint256", indexed: false },
1918
- { name: "outputToken", type: "address", indexed: true },
1900
+ { name: "outputToken", type: "address", indexed: false },
1919
1901
  { name: "outputAmount", type: "uint256", indexed: false }
1920
1902
  ]
1921
1903
  },
1922
- // UnstakeRequested
1923
1904
  {
1924
1905
  type: "event",
1925
1906
  name: "UnstakeRequested",
1926
1907
  inputs: [
1927
1908
  { name: "user", type: "address", indexed: true },
1928
- { name: "requestIndex", type: "uint256", indexed: true },
1909
+ { name: "requestIndex", type: "uint256", indexed: false },
1929
1910
  { name: "redeemedToken", type: "address", indexed: false },
1930
1911
  { name: "redeemedAmount", type: "uint256", indexed: false },
1931
1912
  { name: "slisBNBAmount", type: "uint256", indexed: false }
1932
1913
  ]
1933
1914
  },
1934
- // UnstakeClaimed
1935
1915
  {
1936
1916
  type: "event",
1937
1917
  name: "UnstakeClaimed",
1938
1918
  inputs: [
1939
1919
  { name: "user", type: "address", indexed: true },
1940
- { name: "requestIndex", type: "uint256", indexed: true },
1920
+ { name: "requestIndex", type: "uint256", indexed: false },
1941
1921
  { name: "bnbAmount", type: "uint256", indexed: false }
1942
1922
  ]
1943
1923
  },
1944
- // DefaultLSTUpdated
1945
1924
  {
1946
1925
  type: "event",
1947
1926
  name: "DefaultLSTUpdated",
1948
1927
  inputs: [
1949
- { name: "oldLST", type: "address", indexed: true },
1950
- { name: "newLST", type: "address", indexed: true }
1928
+ { name: "oldLST", type: "address", indexed: false },
1929
+ { name: "newLST", type: "address", indexed: false }
1930
+ ]
1931
+ },
1932
+ {
1933
+ type: "event",
1934
+ name: "OwnershipTransferred",
1935
+ inputs: [
1936
+ { name: "previousOwner", type: "address", indexed: true },
1937
+ { name: "newOwner", type: "address", indexed: true }
1951
1938
  ]
1952
1939
  },
1953
1940
  // ============ Errors ============
1954
- { type: "error", name: "UnsupportedInputToken", inputs: [] },
1955
- { type: "error", name: "UnsupportedLST", inputs: [] },
1956
1941
  { type: "error", name: "DeadlineExpired", inputs: [] },
1942
+ { type: "error", name: "DefaultLSTNotSet", inputs: [] },
1957
1943
  { type: "error", name: "InsufficientOutput", inputs: [] },
1958
- { type: "error", name: "ZeroAmount", inputs: [] },
1944
+ { type: "error", name: "InvalidPoolFee", inputs: [] },
1959
1945
  { type: "error", name: "InvalidRecipient", inputs: [] },
1960
- { type: "error", name: "SwapFailed", inputs: [] },
1946
+ { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
1961
1947
  { type: "error", name: "MintFailed", inputs: [] },
1962
1948
  { type: "error", name: "NativeTransferFailed", inputs: [] },
1963
- { type: "error", name: "InvalidPoolFee", inputs: [] },
1964
- { type: "error", name: "DefaultLSTNotSet", inputs: [] },
1965
- { type: "error", name: "InvalidWithdrawalRequest", inputs: [] },
1966
- { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
1949
+ { type: "error", name: "OnlySlisBNBSupported", inputs: [] },
1950
+ { type: "error", name: "SwapFailed", inputs: [] },
1951
+ { type: "error", name: "UnsupportedInputToken", inputs: [] },
1952
+ { type: "error", name: "UnsupportedLST", inputs: [] },
1953
+ { type: "error", name: "V3PoolNotFound", inputs: [] },
1967
1954
  { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
1968
- { type: "error", name: "OnlySlisBNBSupported", inputs: [] }
1955
+ { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
1956
+ { type: "error", name: "ZeroAmount", inputs: [] },
1957
+ { type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
1958
+ { type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address" }] },
1959
+ { type: "error", name: "OwnableUnauthorizedAccount", inputs: [{ name: "account", type: "address" }] },
1960
+ { type: "error", name: "SafeERC20FailedOperation", inputs: [{ name: "token", type: "address" }] },
1961
+ // Receive
1962
+ { type: "receive", stateMutability: "payable" }
1969
1963
  ];
1970
1964
 
1971
1965
  // src/router.ts
@@ -2025,19 +2019,48 @@ var AspanRouterReadClient = class {
2025
2019
  });
2026
2020
  }
2027
2021
  /**
2028
- * Get expected output from a swap and mint operation
2022
+ * Preview apUSD mint output for a given LST amount
2029
2023
  */
2030
- async getExpectedOutput(inputToken, inputAmount, targetLST, mintXBNB) {
2031
- const result = await this.publicClient.readContract({
2024
+ async previewMintApUSD(lst, lstAmount) {
2025
+ return this.publicClient.readContract({
2032
2026
  address: this.routerAddress,
2033
2027
  abi: RouterABI,
2034
- functionName: "getExpectedOutput",
2035
- args: [inputToken, inputAmount, targetLST, mintXBNB]
2028
+ functionName: "previewMintApUSD",
2029
+ args: [lst, lstAmount]
2030
+ });
2031
+ }
2032
+ /**
2033
+ * Preview xBNB mint output for a given LST amount
2034
+ */
2035
+ async previewMintXBNB(lst, lstAmount) {
2036
+ return this.publicClient.readContract({
2037
+ address: this.routerAddress,
2038
+ abi: RouterABI,
2039
+ functionName: "previewMintXBNB",
2040
+ args: [lst, lstAmount]
2041
+ });
2042
+ }
2043
+ /**
2044
+ * Preview LST output for redeeming apUSD
2045
+ */
2046
+ async previewRedeemApUSD(lst, apUSDAmount) {
2047
+ return this.publicClient.readContract({
2048
+ address: this.routerAddress,
2049
+ abi: RouterABI,
2050
+ functionName: "previewRedeemApUSD",
2051
+ args: [lst, apUSDAmount]
2052
+ });
2053
+ }
2054
+ /**
2055
+ * Preview LST output for redeeming xBNB
2056
+ */
2057
+ async previewRedeemXBNB(lst, xBNBAmount) {
2058
+ return this.publicClient.readContract({
2059
+ address: this.routerAddress,
2060
+ abi: RouterABI,
2061
+ functionName: "previewRedeemXBNB",
2062
+ args: [lst, xBNBAmount]
2036
2063
  });
2037
- return {
2038
- expectedLST: result[0],
2039
- expectedMint: result[1]
2040
- };
2041
2064
  }
2042
2065
  /**
2043
2066
  * Get user's withdrawal request indices
@@ -2158,11 +2181,9 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2158
2181
  inputAmount: params.swapParams.inputAmount,
2159
2182
  targetLST: params.swapParams.targetLST,
2160
2183
  minLSTOut: params.swapParams.minLSTOut,
2161
- poolFee: params.swapParams.poolFee,
2162
- useV2: params.swapParams.useV2
2184
+ poolFee: params.swapParams.poolFee
2163
2185
  },
2164
2186
  {
2165
- mintXBNB: params.mintParams.mintXBNB,
2166
2187
  minMintOut: params.mintParams.minMintOut,
2167
2188
  recipient: params.mintParams.recipient,
2168
2189
  deadline: params.mintParams.deadline
@@ -2188,11 +2209,9 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2188
2209
  inputAmount: params.swapParams.inputAmount,
2189
2210
  targetLST: params.swapParams.targetLST,
2190
2211
  minLSTOut: params.swapParams.minLSTOut,
2191
- poolFee: params.swapParams.poolFee,
2192
- useV2: params.swapParams.useV2
2212
+ poolFee: params.swapParams.poolFee
2193
2213
  },
2194
2214
  {
2195
- mintXBNB: params.mintParams.mintXBNB,
2196
2215
  minMintOut: params.mintParams.minMintOut,
2197
2216
  recipient: params.mintParams.recipient,
2198
2217
  deadline: params.mintParams.deadline
@@ -2213,7 +2232,7 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2213
2232
  functionName: "stakeAndMint",
2214
2233
  args: [
2215
2234
  params.targetLST,
2216
- params.mintXBNB,
2235
+ params.isXBNB,
2217
2236
  params.minMintOut,
2218
2237
  params.deadline
2219
2238
  ],
@@ -2344,7 +2363,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2344
2363
  }
2345
2364
  // ============ Redeem and Swap Functions ============
2346
2365
  /**
2347
- * Redeem apUSD and swap LST to output token
2366
+ * Redeem apUSD and swap LST to output token via V3 path
2367
+ * @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
2348
2368
  */
2349
2369
  async redeemApUSDAndSwap(params) {
2350
2370
  return this.walletClient.writeContract({
@@ -2356,16 +2376,15 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2356
2376
  args: [
2357
2377
  params.lst,
2358
2378
  params.amount,
2359
- params.outputToken,
2379
+ params.path,
2360
2380
  params.minOut,
2361
- params.deadline,
2362
- params.useV2,
2363
- params.poolFee
2381
+ params.deadline
2364
2382
  ]
2365
2383
  });
2366
2384
  }
2367
2385
  /**
2368
- * Redeem xBNB and swap LST to output token
2386
+ * Redeem xBNB and swap LST to output token via V3 path
2387
+ * @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
2369
2388
  */
2370
2389
  async redeemXBNBAndSwap(params) {
2371
2390
  return this.walletClient.writeContract({
@@ -2377,40 +2396,12 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2377
2396
  args: [
2378
2397
  params.lst,
2379
2398
  params.amount,
2380
- params.outputToken,
2399
+ params.path,
2381
2400
  params.minOut,
2382
- params.deadline,
2383
- params.useV2,
2384
- params.poolFee
2401
+ params.deadline
2385
2402
  ]
2386
2403
  });
2387
2404
  }
2388
- /**
2389
- * Redeem apUSD and instantly unstake LST to native BNB via DEX
2390
- */
2391
- async redeemApUSDAndUnstake(params) {
2392
- return this.walletClient.writeContract({
2393
- chain: this.chain,
2394
- account: this.walletClient.account,
2395
- address: this.routerAddress,
2396
- abi: RouterABI,
2397
- functionName: "redeemApUSDAndUnstake",
2398
- args: [params.lst, params.amount, params.minBNBOut, params.deadline]
2399
- });
2400
- }
2401
- /**
2402
- * Redeem xBNB and instantly unstake LST to native BNB via DEX
2403
- */
2404
- async redeemXBNBAndUnstake(params) {
2405
- return this.walletClient.writeContract({
2406
- chain: this.chain,
2407
- account: this.walletClient.account,
2408
- address: this.routerAddress,
2409
- abi: RouterABI,
2410
- functionName: "redeemXBNBAndUnstake",
2411
- args: [params.lst, params.amount, params.minBNBOut, params.deadline]
2412
- });
2413
- }
2414
2405
  // ============ Native Unstake Functions ============
2415
2406
  /**
2416
2407
  * Redeem apUSD and request native unstake from Lista (starts unbonding period)
@@ -2490,6 +2481,19 @@ function createRouterTestnetClient(routerAddress, account, rpcUrl) {
2490
2481
  });
2491
2482
  }
2492
2483
 
2484
+ // src/types.ts
2485
+ function encodeV3Path(tokens, fees) {
2486
+ if (tokens.length < 2) throw new Error("Path must have at least 2 tokens");
2487
+ if (fees.length !== tokens.length - 1) throw new Error("Fees length must be tokens.length - 1");
2488
+ let path = tokens[0].toLowerCase().slice(2);
2489
+ for (let i = 0; i < fees.length; i++) {
2490
+ const feeHex = fees[i].toString(16).padStart(6, "0");
2491
+ path += feeHex;
2492
+ path += tokens[i + 1].toLowerCase().slice(2);
2493
+ }
2494
+ return `0x${path}`;
2495
+ }
2496
+
2493
2497
  // src/index.ts
2494
2498
  var PRECISION = 10n ** 18n;
2495
2499
  var BPS_PRECISION = 10000n;
@@ -2545,6 +2549,7 @@ function calculateAPY(previousRate, currentRate, periodDays) {
2545
2549
  createRouterReadClient,
2546
2550
  createRouterTestnetClient,
2547
2551
  createRouterTestnetReadClient,
2552
+ encodeV3Path,
2548
2553
  formatAmount,
2549
2554
  formatCR,
2550
2555
  formatFeeBPS,