@aspan/sdk 0.4.0 → 0.4.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.d.ts CHANGED
@@ -385,6 +385,20 @@ interface UnstakeClaimedEvent {
385
385
  bnbAmount: bigint;
386
386
  }
387
387
 
388
+ /** Pharos Atlantic Testnet chain definition */
389
+ declare const pharosTestnet: Chain;
390
+ /** Supported chain IDs */
391
+ declare const CHAIN_IDS: {
392
+ readonly BSC: 56;
393
+ readonly BSC_TESTNET: 97;
394
+ readonly PHAROS: 688689;
395
+ };
396
+ /**
397
+ * Get the viem Chain object for a given chainId.
398
+ * @throws if the chainId is not supported
399
+ */
400
+ declare function getChainById(chainId: number): Chain;
401
+
388
402
  interface AspanClientConfig {
389
403
  /** Diamond contract address */
390
404
  diamondAddress: Address;
@@ -404,7 +418,7 @@ interface AspanWriteClientConfig extends AspanClientConfig {
404
418
  */
405
419
  declare class AspanReadClient {
406
420
  protected readonly publicClient: PublicClient;
407
- protected readonly diamondAddress: Address;
421
+ readonly diamondAddress: Address;
408
422
  protected readonly chain: Chain;
409
423
  private static readonly ZERO_SUPPLY_ERROR_SIGNATURES;
410
424
  constructor(config: AspanClientConfig);
@@ -464,6 +478,16 @@ declare class AspanReadClient {
464
478
  getMaxPriceAge(): Promise<bigint>;
465
479
  getMinDepositPeriod(): Promise<bigint>;
466
480
  isPaused(): Promise<boolean>;
481
+ /**
482
+ * Check if xBNB liquidity has been bootstrapped
483
+ * @returns true if bootstrap has been called
484
+ */
485
+ isBootstrapped(): Promise<boolean>;
486
+ /**
487
+ * Get the amount of xBNB locked in bootstrap (burned to dead address)
488
+ * @returns xBNB amount in wei
489
+ */
490
+ getBootstrapXBNBAmount(): Promise<bigint>;
467
491
  getStabilityMode(): Promise<StabilityModeInfo>;
468
492
  canTriggerStabilityMode2(): Promise<StabilityMode2Info>;
469
493
  getOwner(): Promise<Address>;
@@ -521,6 +545,43 @@ declare class AspanClient extends AspanReadClient {
521
545
  * @returns Transaction hash
522
546
  */
523
547
  harvestYield(): Promise<Hash>;
548
+ /**
549
+ * Trigger Stability Mode 2 forced conversion
550
+ * @description Anyone can call when CR < 130%. Burns apUSD from stability pool
551
+ * and mints xBNB to compensate stakers.
552
+ * @param targetCR Target CR to restore to (in BPS, e.g., 14000 = 140%)
553
+ * @returns Transaction hash
554
+ */
555
+ triggerStabilityMode2(targetCR?: bigint): Promise<Hash>;
556
+ /**
557
+ * Clean underwater xBNB (burn without getting LST back)
558
+ * @description Only works when xBNB is underwater (price = 0)
559
+ * @param xBNBAmount Amount of xBNB to clean (burn)
560
+ * @returns Transaction hash
561
+ */
562
+ cleanXbnb(xBNBAmount: bigint): Promise<Hash>;
563
+ /**
564
+ * Set fee tiers (requires feeManager or owner role)
565
+ * @param tiers Array of fee tier configurations
566
+ * @returns Transaction hash
567
+ */
568
+ setFeeTiers(tiers: Array<{
569
+ minCR: bigint;
570
+ apUSDMintFee: number;
571
+ apUSDRedeemFee: number;
572
+ xBNBMintFee: number;
573
+ xBNBRedeemFee: number;
574
+ apUSDMintDisabled: boolean;
575
+ }>): Promise<Hash>;
576
+ /**
577
+ * Bootstrap xBNB liquidity (owner only)
578
+ * @description Initializes xBNB supply by minting to dead address, preventing extreme initial prices.
579
+ * Similar to Uniswap V2's MINIMUM_LIQUIDITY. Can only be called once.
580
+ * @param lstToken LST token address to deposit
581
+ * @param lstAmount Amount of LST to deposit for bootstrap
582
+ * @returns Transaction hash
583
+ */
584
+ bootstrap(lstToken: Address, lstAmount: bigint): Promise<Hash>;
524
585
  /**
525
586
  * Wait for transaction confirmation
526
587
  * @param hash Transaction hash
@@ -544,6 +605,33 @@ declare function createAspanTestnetReadClient(diamondAddress: Address, rpcUrl?:
544
605
  * Create a full client for BSC testnet
545
606
  */
546
607
  declare function createAspanTestnetClient(diamondAddress: Address, account: Account, rpcUrl?: string): AspanClient;
608
+ /**
609
+ * Create a read-only client for Pharos Atlantic Testnet
610
+ */
611
+ declare function createAspanPharosReadClient(diamondAddress: Address, rpcUrl?: string): AspanReadClient;
612
+ /**
613
+ * Create a full client for Pharos Atlantic Testnet
614
+ */
615
+ declare function createAspanPharosClient(diamondAddress: Address, account: Account, rpcUrl?: string): AspanClient;
616
+ /**
617
+ * Create a read-only Aspan client by chainId.
618
+ * Defaults to BSC mainnet (chainId = 56) if chainId is not provided.
619
+ *
620
+ * @param diamondAddress Diamond contract address for the target chain.
621
+ * @param chainId Target chain ID (56 = BSC, 688689 = Pharos). Defaults to 56.
622
+ * @param rpcUrl Optional custom RPC endpoint.
623
+ */
624
+ declare function createAspanReadClientForChain(diamondAddress: Address, chainId?: number, rpcUrl?: string): AspanReadClient;
625
+ /**
626
+ * Create a write Aspan client by chainId using an external wagmi WalletClient.
627
+ * Defaults to BSC mainnet (chainId = 56) if chainId is not provided.
628
+ *
629
+ * @param diamondAddress Diamond contract address for the target chain.
630
+ * @param chainId Target chain ID (56 = BSC, 688689 = Pharos). Defaults to 56.
631
+ * @param walletClient External WalletClient from wagmi / viem.
632
+ * @param rpcUrl Optional custom RPC endpoint.
633
+ */
634
+ declare function createAspanWriteClientForChain(diamondAddress: Address, chainId: number | undefined, walletClient: WalletClient<Transport, Chain, Account>, rpcUrl?: string): AspanClient;
547
635
 
548
636
  interface AspanRouterClientConfig {
549
637
  /** Router contract address */
@@ -683,6 +771,33 @@ declare function createRouterTestnetReadClient(routerAddress: Address, rpcUrl?:
683
771
  * Create a full router client for BSC testnet
684
772
  */
685
773
  declare function createRouterTestnetClient(routerAddress: Address, account: Account, rpcUrl?: string): AspanRouterClient;
774
+ /**
775
+ * Create a read-only router client for Pharos Atlantic Testnet
776
+ */
777
+ declare function createRouterPharosReadClient(routerAddress: Address, rpcUrl?: string): AspanRouterReadClient;
778
+ /**
779
+ * Create a full router client for Pharos Atlantic Testnet
780
+ */
781
+ declare function createRouterPharosClient(routerAddress: Address, account: Account, rpcUrl?: string): AspanRouterClient;
782
+ /**
783
+ * Create a read-only AspanRouter client by chainId.
784
+ * Defaults to BSC mainnet (chainId = 56) if chainId is not provided.
785
+ *
786
+ * @param routerAddress Router contract address for the target chain.
787
+ * @param chainId Target chain ID (56 = BSC, 688689 = Pharos). Defaults to 56.
788
+ * @param rpcUrl Optional custom RPC endpoint.
789
+ */
790
+ declare function createRouterReadClientForChain(routerAddress: Address, chainId?: number, rpcUrl?: string): AspanRouterReadClient;
791
+ /**
792
+ * Create a write AspanRouter client by chainId using an external wagmi WalletClient.
793
+ * Defaults to BSC mainnet (chainId = 56) if chainId is not provided.
794
+ *
795
+ * @param routerAddress Router contract address for the target chain.
796
+ * @param chainId Target chain ID (56 = BSC, 688689 = Pharos). Defaults to 56.
797
+ * @param walletClient External WalletClient from wagmi / viem.
798
+ * @param rpcUrl Optional custom RPC endpoint.
799
+ */
800
+ declare function createRouterWriteClientForChain(routerAddress: Address, chainId: number | undefined, walletClient: WalletClient<Transport, Chain, Account>, rpcUrl?: string): AspanRouterClient;
686
801
 
687
802
  /**
688
803
  * Combined Diamond ABI - includes all facet functions
@@ -1536,6 +1651,44 @@ declare const DiamondABI: readonly [{
1536
1651
  readonly internalType: "bool";
1537
1652
  }];
1538
1653
  readonly stateMutability: "view";
1654
+ }, {
1655
+ readonly type: "function";
1656
+ readonly name: "bootstrap";
1657
+ readonly inputs: readonly [{
1658
+ readonly name: "_lstToken";
1659
+ readonly type: "address";
1660
+ readonly internalType: "address";
1661
+ }, {
1662
+ readonly name: "_lstAmount";
1663
+ readonly type: "uint256";
1664
+ readonly internalType: "uint256";
1665
+ }];
1666
+ readonly outputs: readonly [{
1667
+ readonly name: "xBNBAmount";
1668
+ readonly type: "uint256";
1669
+ readonly internalType: "uint256";
1670
+ }];
1671
+ readonly stateMutability: "nonpayable";
1672
+ }, {
1673
+ readonly type: "function";
1674
+ readonly name: "isBootstrapped";
1675
+ readonly inputs: readonly [];
1676
+ readonly outputs: readonly [{
1677
+ readonly name: "";
1678
+ readonly type: "bool";
1679
+ readonly internalType: "bool";
1680
+ }];
1681
+ readonly stateMutability: "view";
1682
+ }, {
1683
+ readonly type: "function";
1684
+ readonly name: "getBootstrapXBNBAmount";
1685
+ readonly inputs: readonly [];
1686
+ readonly outputs: readonly [{
1687
+ readonly name: "";
1688
+ readonly type: "uint256";
1689
+ readonly internalType: "uint256";
1690
+ }];
1691
+ readonly stateMutability: "view";
1539
1692
  }, {
1540
1693
  readonly type: "function";
1541
1694
  readonly name: "getStabilityMode";
@@ -1586,6 +1739,16 @@ declare const DiamondABI: readonly [{
1586
1739
  readonly internalType: "uint256";
1587
1740
  }];
1588
1741
  readonly stateMutability: "nonpayable";
1742
+ }, {
1743
+ readonly type: "function";
1744
+ readonly name: "cleanXbnb";
1745
+ readonly inputs: readonly [{
1746
+ readonly name: "_xBNBAmount";
1747
+ readonly type: "uint256";
1748
+ readonly internalType: "uint256";
1749
+ }];
1750
+ readonly outputs: readonly [];
1751
+ readonly stateMutability: "nonpayable";
1589
1752
  }, {
1590
1753
  readonly type: "event";
1591
1754
  readonly name: "StabilityMode2Triggered";
@@ -1621,6 +1784,71 @@ declare const DiamondABI: readonly [{
1621
1784
  readonly internalType: "address";
1622
1785
  }];
1623
1786
  readonly stateMutability: "view";
1787
+ }, {
1788
+ readonly type: "function";
1789
+ readonly name: "setFeeManager";
1790
+ readonly inputs: readonly [{
1791
+ readonly name: "_feeManager";
1792
+ readonly type: "address";
1793
+ readonly internalType: "address";
1794
+ }];
1795
+ readonly outputs: readonly [];
1796
+ readonly stateMutability: "nonpayable";
1797
+ }, {
1798
+ readonly type: "function";
1799
+ readonly name: "getFeeManager";
1800
+ readonly inputs: readonly [];
1801
+ readonly outputs: readonly [{
1802
+ readonly name: "";
1803
+ readonly type: "address";
1804
+ readonly internalType: "address";
1805
+ }];
1806
+ readonly stateMutability: "view";
1807
+ }, {
1808
+ readonly type: "function";
1809
+ readonly name: "setFeeTiers";
1810
+ readonly inputs: readonly [{
1811
+ readonly name: "_tiers";
1812
+ readonly type: "tuple[]";
1813
+ readonly internalType: "struct LibAppStorage.FeeTier[]";
1814
+ readonly components: readonly [{
1815
+ readonly name: "minCR";
1816
+ readonly type: "uint256";
1817
+ readonly internalType: "uint256";
1818
+ }, {
1819
+ readonly name: "apUSDMintFee";
1820
+ readonly type: "uint16";
1821
+ readonly internalType: "uint16";
1822
+ }, {
1823
+ readonly name: "apUSDRedeemFee";
1824
+ readonly type: "uint16";
1825
+ readonly internalType: "uint16";
1826
+ }, {
1827
+ readonly name: "xBNBMintFee";
1828
+ readonly type: "uint16";
1829
+ readonly internalType: "uint16";
1830
+ }, {
1831
+ readonly name: "xBNBRedeemFee";
1832
+ readonly type: "uint16";
1833
+ readonly internalType: "uint16";
1834
+ }, {
1835
+ readonly name: "apUSDMintDisabled";
1836
+ readonly type: "bool";
1837
+ readonly internalType: "bool";
1838
+ }];
1839
+ }];
1840
+ readonly outputs: readonly [];
1841
+ readonly stateMutability: "nonpayable";
1842
+ }, {
1843
+ readonly type: "event";
1844
+ readonly name: "FeeManagerSet";
1845
+ readonly inputs: readonly [{
1846
+ readonly name: "feeManager";
1847
+ readonly type: "address";
1848
+ readonly indexed: true;
1849
+ readonly internalType: "address";
1850
+ }];
1851
+ readonly anonymous: false;
1624
1852
  }];
1625
1853
 
1626
1854
  /**
@@ -2413,18 +2641,27 @@ declare const PRECISION: bigint;
2413
2641
  declare const BPS_PRECISION = 10000n;
2414
2642
  declare const PRICE_PRECISION: bigint;
2415
2643
  declare const BSC_ADDRESSES: {
2416
- readonly diamond: "0x10d25Ae0690533e0BA9E64EC7ae77dbD4fE8A46f";
2417
- readonly router: "0x813d3D1A3154950E2f1d8718305426a335A974A9";
2418
- readonly apUSD: "0x1977097E2E5697A6DD91b6732F368a14F50f6B3d";
2419
- readonly xBNB: "0xB78eB4d5928bAb158Eb23c3154544084cD2661d5";
2420
- readonly sApUSD: "0xE2BE739C4aA4126ee72D612d9548C38B1B0e5A1b";
2644
+ readonly diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78";
2645
+ readonly router: "0x29dd49b2e98674ee7531f17e4d40a7725918c3f6";
2646
+ readonly apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287";
2647
+ readonly xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43";
2648
+ readonly sApUSD: "0x73407A291c007a47CC926EcD5CaC256A1E2d00cF";
2421
2649
  readonly slisBNB: "0xB0b84D294e0C75A6abe60171b70edEb2EFd14A1B";
2422
2650
  readonly asBNB: "0x77734e70b6E88b4d82fE632a168EDf6e700912b6";
2423
- readonly wclisBNB: "0x439faaC2229559121C4Ad4fd8B3FE13Dff038046";
2651
+ readonly wclisBNB: "0x448f7c2fa4e5135a4a5B50879602cf3CD428e108";
2424
2652
  readonly USDT: "0x55d398326f99059fF775485246999027B3197955";
2425
2653
  readonly USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d";
2426
2654
  readonly WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
2427
2655
  };
2656
+ declare const PHAROS_ADDRESSES: {
2657
+ readonly diamond: "0x67011Ce4B5E534FA78dD9922559B7005197DBcc8";
2658
+ readonly apUSD: "0x82ac96db027772cE8a770e099370b5D7941B3ae4";
2659
+ readonly xBNB: "0xFF43b2f50b2c6c588d14Ea4565Ee5Eb93e438576";
2660
+ readonly sApUSD: "0xFA4B826CfD5faaAfA48E4963d8a7d6Cf9889A9A8";
2661
+ readonly mockLST: "0xc7BB55759e8e04AfAA620De96E9E133B1FAd3e18";
2662
+ readonly mockPriceFeed: "0xa2B41DDE7a7BB0A897DE476Ea441fB27A6978682";
2663
+ readonly mockExchangeRate: "0xffA1938e072Ea3b144EA7e61662dd8B0818D82B9";
2664
+ };
2428
2665
  /**
2429
2666
  * Format a bigint amount to human-readable string with decimals
2430
2667
  * @param amount Amount in wei (18 decimals)
@@ -2465,4 +2702,4 @@ declare function formatPriceUSD(price: bigint): string;
2465
2702
  */
2466
2703
  declare function calculateAPY(previousRate: bigint, currentRate: bigint, periodDays: number): number;
2467
2704
 
2468
- export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type WithdrawAssetsParams, type WithdrawParams, type WithdrawalRequestInfo, type WithdrawnEvent, type XBNBMintedEvent, type XBNBRedeemedEvent, type YieldHarvestedEvent, type YieldStats, calculateAPY, createAspanClient, createAspanReadClient, createAspanTestnetClient, createAspanTestnetReadClient, createRouterClient, createRouterReadClient, createRouterTestnetClient, createRouterTestnetReadClient, encodeV3Path, formatAmount, formatCR, formatFeeBPS, formatPriceUSD, parseAmount };
2705
+ export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, CHAIN_IDS, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PHAROS_ADDRESSES, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type WithdrawAssetsParams, type WithdrawParams, type WithdrawalRequestInfo, type WithdrawnEvent, type XBNBMintedEvent, type XBNBRedeemedEvent, type YieldHarvestedEvent, type YieldStats, calculateAPY, createAspanClient, createAspanPharosClient, createAspanPharosReadClient, createAspanReadClient, createAspanReadClientForChain, createAspanTestnetClient, createAspanTestnetReadClient, createAspanWriteClientForChain, createRouterClient, createRouterPharosClient, createRouterPharosReadClient, createRouterReadClient, createRouterReadClientForChain, createRouterTestnetClient, createRouterTestnetReadClient, createRouterWriteClientForChain, encodeV3Path, formatAmount, formatCR, formatFeeBPS, formatPriceUSD, getChainById, parseAmount, pharosTestnet };