@aspan/sdk 0.3.1 → 0.4.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/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  AspanRouterClient: () => AspanRouterClient,
26
26
  AspanRouterReadClient: () => AspanRouterReadClient,
27
27
  BPS_PRECISION: () => BPS_PRECISION,
28
+ BSC_ADDRESSES: () => BSC_ADDRESSES,
28
29
  DiamondABI: () => DiamondABI,
29
30
  PRECISION: () => PRECISION,
30
31
  PRICE_PRECISION: () => PRICE_PRECISION,
@@ -1462,11 +1463,11 @@ var import_chains2 = require("viem/chains");
1462
1463
 
1463
1464
  // src/abi/router.ts
1464
1465
  var RouterABI = [
1465
- // ============ Core Swap+Mint Functions ============
1466
- // swapAndMintApUSD
1466
+ // ============ Core Functions ============
1467
+ // swapAndMint - unified swap + mint
1467
1468
  {
1468
1469
  type: "function",
1469
- name: "swapAndMintApUSD",
1470
+ name: "swapAndMint",
1470
1471
  inputs: [
1471
1472
  {
1472
1473
  name: "swapParams",
@@ -1492,45 +1493,26 @@ var RouterABI = [
1492
1493
  ],
1493
1494
  outputs: [
1494
1495
  { name: "lstAmount", type: "uint256" },
1495
- { name: "apUSDAmount", type: "uint256" }
1496
+ { name: "mintedAmount", type: "uint256" }
1496
1497
  ],
1497
1498
  stateMutability: "payable"
1498
1499
  },
1499
- // swapAndMintXBNB
1500
+ // swapAndMintDefault - simplified version using default LST
1500
1501
  {
1501
1502
  type: "function",
1502
- name: "swapAndMintXBNB",
1503
+ name: "swapAndMintDefault",
1503
1504
  inputs: [
1504
- {
1505
- name: "swapParams",
1506
- type: "tuple",
1507
- components: [
1508
- { name: "inputToken", type: "address" },
1509
- { name: "inputAmount", type: "uint256" },
1510
- { name: "targetLST", type: "address" },
1511
- { name: "minLSTOut", type: "uint256" },
1512
- { name: "poolFee", type: "uint24" }
1513
- ]
1514
- },
1515
- {
1516
- name: "mintParams",
1517
- type: "tuple",
1518
- components: [
1519
- { name: "mintXBNB", type: "bool" },
1520
- { name: "minMintOut", type: "uint256" },
1521
- { name: "recipient", type: "address" },
1522
- { name: "deadline", type: "uint256" }
1523
- ]
1524
- }
1525
- ],
1526
- outputs: [
1527
- { name: "lstAmount", type: "uint256" },
1528
- { name: "xBNBAmount", type: "uint256" }
1505
+ { name: "inputToken", type: "address" },
1506
+ { name: "inputAmount", type: "uint256" },
1507
+ { name: "mintXBNB", type: "bool" },
1508
+ { name: "minMintOut", type: "uint256" },
1509
+ { name: "deadline", type: "uint256" }
1529
1510
  ],
1511
+ outputs: [{ name: "mintedAmount", type: "uint256" }],
1530
1512
  stateMutability: "payable"
1531
1513
  },
1532
1514
  // ============ Stake+Mint Functions ============
1533
- // stakeAndMint
1515
+ // stakeAndMint - stake BNB directly to LST and mint
1534
1516
  {
1535
1517
  type: "function",
1536
1518
  name: "stakeAndMint",
@@ -1546,144 +1528,59 @@ var RouterABI = [
1546
1528
  ],
1547
1529
  stateMutability: "payable"
1548
1530
  },
1549
- // stakeAndMintApUSD (simplified)
1550
- {
1551
- type: "function",
1552
- name: "stakeAndMintApUSD",
1553
- inputs: [{ name: "minMintOut", type: "uint256" }],
1554
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
1555
- stateMutability: "payable"
1556
- },
1557
- // stakeAndMintXBNB (simplified)
1558
- {
1559
- type: "function",
1560
- name: "stakeAndMintXBNB",
1561
- inputs: [{ name: "minMintOut", type: "uint256" }],
1562
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
1563
- stateMutability: "payable"
1564
- },
1565
- // ============ Simplified Swap+Mint Functions ============
1566
- // swapAndMintApUSDDefault
1567
- {
1568
- type: "function",
1569
- name: "swapAndMintApUSDDefault",
1570
- inputs: [
1571
- { name: "inputToken", type: "address" },
1572
- { name: "inputAmount", type: "uint256" },
1573
- { name: "minMintOut", type: "uint256" },
1574
- { name: "deadline", type: "uint256" }
1575
- ],
1576
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
1577
- stateMutability: "payable"
1578
- },
1579
- // swapAndMintXBNBDefault
1580
- {
1581
- type: "function",
1582
- name: "swapAndMintXBNBDefault",
1583
- inputs: [
1584
- { name: "inputToken", type: "address" },
1585
- { name: "inputAmount", type: "uint256" },
1586
- { name: "minMintOut", type: "uint256" },
1587
- { name: "deadline", type: "uint256" }
1588
- ],
1589
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
1590
- stateMutability: "payable"
1591
- },
1592
1531
  // ============ Direct Mint/Redeem Functions ============
1593
- // mintApUSD
1532
+ // mint - unified mint function
1594
1533
  {
1595
1534
  type: "function",
1596
- name: "mintApUSD",
1535
+ name: "mint",
1597
1536
  inputs: [
1598
1537
  { name: "lst", type: "address" },
1599
1538
  { name: "lstAmount", type: "uint256" },
1539
+ { name: "mintXBNB", type: "bool" },
1600
1540
  { name: "minOut", type: "uint256" }
1601
1541
  ],
1602
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
1542
+ outputs: [{ name: "mintedAmount", type: "uint256" }],
1603
1543
  stateMutability: "nonpayable"
1604
1544
  },
1605
- // mintXBNB
1545
+ // redeem - unified redeem function
1606
1546
  {
1607
1547
  type: "function",
1608
- name: "mintXBNB",
1609
- inputs: [
1610
- { name: "lst", type: "address" },
1611
- { name: "lstAmount", type: "uint256" },
1612
- { name: "minOut", type: "uint256" }
1613
- ],
1614
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
1615
- stateMutability: "nonpayable"
1616
- },
1617
- // redeemApUSD
1618
- {
1619
- type: "function",
1620
- name: "redeemApUSD",
1548
+ name: "redeem",
1621
1549
  inputs: [
1622
1550
  { name: "lst", type: "address" },
1623
- { name: "apUSDAmount", type: "uint256" },
1551
+ { name: "redeemXBNB", type: "bool" },
1552
+ { name: "amount", type: "uint256" },
1624
1553
  { name: "minOut", type: "uint256" }
1625
1554
  ],
1626
1555
  outputs: [{ name: "lstAmount", type: "uint256" }],
1627
1556
  stateMutability: "nonpayable"
1628
1557
  },
1629
- // redeemXBNB
1558
+ // ============ Redeem + Swap Functions ============
1559
+ // redeemAndSwap - unified redeem and swap via V3 path
1630
1560
  {
1631
1561
  type: "function",
1632
- name: "redeemXBNB",
1633
- inputs: [
1634
- { name: "lst", type: "address" },
1635
- { name: "xBNBAmount", type: "uint256" },
1636
- { name: "minOut", type: "uint256" }
1637
- ],
1638
- outputs: [{ name: "lstAmount", type: "uint256" }],
1639
- stateMutability: "nonpayable"
1640
- },
1641
- // ============ Redeem + Swap Functions (V3 path) ============
1642
- // redeemApUSDAndSwap
1643
- {
1644
- type: "function",
1645
- name: "redeemApUSDAndSwap",
1562
+ name: "redeemAndSwap",
1646
1563
  inputs: [
1647
1564
  { name: "lst", type: "address" },
1648
- { name: "apUSDAmount", type: "uint256" },
1565
+ { name: "redeemXBNB", type: "bool" },
1566
+ { name: "amount", type: "uint256" },
1649
1567
  { name: "path", type: "bytes" },
1650
1568
  { name: "minOut", type: "uint256" },
1651
- { name: "deadline", type: "uint256" }
1652
- ],
1653
- outputs: [{ name: "outputAmount", type: "uint256" }],
1654
- stateMutability: "nonpayable"
1655
- },
1656
- // redeemXBNBAndSwap
1657
- {
1658
- type: "function",
1659
- name: "redeemXBNBAndSwap",
1660
- inputs: [
1661
- { name: "lst", type: "address" },
1662
- { name: "xBNBAmount", type: "uint256" },
1663
- { name: "path", type: "bytes" },
1664
- { name: "minOut", type: "uint256" },
1665
- { name: "deadline", type: "uint256" }
1569
+ { name: "deadline", type: "uint256" },
1570
+ { name: "unwrapBNB", type: "bool" }
1666
1571
  ],
1667
1572
  outputs: [{ name: "outputAmount", type: "uint256" }],
1668
1573
  stateMutability: "nonpayable"
1669
1574
  },
1670
1575
  // ============ Native Unstake Functions ============
1671
- // redeemApUSDAndRequestUnstake
1576
+ // redeemAndRequestUnstake - unified unstake request
1672
1577
  {
1673
1578
  type: "function",
1674
- name: "redeemApUSDAndRequestUnstake",
1675
- inputs: [{ name: "apUSDAmount", type: "uint256" }],
1676
- outputs: [
1677
- { name: "requestIndex", type: "uint256" },
1678
- { name: "slisBNBAmount", type: "uint256" }
1579
+ name: "redeemAndRequestUnstake",
1580
+ inputs: [
1581
+ { name: "redeemXBNB", type: "bool" },
1582
+ { name: "amount", type: "uint256" }
1679
1583
  ],
1680
- stateMutability: "nonpayable"
1681
- },
1682
- // redeemXBNBAndRequestUnstake
1683
- {
1684
- type: "function",
1685
- name: "redeemXBNBAndRequestUnstake",
1686
- inputs: [{ name: "xBNBAmount", type: "uint256" }],
1687
1584
  outputs: [
1688
1585
  { name: "requestIndex", type: "uint256" },
1689
1586
  { name: "slisBNBAmount", type: "uint256" }
@@ -1730,43 +1627,25 @@ var RouterABI = [
1730
1627
  outputs: [{ type: "bool" }],
1731
1628
  stateMutability: "view"
1732
1629
  },
1733
- // Preview functions
1630
+ // Preview functions - unified
1734
1631
  {
1735
1632
  type: "function",
1736
- name: "previewMintApUSD",
1633
+ name: "previewMint",
1737
1634
  inputs: [
1738
1635
  { name: "lst", type: "address" },
1739
- { name: "lstAmount", type: "uint256" }
1740
- ],
1741
- outputs: [{ name: "apUSDAmount", type: "uint256" }],
1742
- stateMutability: "view"
1743
- },
1744
- {
1745
- type: "function",
1746
- name: "previewMintXBNB",
1747
- inputs: [
1748
- { name: "lst", type: "address" },
1749
- { name: "lstAmount", type: "uint256" }
1750
- ],
1751
- outputs: [{ name: "xBNBAmount", type: "uint256" }],
1752
- stateMutability: "view"
1753
- },
1754
- {
1755
- type: "function",
1756
- name: "previewRedeemApUSD",
1757
- inputs: [
1758
- { name: "lst", type: "address" },
1759
- { name: "apUSDAmount", type: "uint256" }
1636
+ { name: "lstAmount", type: "uint256" },
1637
+ { name: "mintXBNB", type: "bool" }
1760
1638
  ],
1761
- outputs: [{ name: "lstAmount", type: "uint256" }],
1639
+ outputs: [{ name: "mintedAmount", type: "uint256" }],
1762
1640
  stateMutability: "view"
1763
1641
  },
1764
1642
  {
1765
1643
  type: "function",
1766
- name: "previewRedeemXBNB",
1644
+ name: "previewRedeem",
1767
1645
  inputs: [
1768
1646
  { name: "lst", type: "address" },
1769
- { name: "xBNBAmount", type: "uint256" }
1647
+ { name: "redeemXBNB", type: "bool" },
1648
+ { name: "amount", type: "uint256" }
1770
1649
  ],
1771
1650
  outputs: [{ name: "lstAmount", type: "uint256" }],
1772
1651
  stateMutability: "view"
@@ -1848,9 +1727,9 @@ var RouterABI = [
1848
1727
  name: "SwapAndMint",
1849
1728
  inputs: [
1850
1729
  { name: "user", type: "address", indexed: true },
1851
- { name: "inputToken", type: "address", indexed: false },
1730
+ { name: "inputToken", type: "address", indexed: true },
1852
1731
  { name: "inputAmount", type: "uint256", indexed: false },
1853
- { name: "lst", type: "address", indexed: false },
1732
+ { name: "targetLST", type: "address", indexed: true },
1854
1733
  { name: "lstAmount", type: "uint256", indexed: false },
1855
1734
  { name: "mintedToken", type: "address", indexed: false },
1856
1735
  { name: "mintedAmount", type: "uint256", indexed: false }
@@ -1862,20 +1741,28 @@ var RouterABI = [
1862
1741
  inputs: [
1863
1742
  { name: "user", type: "address", indexed: true },
1864
1743
  { name: "bnbAmount", type: "uint256", indexed: false },
1865
- { name: "lst", type: "address", indexed: false },
1744
+ { name: "targetLST", type: "address", indexed: true },
1866
1745
  { name: "lstAmount", type: "uint256", indexed: false },
1867
- { name: "mintedToken", type: "address", indexed: false },
1746
+ { name: "mintedToken", type: "address", indexed: true },
1868
1747
  { name: "mintedAmount", type: "uint256", indexed: false }
1869
1748
  ]
1870
1749
  },
1750
+ {
1751
+ type: "event",
1752
+ name: "DefaultLSTUpdated",
1753
+ inputs: [
1754
+ { name: "oldLST", type: "address", indexed: true },
1755
+ { name: "newLST", type: "address", indexed: true }
1756
+ ]
1757
+ },
1871
1758
  {
1872
1759
  type: "event",
1873
1760
  name: "Mint",
1874
1761
  inputs: [
1875
1762
  { name: "user", type: "address", indexed: true },
1876
- { name: "lst", type: "address", indexed: false },
1763
+ { name: "lst", type: "address", indexed: true },
1877
1764
  { name: "lstAmount", type: "uint256", indexed: false },
1878
- { name: "mintedToken", type: "address", indexed: false },
1765
+ { name: "mintedToken", type: "address", indexed: true },
1879
1766
  { name: "mintedAmount", type: "uint256", indexed: false }
1880
1767
  ]
1881
1768
  },
@@ -1884,9 +1771,9 @@ var RouterABI = [
1884
1771
  name: "Redeem",
1885
1772
  inputs: [
1886
1773
  { name: "user", type: "address", indexed: true },
1887
- { name: "redeemedToken", type: "address", indexed: false },
1774
+ { name: "redeemedToken", type: "address", indexed: true },
1888
1775
  { name: "redeemedAmount", type: "uint256", indexed: false },
1889
- { name: "lst", type: "address", indexed: false },
1776
+ { name: "lst", type: "address", indexed: true },
1890
1777
  { name: "lstAmount", type: "uint256", indexed: false }
1891
1778
  ]
1892
1779
  },
@@ -1899,7 +1786,7 @@ var RouterABI = [
1899
1786
  { name: "redeemedAmount", type: "uint256", indexed: false },
1900
1787
  { name: "lst", type: "address", indexed: false },
1901
1788
  { name: "lstAmount", type: "uint256", indexed: false },
1902
- { name: "outputToken", type: "address", indexed: false },
1789
+ { name: "outputToken", type: "address", indexed: true },
1903
1790
  { name: "outputAmount", type: "uint256", indexed: false }
1904
1791
  ]
1905
1792
  },
@@ -1908,7 +1795,7 @@ var RouterABI = [
1908
1795
  name: "UnstakeRequested",
1909
1796
  inputs: [
1910
1797
  { name: "user", type: "address", indexed: true },
1911
- { name: "requestIndex", type: "uint256", indexed: false },
1798
+ { name: "requestIndex", type: "uint256", indexed: true },
1912
1799
  { name: "redeemedToken", type: "address", indexed: false },
1913
1800
  { name: "redeemedAmount", type: "uint256", indexed: false },
1914
1801
  { name: "slisBNBAmount", type: "uint256", indexed: false }
@@ -1919,18 +1806,10 @@ var RouterABI = [
1919
1806
  name: "UnstakeClaimed",
1920
1807
  inputs: [
1921
1808
  { name: "user", type: "address", indexed: true },
1922
- { name: "requestIndex", type: "uint256", indexed: false },
1809
+ { name: "requestIndex", type: "uint256", indexed: true },
1923
1810
  { name: "bnbAmount", type: "uint256", indexed: false }
1924
1811
  ]
1925
1812
  },
1926
- {
1927
- type: "event",
1928
- name: "DefaultLSTUpdated",
1929
- inputs: [
1930
- { name: "oldLST", type: "address", indexed: false },
1931
- { name: "newLST", type: "address", indexed: false }
1932
- ]
1933
- },
1934
1813
  {
1935
1814
  type: "event",
1936
1815
  name: "OwnershipTransferred",
@@ -1952,7 +1831,7 @@ var RouterABI = [
1952
1831
  { type: "error", name: "SwapFailed", inputs: [] },
1953
1832
  { type: "error", name: "UnsupportedInputToken", inputs: [] },
1954
1833
  { type: "error", name: "UnsupportedLST", inputs: [] },
1955
- { type: "error", name: "V3PoolNotFound", inputs: [] },
1834
+ { type: "error", name: "UnsupportedSwapPath", inputs: [] },
1956
1835
  { type: "error", name: "WithdrawalAlreadyClaimed", inputs: [] },
1957
1836
  { type: "error", name: "WithdrawalNotClaimable", inputs: [] },
1958
1837
  { type: "error", name: "ZeroAmount", inputs: [] },
@@ -2021,47 +1900,31 @@ var AspanRouterReadClient = class {
2021
1900
  });
2022
1901
  }
2023
1902
  /**
2024
- * Preview apUSD mint output for a given LST amount
1903
+ * Preview mint output for a given LST amount
1904
+ * @param lst LST token address
1905
+ * @param lstAmount Amount of LST
1906
+ * @param mintXBNB true = preview xBNB mint, false = preview apUSD mint
2025
1907
  */
2026
- async previewMintApUSD(lst, lstAmount) {
1908
+ async previewMint(lst, lstAmount, mintXBNB) {
2027
1909
  return this.publicClient.readContract({
2028
1910
  address: this.routerAddress,
2029
1911
  abi: RouterABI,
2030
- functionName: "previewMintApUSD",
2031
- args: [lst, lstAmount]
1912
+ functionName: "previewMint",
1913
+ args: [lst, lstAmount, mintXBNB]
2032
1914
  });
2033
1915
  }
2034
1916
  /**
2035
- * Preview xBNB mint output for a given LST amount
1917
+ * Preview redeem output
1918
+ * @param lst LST token to receive
1919
+ * @param redeemXBNB true = redeem xBNB, false = redeem apUSD
1920
+ * @param amount Amount of apUSD/xBNB to redeem
2036
1921
  */
2037
- async previewMintXBNB(lst, lstAmount) {
1922
+ async previewRedeem(lst, redeemXBNB, amount) {
2038
1923
  return this.publicClient.readContract({
2039
1924
  address: this.routerAddress,
2040
1925
  abi: RouterABI,
2041
- functionName: "previewMintXBNB",
2042
- args: [lst, lstAmount]
2043
- });
2044
- }
2045
- /**
2046
- * Preview LST output for redeeming apUSD
2047
- */
2048
- async previewRedeemApUSD(lst, apUSDAmount) {
2049
- return this.publicClient.readContract({
2050
- address: this.routerAddress,
2051
- abi: RouterABI,
2052
- functionName: "previewRedeemApUSD",
2053
- args: [lst, apUSDAmount]
2054
- });
2055
- }
2056
- /**
2057
- * Preview LST output for redeeming xBNB
2058
- */
2059
- async previewRedeemXBNB(lst, xBNBAmount) {
2060
- return this.publicClient.readContract({
2061
- address: this.routerAddress,
2062
- abi: RouterABI,
2063
- functionName: "previewRedeemXBNB",
2064
- args: [lst, xBNBAmount]
1926
+ functionName: "previewRedeem",
1927
+ args: [lst, redeemXBNB, amount]
2065
1928
  });
2066
1929
  }
2067
1930
  /**
@@ -2167,16 +2030,18 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2167
2030
  }
2168
2031
  // ============ Core Functions ============
2169
2032
  /**
2170
- * Swap input token to LST and mint apUSD
2033
+ * Swap input token to LST and mint apUSD or xBNB
2034
+ * @param params.swapParams Swap configuration
2035
+ * @param params.mintParams Mint configuration (mintXBNB determines output token)
2171
2036
  */
2172
- async swapAndMintApUSD(params) {
2037
+ async swapAndMint(params) {
2173
2038
  const value = params.swapParams.inputToken === import_viem2.zeroAddress ? params.swapParams.inputAmount : 0n;
2174
2039
  return this.walletClient.writeContract({
2175
2040
  chain: this.chain,
2176
2041
  account: this.walletClient.account,
2177
2042
  address: this.routerAddress,
2178
2043
  abi: RouterABI,
2179
- functionName: "swapAndMintApUSD",
2044
+ functionName: "swapAndMint",
2180
2045
  args: [
2181
2046
  {
2182
2047
  inputToken: params.swapParams.inputToken,
@@ -2186,8 +2051,7 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2186
2051
  poolFee: params.swapParams.poolFee
2187
2052
  },
2188
2053
  {
2189
- mintXBNB: false,
2190
- // swapAndMintApUSD always mints apUSD
2054
+ mintXBNB: params.mintParams.mintXBNB,
2191
2055
  minMintOut: params.mintParams.minMintOut,
2192
2056
  recipient: params.mintParams.recipient,
2193
2057
  deadline: params.mintParams.deadline
@@ -2197,37 +2061,30 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2197
2061
  });
2198
2062
  }
2199
2063
  /**
2200
- * Swap input token to LST and mint xBNB
2064
+ * Swap input token and mint using default LST (simplified)
2065
+ * @param params.mintXBNB true = mint xBNB, false = mint apUSD
2201
2066
  */
2202
- async swapAndMintXBNB(params) {
2203
- const value = params.swapParams.inputToken === import_viem2.zeroAddress ? params.swapParams.inputAmount : 0n;
2067
+ async swapAndMintDefault(params) {
2068
+ const value = params.inputToken === import_viem2.zeroAddress ? params.value ?? params.inputAmount : 0n;
2204
2069
  return this.walletClient.writeContract({
2205
2070
  chain: this.chain,
2206
2071
  account: this.walletClient.account,
2207
2072
  address: this.routerAddress,
2208
2073
  abi: RouterABI,
2209
- functionName: "swapAndMintXBNB",
2074
+ functionName: "swapAndMintDefault",
2210
2075
  args: [
2211
- {
2212
- inputToken: params.swapParams.inputToken,
2213
- inputAmount: params.swapParams.inputAmount,
2214
- targetLST: params.swapParams.targetLST,
2215
- minLSTOut: params.swapParams.minLSTOut,
2216
- poolFee: params.swapParams.poolFee
2217
- },
2218
- {
2219
- mintXBNB: true,
2220
- // swapAndMintXBNB always mints xBNB
2221
- minMintOut: params.mintParams.minMintOut,
2222
- recipient: params.mintParams.recipient,
2223
- deadline: params.mintParams.deadline
2224
- }
2076
+ params.inputToken,
2077
+ params.inputAmount,
2078
+ params.mintXBNB,
2079
+ params.minMintOut,
2080
+ params.deadline
2225
2081
  ],
2226
2082
  value
2227
2083
  });
2228
2084
  }
2229
2085
  /**
2230
2086
  * Stake native BNB directly to LST and mint
2087
+ * @param params.isXBNB true = mint xBNB, false = mint apUSD
2231
2088
  */
2232
2089
  async stakeAndMint(params) {
2233
2090
  return this.walletClient.writeContract({
@@ -2245,194 +2102,73 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2245
2102
  value: params.value
2246
2103
  });
2247
2104
  }
2248
- // ============ Simplified Functions ============
2249
- /**
2250
- * Swap input token and mint apUSD using default LST
2251
- */
2252
- async swapAndMintApUSDDefault(params) {
2253
- const value = params.inputToken === import_viem2.zeroAddress ? params.value ?? params.inputAmount : 0n;
2254
- return this.walletClient.writeContract({
2255
- chain: this.chain,
2256
- account: this.walletClient.account,
2257
- address: this.routerAddress,
2258
- abi: RouterABI,
2259
- functionName: "swapAndMintApUSDDefault",
2260
- args: [
2261
- params.inputToken,
2262
- params.inputAmount,
2263
- params.minMintOut,
2264
- params.deadline
2265
- ],
2266
- value
2267
- });
2268
- }
2269
- /**
2270
- * Swap input token and mint xBNB using default LST
2271
- */
2272
- async swapAndMintXBNBDefault(params) {
2273
- const value = params.inputToken === import_viem2.zeroAddress ? params.value ?? params.inputAmount : 0n;
2274
- return this.walletClient.writeContract({
2275
- chain: this.chain,
2276
- account: this.walletClient.account,
2277
- address: this.routerAddress,
2278
- abi: RouterABI,
2279
- functionName: "swapAndMintXBNBDefault",
2280
- args: [
2281
- params.inputToken,
2282
- params.inputAmount,
2283
- params.minMintOut,
2284
- params.deadline
2285
- ],
2286
- value
2287
- });
2288
- }
2289
- /**
2290
- * Stake native BNB and mint apUSD using default LST
2291
- */
2292
- async stakeAndMintApUSD(minMintOut, value) {
2293
- return this.walletClient.writeContract({
2294
- chain: this.chain,
2295
- account: this.walletClient.account,
2296
- address: this.routerAddress,
2297
- abi: RouterABI,
2298
- functionName: "stakeAndMintApUSD",
2299
- args: [minMintOut],
2300
- value
2301
- });
2302
- }
2303
- /**
2304
- * Stake native BNB and mint xBNB using default LST
2305
- */
2306
- async stakeAndMintXBNB(minMintOut, value) {
2307
- return this.walletClient.writeContract({
2308
- chain: this.chain,
2309
- account: this.walletClient.account,
2310
- address: this.routerAddress,
2311
- abi: RouterABI,
2312
- functionName: "stakeAndMintXBNB",
2313
- args: [minMintOut],
2314
- value
2315
- });
2316
- }
2317
2105
  // ============ Direct Mint/Redeem Functions ============
2318
2106
  /**
2319
- * Mint apUSD by providing LST directly (no swap)
2107
+ * Mint apUSD or xBNB by providing LST directly (no swap)
2108
+ * @param params.mintXBNB true = mint xBNB, false = mint apUSD
2320
2109
  */
2321
- async mintApUSD(params) {
2110
+ async mint(params) {
2322
2111
  return this.walletClient.writeContract({
2323
2112
  chain: this.chain,
2324
2113
  account: this.walletClient.account,
2325
2114
  address: this.routerAddress,
2326
2115
  abi: RouterABI,
2327
- functionName: "mintApUSD",
2328
- args: [params.lst, params.lstAmount, params.minOut ?? 0n]
2116
+ functionName: "mint",
2117
+ args: [params.lst, params.lstAmount, params.mintXBNB, params.minOut ?? 0n]
2329
2118
  });
2330
2119
  }
2331
2120
  /**
2332
- * Mint xBNB by providing LST directly (no swap)
2121
+ * Redeem apUSD or xBNB for LST (no swap)
2122
+ * @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
2333
2123
  */
2334
- async mintXBNB(params) {
2124
+ async redeem(params) {
2335
2125
  return this.walletClient.writeContract({
2336
2126
  chain: this.chain,
2337
2127
  account: this.walletClient.account,
2338
2128
  address: this.routerAddress,
2339
2129
  abi: RouterABI,
2340
- functionName: "mintXBNB",
2341
- args: [params.lst, params.lstAmount, params.minOut ?? 0n]
2342
- });
2343
- }
2344
- /**
2345
- * Redeem apUSD for LST (no swap)
2346
- */
2347
- async redeemApUSD(params) {
2348
- return this.walletClient.writeContract({
2349
- chain: this.chain,
2350
- account: this.walletClient.account,
2351
- address: this.routerAddress,
2352
- abi: RouterABI,
2353
- functionName: "redeemApUSD",
2354
- args: [params.lst, params.apUSDAmount, params.minOut ?? 0n]
2355
- });
2356
- }
2357
- /**
2358
- * Redeem xBNB for LST (no swap)
2359
- */
2360
- async redeemXBNB(params) {
2361
- return this.walletClient.writeContract({
2362
- chain: this.chain,
2363
- account: this.walletClient.account,
2364
- address: this.routerAddress,
2365
- abi: RouterABI,
2366
- functionName: "redeemXBNB",
2367
- args: [params.lst, params.xBNBAmount, params.minOut ?? 0n]
2130
+ functionName: "redeem",
2131
+ args: [params.lst, params.redeemXBNB, params.amount, params.minOut ?? 0n]
2368
2132
  });
2369
2133
  }
2370
2134
  // ============ Redeem and Swap Functions ============
2371
2135
  /**
2372
- * Redeem apUSD and swap LST to output token via V3 path
2373
- * @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
2374
- */
2375
- async redeemApUSDAndSwap(params) {
2376
- return this.walletClient.writeContract({
2377
- chain: this.chain,
2378
- account: this.walletClient.account,
2379
- address: this.routerAddress,
2380
- abi: RouterABI,
2381
- functionName: "redeemApUSDAndSwap",
2382
- args: [
2383
- params.lst,
2384
- params.amount,
2385
- params.path,
2386
- params.minOut,
2387
- params.deadline
2388
- ]
2389
- });
2390
- }
2391
- /**
2392
- * Redeem xBNB and swap LST to output token via V3 path
2393
- * @param params.path - PancakeSwap V3 encoded path (use encodeV3Path helper)
2136
+ * Redeem apUSD/xBNB and swap LST to output token via V3 path
2137
+ * @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
2138
+ * @param params.path PancakeSwap V3 encoded path (use encodeV3Path helper)
2139
+ * @param params.unwrapBNB If true and output is WBNB, unwrap to native BNB
2394
2140
  */
2395
- async redeemXBNBAndSwap(params) {
2141
+ async redeemAndSwap(params) {
2396
2142
  return this.walletClient.writeContract({
2397
2143
  chain: this.chain,
2398
2144
  account: this.walletClient.account,
2399
2145
  address: this.routerAddress,
2400
2146
  abi: RouterABI,
2401
- functionName: "redeemXBNBAndSwap",
2147
+ functionName: "redeemAndSwap",
2402
2148
  args: [
2403
2149
  params.lst,
2150
+ params.redeemXBNB,
2404
2151
  params.amount,
2405
2152
  params.path,
2406
2153
  params.minOut,
2407
- params.deadline
2154
+ params.deadline,
2155
+ params.unwrapBNB
2408
2156
  ]
2409
2157
  });
2410
2158
  }
2411
2159
  // ============ Native Unstake Functions ============
2412
2160
  /**
2413
- * Redeem apUSD and request native unstake from Lista (starts unbonding period)
2161
+ * Redeem apUSD/xBNB and request native unstake from Lista (starts unbonding period)
2162
+ * @param params.redeemXBNB true = redeem xBNB, false = redeem apUSD
2414
2163
  */
2415
- async redeemApUSDAndRequestUnstake(apUSDAmount) {
2164
+ async redeemAndRequestUnstake(params) {
2416
2165
  return this.walletClient.writeContract({
2417
2166
  chain: this.chain,
2418
2167
  account: this.walletClient.account,
2419
2168
  address: this.routerAddress,
2420
2169
  abi: RouterABI,
2421
- functionName: "redeemApUSDAndRequestUnstake",
2422
- args: [apUSDAmount]
2423
- });
2424
- }
2425
- /**
2426
- * Redeem xBNB and request native unstake from Lista (starts unbonding period)
2427
- */
2428
- async redeemXBNBAndRequestUnstake(xBNBAmount) {
2429
- return this.walletClient.writeContract({
2430
- chain: this.chain,
2431
- account: this.walletClient.account,
2432
- address: this.routerAddress,
2433
- abi: RouterABI,
2434
- functionName: "redeemXBNBAndRequestUnstake",
2435
- args: [xBNBAmount]
2170
+ functionName: "redeemAndRequestUnstake",
2171
+ args: [params.redeemXBNB, params.amount]
2436
2172
  });
2437
2173
  }
2438
2174
  /**
@@ -2504,6 +2240,21 @@ function encodeV3Path(tokens, fees) {
2504
2240
  var PRECISION = 10n ** 18n;
2505
2241
  var BPS_PRECISION = 10000n;
2506
2242
  var PRICE_PRECISION = 10n ** 8n;
2243
+ var BSC_ADDRESSES = {
2244
+ diamond: "0x10d25Ae0690533e0BA9E64EC7ae77dbD4fE8A46f",
2245
+ router: "0x813d3D1A3154950E2f1d8718305426a335A974A9",
2246
+ apUSD: "0x1977097E2E5697A6DD91b6732F368a14F50f6B3d",
2247
+ xBNB: "0xB78eB4d5928bAb158Eb23c3154544084cD2661d5",
2248
+ sApUSD: "0xE2BE739C4aA4126ee72D612d9548C38B1B0e5A1b",
2249
+ // LSTs
2250
+ slisBNB: "0xB0b84D294e0C75A6abe60171b70edEb2EFd14A1B",
2251
+ asBNB: "0x77734e70b6E88b4d82fE632a168EDf6e700912b6",
2252
+ wclisBNB: "0x439faaC2229559121C4Ad4fd8B3FE13Dff038046",
2253
+ // Stablecoins
2254
+ USDT: "0x55d398326f99059fF775485246999027B3197955",
2255
+ USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
2256
+ WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
2257
+ };
2507
2258
  function formatAmount(amount, decimals = 4) {
2508
2259
  const divisor = 10n ** BigInt(18 - decimals);
2509
2260
  const scaled = amount / divisor;
@@ -2542,6 +2293,7 @@ function calculateAPY(previousRate, currentRate, periodDays) {
2542
2293
  AspanRouterClient,
2543
2294
  AspanRouterReadClient,
2544
2295
  BPS_PRECISION,
2296
+ BSC_ADDRESSES,
2545
2297
  DiamondABI,
2546
2298
  PRECISION,
2547
2299
  PRICE_PRECISION,