@ember-finance/sdk 2.12.0 → 2.14.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.
Files changed (47) hide show
  1. package/dist/src/placements/adapters/alphalend.d.ts +1 -0
  2. package/dist/src/placements/adapters/alphalend.js +58 -0
  3. package/dist/src/placements/adapters/bluefin-spot.d.ts +1 -0
  4. package/dist/src/placements/adapters/bluefin-spot.js +78 -0
  5. package/dist/src/placements/adapters/current.d.ts +1 -0
  6. package/dist/src/placements/adapters/current.js +70 -0
  7. package/dist/src/placements/adapters/evm-protocols.d.ts +1 -0
  8. package/dist/src/placements/adapters/evm-protocols.js +8 -0
  9. package/dist/src/placements/adapters/factory.d.ts +15 -0
  10. package/dist/src/placements/adapters/factory.js +62 -0
  11. package/dist/src/placements/adapters/index.d.ts +14 -0
  12. package/dist/src/placements/adapters/index.js +25 -0
  13. package/dist/src/placements/adapters/navi.d.ts +1 -0
  14. package/dist/src/placements/adapters/navi.js +53 -0
  15. package/dist/src/placements/adapters/pendle.d.ts +9 -0
  16. package/dist/src/placements/adapters/pendle.js +108 -0
  17. package/dist/src/placements/adapters/royco.d.ts +2 -0
  18. package/dist/src/placements/adapters/royco.js +49 -0
  19. package/dist/src/placements/adapters/suilend.d.ts +1 -0
  20. package/dist/src/placements/adapters/suilend.js +57 -0
  21. package/dist/src/placements/batch.d.ts +70 -0
  22. package/dist/src/placements/batch.js +197 -0
  23. package/dist/src/placements/client.d.ts +17 -0
  24. package/dist/src/placements/client.js +194 -0
  25. package/dist/src/placements/evm.d.ts +29 -0
  26. package/dist/src/placements/evm.js +280 -0
  27. package/dist/src/placements/index.d.ts +9 -0
  28. package/dist/src/placements/index.js +9 -0
  29. package/dist/src/placements/pointers.d.ts +24 -0
  30. package/dist/src/placements/pointers.js +126 -0
  31. package/dist/src/placements/registry.d.ts +11 -0
  32. package/dist/src/placements/registry.js +19 -0
  33. package/dist/src/placements/sui.d.ts +47 -0
  34. package/dist/src/placements/sui.js +302 -0
  35. package/dist/src/placements/types.d.ts +147 -0
  36. package/dist/src/placements/types.js +1 -0
  37. package/dist/src/placements/vaults.d.ts +15 -0
  38. package/dist/src/placements/vaults.js +97 -0
  39. package/dist/src/sui-vaults/on-chain-calls/operator.d.ts +124 -0
  40. package/dist/src/sui-vaults/on-chain-calls/operator.js +174 -0
  41. package/dist/src/sui-vaults/on-chain-calls/tx-builder.d.ts +197 -5
  42. package/dist/src/sui-vaults/on-chain-calls/tx-builder.js +493 -7
  43. package/dist/src/sui-vaults/on-chain-calls/user.d.ts +82 -3
  44. package/dist/src/sui-vaults/on-chain-calls/user.js +129 -6
  45. package/dist/src/sui-vaults/on-chain-calls/vault-admin.d.ts +10 -2
  46. package/dist/src/sui-vaults/on-chain-calls/vault-admin.js +11 -6
  47. package/package.json +6 -1
@@ -1,6 +1,6 @@
1
1
  import { SuiDeploymentParser } from "../utils/index.js";
2
2
  import { TransactionBlock } from "@firefly-exchange/library-sui";
3
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
3
+ import { SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui/utils";
4
4
  export class TxBuilder {
5
5
  constructor(_deployment) {
6
6
  this.parser = new SuiDeploymentParser(_deployment);
@@ -1734,21 +1734,30 @@ export class TxBuilder {
1734
1734
  return txb;
1735
1735
  }
1736
1736
  /**
1737
- * Sets the Suilend strategy for an atomic vault
1737
+ * Step 1 of 2 for Suilend activation: commits the reserve index, the market
1738
+ * object and the collateral type. Step 2 is `atomicOpenSuilendObligation`,
1739
+ * without which every supply aborts `ESuilendObligationMissing`.
1740
+ *
1741
+ * The market object and `poolCoinType` became required in the I-11 fix —
1742
+ * previously only the reserve index was committed, so a wrong market was
1743
+ * undetectable on chain.
1738
1744
  * @param vaultId Id of the atomic vault
1745
+ * @param poolCoinType The Suilend pool coin type (P)
1746
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
1739
1747
  * @param reserveArrayIndex Suilend reserve array index
1740
1748
  * @param options Optional tx building params
1741
1749
  * @returns TransactionBlock
1742
1750
  */
1743
- atomicSetStrategySuilend(vaultId, reserveArrayIndex, options) {
1751
+ atomicSetStrategySuilend(vaultId, poolCoinType, lendingMarketId, reserveArrayIndex, options) {
1744
1752
  const txb = options?.txBlock || new TransactionBlock();
1745
1753
  txb.moveCall({
1746
1754
  arguments: [
1747
1755
  txb.object(vaultId),
1748
1756
  txb.object(this.parser.getProtocolConfig()),
1757
+ txb.object(lendingMarketId),
1749
1758
  txb.pure.u64(reserveArrayIndex)
1750
1759
  ],
1751
- typeArguments: [this.parser.getAtomicCollateralType(vaultId)],
1760
+ typeArguments: [this.parser.getAtomicCollateralType(vaultId), poolCoinType],
1752
1761
  target: `${this.parser.getPackageId()}::gateway::atomic_set_strategy_suilend`
1753
1762
  });
1754
1763
  if (options?.gasBudget)
@@ -1757,6 +1766,209 @@ export class TxBuilder {
1757
1766
  txb.setSenderIfNotSet(options.sender);
1758
1767
  return txb;
1759
1768
  }
1769
+ /**
1770
+ * Step 2 of 2 for Suilend activation: opens the obligation the vault's
1771
+ * supply is held in. Must run after `atomicSetStrategySuilend` and before
1772
+ * the first supply.
1773
+ *
1774
+ * Not optional. Suilend accounts liquidity-mining rewards against an
1775
+ * obligation, so cTokens held outside one earn base interest and no
1776
+ * rewards; supplying before this aborts rather than silently falling back.
1777
+ * Callable by either the vault admin or the operator.
1778
+ * @param vaultId Id of the atomic vault
1779
+ * @param poolCoinType The Suilend pool coin type (P)
1780
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
1781
+ * @param options Optional tx building params
1782
+ * @returns TransactionBlock
1783
+ */
1784
+ atomicOpenSuilendObligation(vaultId, poolCoinType, lendingMarketId, options) {
1785
+ const txb = options?.txBlock || new TransactionBlock();
1786
+ txb.moveCall({
1787
+ arguments: [
1788
+ txb.object(vaultId),
1789
+ txb.object(this.parser.getProtocolConfig()),
1790
+ txb.object(lendingMarketId)
1791
+ ],
1792
+ typeArguments: [this.parser.getAtomicCollateralType(vaultId), poolCoinType],
1793
+ target: `${this.parser.getPackageId()}::gateway::atomic_open_suilend_obligation`
1794
+ });
1795
+ if (options?.gasBudget)
1796
+ txb.setGasBudget(options.gasBudget);
1797
+ if (options?.sender)
1798
+ txb.setSenderIfNotSet(options.sender);
1799
+ return txb;
1800
+ }
1801
+ /**
1802
+ * Claims one accrued Suilend pool reward and forwards it to `subAccount`,
1803
+ * which must be on the vault's sub-account allowlist (`EInvalidAccount`).
1804
+ *
1805
+ * Suilend accounts rewards per (reserve, reward slot, deposit-or-borrow)
1806
+ * triple, so call once per triple and batch them in one PTB. Sweep EVERY
1807
+ * occupied slot, not just the live campaign — ended campaigns keep
1808
+ * claimable `earned_rewards`.
1809
+ *
1810
+ * `rewardIndex` must be resolved off chain per claim and never cached:
1811
+ * `add_pool_reward` fills the first vacant slot, so indices are reused, and
1812
+ * a stale (index, rewardType) pair aborts on Suilend's `EInvalidType`.
1813
+ * @param vaultId Id of the atomic vault
1814
+ * @param poolCoinType The Suilend pool coin type (P)
1815
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
1816
+ * @param rewardSourceType Coin type identifying the reserve the reward
1817
+ * accrues on. The vault's collateral for the strategy position itself,
1818
+ * but the foreign type's own reserve for rewards earned by secondary
1819
+ * collateral sitting in the obligation — those accrue separately and are
1820
+ * lost at exit if not claimed.
1821
+ * @param rewardType Coin type of the reward being claimed
1822
+ * @param subAccount Allowlisted sub-account to receive the reward
1823
+ * @param rewardIndex Slot index in the reserve's pool_rewards vector
1824
+ * @param isDepositReward True for the deposit-side reward manager
1825
+ * @param options Optional tx building params
1826
+ * @returns TransactionBlock
1827
+ */
1828
+ atomicClaimSuilendStrategyReward(vaultId, poolCoinType, lendingMarketId, rewardSourceType, rewardType, subAccount, rewardIndex, isDepositReward, options) {
1829
+ const txb = options?.txBlock || new TransactionBlock();
1830
+ txb.moveCall({
1831
+ arguments: [
1832
+ txb.object(vaultId),
1833
+ txb.object(this.parser.getProtocolConfig()),
1834
+ txb.object(lendingMarketId),
1835
+ txb.pure.address(subAccount),
1836
+ txb.pure.u64(rewardIndex),
1837
+ txb.pure.bool(isDepositReward),
1838
+ txb.object(SUI_CLOCK_OBJECT_ID)
1839
+ ],
1840
+ typeArguments: [
1841
+ this.parser.getAtomicCollateralType(vaultId),
1842
+ poolCoinType,
1843
+ rewardSourceType,
1844
+ rewardType
1845
+ ],
1846
+ target: `${this.parser.getPackageId()}::gateway::atomic_claim_suilend_strategy_reward`
1847
+ });
1848
+ if (options?.gasBudget)
1849
+ txb.setGasBudget(options.gasBudget);
1850
+ if (options?.sender)
1851
+ txb.setSenderIfNotSet(options.sender);
1852
+ return txb;
1853
+ }
1854
+ /**
1855
+ * Drains a foreign collateral position from the vault's Suilend obligation
1856
+ * to an allowlisted sub-account.
1857
+ *
1858
+ * Needed because Suilend's `claim_rewards_and_deposit` takes an obligation
1859
+ * id rather than the owner cap, so anyone can deposit this vault's claimed
1860
+ * rewards into its obligation as collateral in a type the vault never
1861
+ * chose. Teardown refuses to discard the obligation cap while any deposit
1862
+ * remains, so this is what stops a third party blocking the exit. Read the
1863
+ * foreign types off the obligation's `deposits` vector; one call per type.
1864
+ *
1865
+ * Aborts if `rewardType` is the vault's collateral — that position exits
1866
+ * through `atomicWithdrawFromSuilendStrategy`.
1867
+ * @param vaultId Id of the atomic vault
1868
+ * @param poolCoinType The Suilend pool coin type (P)
1869
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
1870
+ * @param rewardType Coin type of the foreign collateral position
1871
+ * @param subAccount Allowlisted sub-account to receive the proceeds
1872
+ * @param options Optional tx building params
1873
+ * @returns TransactionBlock
1874
+ */
1875
+ atomicWithdrawSuilendSecondaryCollateral(vaultId, poolCoinType, lendingMarketId, rewardType, subAccount, options) {
1876
+ const txb = options?.txBlock || new TransactionBlock();
1877
+ txb.moveCall({
1878
+ arguments: [
1879
+ txb.object(vaultId),
1880
+ txb.object(this.parser.getProtocolConfig()),
1881
+ txb.object(lendingMarketId),
1882
+ txb.pure.address(subAccount),
1883
+ txb.object(SUI_CLOCK_OBJECT_ID)
1884
+ ],
1885
+ typeArguments: [
1886
+ this.parser.getAtomicCollateralType(vaultId),
1887
+ poolCoinType,
1888
+ rewardType
1889
+ ],
1890
+ target: `${this.parser.getPackageId()}::gateway::atomic_withdraw_suilend_secondary_collateral`
1891
+ });
1892
+ if (options?.gasBudget)
1893
+ txb.setGasBudget(options.gasBudget);
1894
+ if (options?.sender)
1895
+ txb.setSenderIfNotSet(options.sender);
1896
+ return txb;
1897
+ }
1898
+ /**
1899
+ * SUI variant of `atomicWithdrawSuilendSecondaryCollateral`. Threads the Sui
1900
+ * system state for Suilend's request -> unstake -> fulfill path.
1901
+ *
1902
+ * Use this whenever the foreign position is SUI, regardless of the vault's
1903
+ * own collateral type. The generic call rejects SUI, because Suilend stakes
1904
+ * idle SUI reserve balance and the combined redemption helper has no
1905
+ * unstake step — it pays from a liquid balance that may be empty. A SUI
1906
+ * position here is likely rather than exotic: SUI and sSUI are what these
1907
+ * reserves pay out.
1908
+ * @param vaultId Id of the atomic vault
1909
+ * @param poolCoinType The Suilend pool coin type (P)
1910
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
1911
+ * @param subAccount Allowlisted sub-account to receive the proceeds
1912
+ * @param options Optional tx building params
1913
+ * @returns TransactionBlock
1914
+ */
1915
+ atomicWithdrawSuilendSecondaryCollateralSui(vaultId, poolCoinType, lendingMarketId, subAccount, options) {
1916
+ const txb = options?.txBlock || new TransactionBlock();
1917
+ txb.moveCall({
1918
+ arguments: [
1919
+ txb.object(vaultId),
1920
+ txb.object(this.parser.getProtocolConfig()),
1921
+ txb.object(lendingMarketId),
1922
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
1923
+ txb.pure.address(subAccount),
1924
+ txb.object(SUI_CLOCK_OBJECT_ID)
1925
+ ],
1926
+ typeArguments: [this.parser.getAtomicCollateralType(vaultId), poolCoinType],
1927
+ target: `${this.parser.getPackageId()}::gateway::atomic_withdraw_suilend_secondary_collateral_sui`
1928
+ });
1929
+ if (options?.gasBudget)
1930
+ txb.setGasBudget(options.gasBudget);
1931
+ if (options?.sender)
1932
+ txb.setSenderIfNotSet(options.sender);
1933
+ return txb;
1934
+ }
1935
+ /**
1936
+ * Collects accrued AlphaLend rewards of coin type `rewardType` and forwards
1937
+ * them to an allowlisted sub-account.
1938
+ *
1939
+ * Call once per reward type BEFORE exiting the strategy — the exit burns
1940
+ * the `PositionCap` and strands anything uncollected. `rewardType` must not
1941
+ * be SUI; AlphaLend settles SUI through the staking system and needs the
1942
+ * monomorphic variant, which this SDK does not yet expose.
1943
+ *
1944
+ * PTB REQUIREMENT: refresh AlphaLend Pyth prices for the active market
1945
+ * earlier in the same transaction.
1946
+ * @param vaultId Id of the atomic vault
1947
+ * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
1948
+ * @param rewardType Coin type of the reward being collected
1949
+ * @param subAccount Allowlisted sub-account to receive the reward
1950
+ * @param options Optional tx building params
1951
+ * @returns TransactionBlock
1952
+ */
1953
+ atomicCollectAlphalendStrategyReward(vaultId, lendingProtocolId, rewardType, subAccount, options) {
1954
+ const txb = options?.txBlock || new TransactionBlock();
1955
+ txb.moveCall({
1956
+ arguments: [
1957
+ txb.object(vaultId),
1958
+ txb.object(this.parser.getProtocolConfig()),
1959
+ txb.object(lendingProtocolId),
1960
+ txb.pure.address(subAccount),
1961
+ txb.object(SUI_CLOCK_OBJECT_ID)
1962
+ ],
1963
+ typeArguments: [this.parser.getAtomicCollateralType(vaultId), rewardType],
1964
+ target: `${this.parser.getPackageId()}::gateway::atomic_collect_alphalend_strategy_reward`
1965
+ });
1966
+ if (options?.gasBudget)
1967
+ txb.setGasBudget(options.gasBudget);
1968
+ if (options?.sender)
1969
+ txb.setSenderIfNotSet(options.sender);
1970
+ return txb;
1971
+ }
1760
1972
  /**
1761
1973
  * Sets the AlphaLend strategy for an atomic vault
1762
1974
  * @param vaultId Id of the atomic vault
@@ -2384,10 +2596,16 @@ export class TxBuilder {
2384
2596
  * @param sourceVaultId Object id of the source Vault<T, R>
2385
2597
  * @param shareCoinId Object id of the Coin<R> to swap
2386
2598
  * @param receiver Optional receiver address (defaults on-chain to the sender)
2599
+ * @param minNetOut Minimum collateral to receive, in base units. The swap
2600
+ * aborts below it. This is the A-9 slippage guard: the payout is
2601
+ * gross - fee - holdback, and both the fee multiplier (which moves with
2602
+ * utilization) and the source rate can change between quoting and
2603
+ * landing. Pass the value from `previewSwapInstantWithdraw`; 0 disables
2604
+ * the guard entirely.
2387
2605
  * @param options Optional tx building params
2388
2606
  * @returns TransactionBlock
2389
2607
  */
2390
- atomicSwapEmberShares(vaultId, sourceReceiptType, sourceVaultId, shareCoinId, receiver, options) {
2608
+ atomicSwapEmberShares(vaultId, sourceReceiptType, sourceVaultId, shareCoinId, receiver, minNetOut, options) {
2391
2609
  const txb = options?.txBlock || new TransactionBlock();
2392
2610
  txb.moveCall({
2393
2611
  arguments: [
@@ -2396,6 +2614,7 @@ export class TxBuilder {
2396
2614
  txb.object(sourceVaultId),
2397
2615
  txb.object(shareCoinId),
2398
2616
  txb.pure.option("address", receiver ?? null),
2617
+ txb.pure.u64(minNetOut),
2399
2618
  txb.object(SUI_CLOCK_OBJECT_ID)
2400
2619
  ],
2401
2620
  typeArguments: [
@@ -2420,10 +2639,16 @@ export class TxBuilder {
2420
2639
  * @param lendingMarketId Object id of the Suilend LendingMarket<P>
2421
2640
  * @param shareCoinId Object id of the Coin<R> to swap
2422
2641
  * @param receiver Optional receiver address (defaults on-chain to the sender)
2642
+ * @param minNetOut Minimum collateral to receive, in base units. The swap
2643
+ * aborts below it. This is the A-9 slippage guard: the payout is
2644
+ * gross - fee - holdback, and both the fee multiplier (which moves with
2645
+ * utilization) and the source rate can change between quoting and
2646
+ * landing. Pass the value from `previewSwapInstantWithdraw`; 0 disables
2647
+ * the guard entirely.
2423
2648
  * @param options Optional tx building params
2424
2649
  * @returns TransactionBlock
2425
2650
  */
2426
- atomicSwapEmberSharesWithSuilend(vaultId, sourceReceiptType, poolCoinType, sourceVaultId, lendingMarketId, shareCoinId, receiver, options) {
2651
+ atomicSwapEmberSharesWithSuilend(vaultId, sourceReceiptType, poolCoinType, sourceVaultId, lendingMarketId, shareCoinId, receiver, minNetOut, options) {
2427
2652
  const txb = options?.txBlock || new TransactionBlock();
2428
2653
  txb.moveCall({
2429
2654
  arguments: [
@@ -2433,6 +2658,7 @@ export class TxBuilder {
2433
2658
  txb.object(lendingMarketId),
2434
2659
  txb.object(shareCoinId),
2435
2660
  txb.pure.option("address", receiver ?? null),
2661
+ txb.pure.u64(minNetOut),
2436
2662
  txb.object(SUI_CLOCK_OBJECT_ID)
2437
2663
  ],
2438
2664
  typeArguments: [
@@ -2457,10 +2683,16 @@ export class TxBuilder {
2457
2683
  * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
2458
2684
  * @param shareCoinId Object id of the Coin<R> to swap
2459
2685
  * @param receiver Optional receiver address (defaults on-chain to the sender)
2686
+ * @param minNetOut Minimum collateral to receive, in base units. The swap
2687
+ * aborts below it. This is the A-9 slippage guard: the payout is
2688
+ * gross - fee - holdback, and both the fee multiplier (which moves with
2689
+ * utilization) and the source rate can change between quoting and
2690
+ * landing. Pass the value from `previewSwapInstantWithdraw`; 0 disables
2691
+ * the guard entirely.
2460
2692
  * @param options Optional tx building params
2461
2693
  * @returns TransactionBlock
2462
2694
  */
2463
- atomicSwapEmberSharesWithAlphalend(vaultId, sourceReceiptType, sourceVaultId, lendingProtocolId, shareCoinId, receiver, options) {
2695
+ atomicSwapEmberSharesWithAlphalend(vaultId, sourceReceiptType, sourceVaultId, lendingProtocolId, shareCoinId, receiver, minNetOut, options) {
2464
2696
  const txb = options?.txBlock || new TransactionBlock();
2465
2697
  txb.moveCall({
2466
2698
  arguments: [
@@ -2470,6 +2702,7 @@ export class TxBuilder {
2470
2702
  txb.object(lendingProtocolId),
2471
2703
  txb.object(shareCoinId),
2472
2704
  txb.pure.option("address", receiver ?? null),
2705
+ txb.pure.u64(minNetOut),
2473
2706
  txb.object(SUI_CLOCK_OBJECT_ID)
2474
2707
  ],
2475
2708
  typeArguments: [
@@ -2484,4 +2717,257 @@ export class TxBuilder {
2484
2717
  txb.setSenderIfNotSet(options.sender);
2485
2718
  return txb;
2486
2719
  }
2720
+ // === Vault<SUI> variants ===
2721
+ //
2722
+ // A SUI-collateral atomic vault cannot use the generic builders above. The
2723
+ // lending protocols need to unwrap/rewrap SUI through the system state, so
2724
+ // these entry functions are monomorphic in `T = SUI` and take
2725
+ // `&mut SuiSystemState` as an extra argument. `T` therefore drops out of
2726
+ // typeArguments — passing it is the easy mistake here.
2727
+ //
2728
+ // Note the receiver asymmetry, which is in the contract rather than here:
2729
+ // the SUILEND variants take a bare `address`, the ALPHALEND ones take
2730
+ // `Option<address>`. The Suilend builders below therefore require an
2731
+ // explicit receiver — there is no on-chain "default to sender" for them.
2732
+ /**
2733
+ * Swaps ember shares into a SUI-collateral atomic vault, sourcing payout
2734
+ * liquidity from Suilend.
2735
+ * @param vaultId Id of the atomic vault (collateral must be SUI)
2736
+ * @param sourceReceiptType Receipt coin type of the source vault (R)
2737
+ * @param poolCoinType Suilend pool coin type (P)
2738
+ * @param sourceVaultId Object id of the source Vault<SUI, R>
2739
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
2740
+ * @param shareCoinId Object id of the Coin<R> to swap
2741
+ * @param receiver Payout recipient. REQUIRED — this entry function takes a
2742
+ * bare address, so unlike the generic variant there is no on-chain
2743
+ * fallback to the sender.
2744
+ * @param minNetOut Minimum collateral to receive, in base units (A-9 guard)
2745
+ * @param options Optional tx building params
2746
+ * @returns TransactionBlock
2747
+ */
2748
+ atomicSwapEmberSharesWithSuilendSui(vaultId, sourceReceiptType, poolCoinType, sourceVaultId, lendingMarketId, shareCoinId, receiver, minNetOut, options) {
2749
+ const txb = options?.txBlock || new TransactionBlock();
2750
+ txb.moveCall({
2751
+ arguments: [
2752
+ txb.object(vaultId),
2753
+ txb.object(this.parser.getProtocolConfig()),
2754
+ txb.object(sourceVaultId),
2755
+ txb.object(lendingMarketId),
2756
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2757
+ txb.object(shareCoinId),
2758
+ txb.pure.address(receiver),
2759
+ txb.pure.u64(minNetOut),
2760
+ txb.object(SUI_CLOCK_OBJECT_ID)
2761
+ ],
2762
+ typeArguments: [sourceReceiptType, poolCoinType],
2763
+ target: `${this.parser.getPackageId()}::gateway::atomic_swap_ember_shares_with_suilend_sui`
2764
+ });
2765
+ if (options?.gasBudget)
2766
+ txb.setGasBudget(options.gasBudget);
2767
+ if (options?.sender)
2768
+ txb.setSenderIfNotSet(options.sender);
2769
+ return txb;
2770
+ }
2771
+ /**
2772
+ * Swaps ember shares into a SUI-collateral atomic vault, sourcing payout
2773
+ * liquidity from AlphaLend.
2774
+ * @param vaultId Id of the atomic vault (collateral must be SUI)
2775
+ * @param sourceReceiptType Receipt coin type of the source vault (R)
2776
+ * @param sourceVaultId Object id of the source Vault<SUI, R>
2777
+ * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
2778
+ * @param shareCoinId Object id of the Coin<R> to swap
2779
+ * @param receiver Optional receiver address (defaults on-chain to the sender)
2780
+ * @param minNetOut Minimum collateral to receive, in base units (A-9 guard)
2781
+ * @param options Optional tx building params
2782
+ * @returns TransactionBlock
2783
+ */
2784
+ atomicSwapEmberSharesWithAlphalendSui(vaultId, sourceReceiptType, sourceVaultId, lendingProtocolId, shareCoinId, receiver, minNetOut, options) {
2785
+ const txb = options?.txBlock || new TransactionBlock();
2786
+ txb.moveCall({
2787
+ arguments: [
2788
+ txb.object(vaultId),
2789
+ txb.object(this.parser.getProtocolConfig()),
2790
+ txb.object(sourceVaultId),
2791
+ txb.object(lendingProtocolId),
2792
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2793
+ txb.object(shareCoinId),
2794
+ txb.pure.option("address", receiver ?? null),
2795
+ txb.pure.u64(minNetOut),
2796
+ txb.object(SUI_CLOCK_OBJECT_ID)
2797
+ ],
2798
+ typeArguments: [sourceReceiptType],
2799
+ target: `${this.parser.getPackageId()}::gateway::atomic_swap_ember_shares_with_alphalend_sui`
2800
+ });
2801
+ if (options?.gasBudget)
2802
+ txb.setGasBudget(options.gasBudget);
2803
+ if (options?.sender)
2804
+ txb.setSenderIfNotSet(options.sender);
2805
+ return txb;
2806
+ }
2807
+ /**
2808
+ * Instant withdraw from a SUI-collateral atomic vault, pulling liquidity
2809
+ * from Suilend.
2810
+ * @param receiver Payout recipient. REQUIRED — bare address on chain.
2811
+ */
2812
+ atomicInstantWithdrawWithSuilendSui(vaultId, poolCoinType, lendingMarketId, shares, receiver, options) {
2813
+ const txb = options?.txBlock || new TransactionBlock();
2814
+ txb.moveCall({
2815
+ arguments: [
2816
+ txb.object(vaultId),
2817
+ txb.object(this.parser.getProtocolConfig()),
2818
+ txb.object(lendingMarketId),
2819
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2820
+ txb.pure.u64(shares),
2821
+ txb.pure.address(receiver),
2822
+ txb.object(SUI_CLOCK_OBJECT_ID)
2823
+ ],
2824
+ typeArguments: [poolCoinType],
2825
+ target: `${this.parser.getPackageId()}::gateway::atomic_instant_withdraw_with_suilend_sui`
2826
+ });
2827
+ if (options?.gasBudget)
2828
+ txb.setGasBudget(options.gasBudget);
2829
+ if (options?.sender)
2830
+ txb.setSenderIfNotSet(options.sender);
2831
+ return txb;
2832
+ }
2833
+ /**
2834
+ * Instant withdraw from a SUI-collateral atomic vault, pulling liquidity
2835
+ * from AlphaLend.
2836
+ * @param receiver Optional receiver address (defaults on-chain to the sender)
2837
+ */
2838
+ atomicInstantWithdrawWithAlphalendSui(vaultId, lendingProtocolId, shares, receiver, options) {
2839
+ const txb = options?.txBlock || new TransactionBlock();
2840
+ txb.moveCall({
2841
+ arguments: [
2842
+ txb.object(vaultId),
2843
+ txb.object(this.parser.getProtocolConfig()),
2844
+ txb.object(lendingProtocolId),
2845
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2846
+ txb.pure.u64(shares),
2847
+ txb.pure.option("address", receiver ?? null),
2848
+ txb.object(SUI_CLOCK_OBJECT_ID)
2849
+ ],
2850
+ typeArguments: [],
2851
+ target: `${this.parser.getPackageId()}::gateway::atomic_instant_withdraw_with_alphalend_sui`
2852
+ });
2853
+ if (options?.gasBudget)
2854
+ txb.setGasBudget(options.gasBudget);
2855
+ if (options?.sender)
2856
+ txb.setSenderIfNotSet(options.sender);
2857
+ return txb;
2858
+ }
2859
+ /** Exits the Suilend strategy on a SUI-collateral vault (operator). */
2860
+ atomicSetStrategyNoneFromSuilendSui(vaultId, poolCoinType, lendingMarketId, options) {
2861
+ const txb = options?.txBlock || new TransactionBlock();
2862
+ txb.moveCall({
2863
+ arguments: [
2864
+ txb.object(vaultId),
2865
+ txb.object(this.parser.getProtocolConfig()),
2866
+ txb.object(lendingMarketId),
2867
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2868
+ txb.object(SUI_CLOCK_OBJECT_ID)
2869
+ ],
2870
+ typeArguments: [poolCoinType],
2871
+ target: `${this.parser.getPackageId()}::gateway::atomic_set_strategy_none_from_suilend_sui`
2872
+ });
2873
+ if (options?.gasBudget)
2874
+ txb.setGasBudget(options.gasBudget);
2875
+ if (options?.sender)
2876
+ txb.setSenderIfNotSet(options.sender);
2877
+ return txb;
2878
+ }
2879
+ /**
2880
+ * Exits the AlphaLend strategy on a SUI-collateral vault (operator).
2881
+ * @param acceptResidual Abandon a dust residual rather than aborting the exit
2882
+ */
2883
+ atomicSetStrategyNoneFromAlphalendSui(vaultId, lendingProtocolId, acceptResidual, options) {
2884
+ const txb = options?.txBlock || new TransactionBlock();
2885
+ txb.moveCall({
2886
+ arguments: [
2887
+ txb.object(vaultId),
2888
+ txb.object(this.parser.getProtocolConfig()),
2889
+ txb.object(lendingProtocolId),
2890
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2891
+ txb.pure.bool(acceptResidual),
2892
+ txb.object(SUI_CLOCK_OBJECT_ID)
2893
+ ],
2894
+ typeArguments: [],
2895
+ target: `${this.parser.getPackageId()}::gateway::atomic_set_strategy_none_from_alphalend_sui`
2896
+ });
2897
+ if (options?.gasBudget)
2898
+ txb.setGasBudget(options.gasBudget);
2899
+ if (options?.sender)
2900
+ txb.setSenderIfNotSet(options.sender);
2901
+ return txb;
2902
+ }
2903
+ /** Withdraws from the Suilend strategy on a SUI-collateral vault (operator). */
2904
+ atomicWithdrawFromSuilendStrategySui(vaultId, poolCoinType, lendingMarketId, amount, options) {
2905
+ const txb = options?.txBlock || new TransactionBlock();
2906
+ txb.moveCall({
2907
+ arguments: [
2908
+ txb.object(vaultId),
2909
+ txb.object(this.parser.getProtocolConfig()),
2910
+ txb.object(lendingMarketId),
2911
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2912
+ txb.pure.u64(amount),
2913
+ txb.object(SUI_CLOCK_OBJECT_ID)
2914
+ ],
2915
+ typeArguments: [poolCoinType],
2916
+ target: `${this.parser.getPackageId()}::gateway::atomic_withdraw_from_suilend_strategy_sui`
2917
+ });
2918
+ if (options?.gasBudget)
2919
+ txb.setGasBudget(options.gasBudget);
2920
+ if (options?.sender)
2921
+ txb.setSenderIfNotSet(options.sender);
2922
+ return txb;
2923
+ }
2924
+ /** Withdraws from the AlphaLend strategy on a SUI-collateral vault (operator). */
2925
+ atomicWithdrawFromAlphalendStrategySui(vaultId, lendingProtocolId, amount, options) {
2926
+ const txb = options?.txBlock || new TransactionBlock();
2927
+ txb.moveCall({
2928
+ arguments: [
2929
+ txb.object(vaultId),
2930
+ txb.object(this.parser.getProtocolConfig()),
2931
+ txb.object(lendingProtocolId),
2932
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2933
+ txb.pure.u64(amount),
2934
+ txb.object(SUI_CLOCK_OBJECT_ID)
2935
+ ],
2936
+ typeArguments: [],
2937
+ target: `${this.parser.getPackageId()}::gateway::atomic_withdraw_from_alphalend_strategy_sui`
2938
+ });
2939
+ if (options?.gasBudget)
2940
+ txb.setGasBudget(options.gasBudget);
2941
+ if (options?.sender)
2942
+ txb.setSenderIfNotSet(options.sender);
2943
+ return txb;
2944
+ }
2945
+ /**
2946
+ * Collects AlphaLend rewards through the SUI system state and forwards them
2947
+ * to an allowlisted sub-account (operator).
2948
+ *
2949
+ * Unlike the other `_sui` entrypoints this one is still generic in `T` — it
2950
+ * is the reward path, not the collateral path, so the vault's own collateral
2951
+ * type is still a type argument.
2952
+ */
2953
+ atomicCollectAlphalendStrategyRewardSui(vaultId, lendingProtocolId, subAccount, options) {
2954
+ const txb = options?.txBlock || new TransactionBlock();
2955
+ txb.moveCall({
2956
+ arguments: [
2957
+ txb.object(vaultId),
2958
+ txb.object(this.parser.getProtocolConfig()),
2959
+ txb.object(lendingProtocolId),
2960
+ txb.object(SUI_SYSTEM_STATE_OBJECT_ID),
2961
+ txb.pure.address(subAccount),
2962
+ txb.object(SUI_CLOCK_OBJECT_ID)
2963
+ ],
2964
+ typeArguments: [this.parser.getAtomicCollateralType(vaultId)],
2965
+ target: `${this.parser.getPackageId()}::gateway::atomic_collect_alphalend_strategy_reward_sui`
2966
+ });
2967
+ if (options?.gasBudget)
2968
+ txb.setGasBudget(options.gasBudget);
2969
+ if (options?.sender)
2970
+ txb.setSenderIfNotSet(options.sender);
2971
+ return txb;
2972
+ }
2487
2973
  }