@t2000/sdk 1.4.0 → 1.6.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/adapters/index.cjs +4 -1
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +4 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +2 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +501 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +523 -4
- package/dist/index.d.ts +523 -4
- package/dist/index.js +490 -7
- package/dist/index.js.map +1 -1
- package/dist/{types-BhiUiiNs.d.ts → types-B0VlW8Ov.d.ts} +75 -1
- package/dist/{types-CMVkJNFp.d.cts → types-DrHllxZ5.d.cts} +75 -1
- package/package.json +1 -1
|
@@ -560,6 +560,16 @@ declare function findSwapRoute(params: {
|
|
|
560
560
|
amount: bigint;
|
|
561
561
|
byAmountIn: boolean;
|
|
562
562
|
overlayFee?: OverlayFeeConfig;
|
|
563
|
+
/**
|
|
564
|
+
* Optional Cetus provider allow-list. When omitted, all 30+ DEXes
|
|
565
|
+
* are eligible. Sponsored flows (Enoki) MUST pass an exclusion list
|
|
566
|
+
* computed via `getProvidersExcluding([...])` from the Cetus SDK to
|
|
567
|
+
* remove Pyth-dependent providers (HAEDALPMM, METASTABLE, OBRIC,
|
|
568
|
+
* STEAMM_OMM, STEAMM_OMM_V2, SEVENK, HAEDALHMMV2) — those reference
|
|
569
|
+
* `tx.gas` for oracle fees, which Enoki rejects in sponsored txs.
|
|
570
|
+
* Non-sponsored callers (CLI, direct SDK) leave this undefined.
|
|
571
|
+
*/
|
|
572
|
+
providers?: string[];
|
|
563
573
|
}): Promise<SwapRouteResult | null>;
|
|
564
574
|
/**
|
|
565
575
|
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
@@ -578,6 +588,70 @@ declare function buildSwapTx(params: {
|
|
|
578
588
|
slippage: number;
|
|
579
589
|
overlayFee?: OverlayFeeConfig;
|
|
580
590
|
}): Promise<TransactionObjectArgument>;
|
|
591
|
+
/**
|
|
592
|
+
* Append a swap fragment to an existing PTB. SPEC 7 § "Layer 1" Cetus
|
|
593
|
+
* appender. Two modes, dispatched by the presence of `input.inputCoin`:
|
|
594
|
+
*
|
|
595
|
+
* - **Wallet mode** (`inputCoin` omitted) — fetches `from`-asset coins
|
|
596
|
+
* from the sender's wallet (paginated), merges/splits to the
|
|
597
|
+
* requested amount, runs the swap. Mirrors the audric host's
|
|
598
|
+
* `transactions/prepare/route.ts` swap branch (P2.2c will retire that
|
|
599
|
+
* branch in favor of this appender via `composeTx`).
|
|
600
|
+
*
|
|
601
|
+
* - **Chain mode** (`inputCoin` provided) — consumes the passed-in coin
|
|
602
|
+
* reference (typically produced by an upstream appender like
|
|
603
|
+
* `addWithdrawToTx`) directly, no wallet fetch / no merge / no
|
|
604
|
+
* split. This is the SPEC 7 multi-write enabler ("withdraw → swap →
|
|
605
|
+
* save" without intermediate wallet materialization).
|
|
606
|
+
*
|
|
607
|
+
* **SUI in wallet mode:** uses `client.getCoins` like every other
|
|
608
|
+
* token. This works for sponsored flows (Enoki — `tx.gas` belongs to
|
|
609
|
+
* the sponsor, swap input comes from the user's separate SUI coin
|
|
610
|
+
* objects). For non-sponsored flows where `tx.gas` IS the user's SUI,
|
|
611
|
+
* the caller should pre-build the inputCoin via
|
|
612
|
+
* `tx.splitCoins(tx.gas, [rawAmount])[0]` and pass it via chain mode
|
|
613
|
+
* instead. (`T2000.swap()` already handles this internally — direct SDK
|
|
614
|
+
* users go through the high-level class, not through this appender.)
|
|
615
|
+
*
|
|
616
|
+
* **`swapAll` semantics (wallet mode):** if the requested raw amount
|
|
617
|
+
* is >= the wallet's total `from` balance, the appender consumes the
|
|
618
|
+
* entire merged primary coin (not a split), matching audric's host
|
|
619
|
+
* route's `swapAll` clipping. The returned `effectiveAmountIn` reflects
|
|
620
|
+
* the actual consumed amount in display units.
|
|
621
|
+
*
|
|
622
|
+
* **Slippage:** clamped to [0.001, 0.05] (0.1% – 5%). Defaults to 0.01.
|
|
623
|
+
*
|
|
624
|
+
* @returns
|
|
625
|
+
* - `coin` — output coin reference, ready for downstream consumption
|
|
626
|
+
* (e.g. `addSaveToTx`) or wallet transfer (`tx.transferObjects`).
|
|
627
|
+
* - `effectiveAmountIn` — display-units input amount the swap actually
|
|
628
|
+
* consumes (handles `swapAll` clipping in wallet mode; in chain mode
|
|
629
|
+
* echoes the requested `input.amount`).
|
|
630
|
+
* - `expectedAmountOut` — display-units output amount per the route
|
|
631
|
+
* quote. Actual on-chain output may differ within slippage.
|
|
632
|
+
* - `route` — raw `SwapRouteResult` for downstream telemetry / logging.
|
|
633
|
+
*/
|
|
634
|
+
declare function addSwapToTx(tx: Transaction, client: SuiJsonRpcClient, address: string, input: {
|
|
635
|
+
from: string;
|
|
636
|
+
to: string;
|
|
637
|
+
amount: number;
|
|
638
|
+
slippage?: number;
|
|
639
|
+
byAmountIn?: boolean;
|
|
640
|
+
overlayFee?: OverlayFeeConfig;
|
|
641
|
+
inputCoin?: TransactionObjectArgument;
|
|
642
|
+
/**
|
|
643
|
+
* Optional Cetus provider allow-list. Forwarded to `findSwapRoute`.
|
|
644
|
+
* Sponsored flows (Enoki) MUST pass `getProvidersExcluding([...])`
|
|
645
|
+
* to remove Pyth-dependent providers — see `findSwapRoute`'s JSDoc
|
|
646
|
+
* for the exclusion list. Non-sponsored callers omit this.
|
|
647
|
+
*/
|
|
648
|
+
providers?: string[];
|
|
649
|
+
}): Promise<{
|
|
650
|
+
coin: TransactionObjectArgument;
|
|
651
|
+
effectiveAmountIn: number;
|
|
652
|
+
expectedAmountOut: number;
|
|
653
|
+
route: SwapRouteResult;
|
|
654
|
+
}>;
|
|
581
655
|
|
|
582
656
|
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
583
657
|
interface SafeguardErrorDetails {
|
|
@@ -618,4 +692,4 @@ interface TxMetadata {
|
|
|
618
692
|
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
619
693
|
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
620
694
|
|
|
621
|
-
export { WAL_TYPE as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type T2000ErrorData as H, IKA_TYPE as I, T2000_OVERLAY_FEE_WALLET as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, TOKEN_MAP as Q, type TransactionSigner as R, SAVE_FEE_BPS as S, T2000Error as T, type TxDirection as U, type TxMetadata as V, USDC_DECIMALS as W, USDC_TYPE as X, USDE_TYPE as Y, USDSUI_TYPE as Z, USDT_TYPE as _, BPS_DENOMINATOR as a, WBTC_TYPE as a0, type ZkLoginProof as a1, ZkLoginSigner as a2, addFeeTransfer as a3, buildSwapTx as a4, calculateFee as a5, classifyAction as a6, classifyLabel as a7, classifyTransaction as a8, extractTransferDetails as a9, validateAddress as aA, CETUS_USDC_SUI_POOL as aB, OPERATION_ASSETS as aC, type Operation as aD,
|
|
695
|
+
export { WAL_TYPE as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type T2000ErrorData as H, IKA_TYPE as I, T2000_OVERLAY_FEE_WALLET as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, TOKEN_MAP as Q, type TransactionSigner as R, SAVE_FEE_BPS as S, T2000Error as T, type TxDirection as U, type TxMetadata as V, USDC_DECIMALS as W, USDC_TYPE as X, USDE_TYPE as Y, USDSUI_TYPE as Z, USDT_TYPE as _, BPS_DENOMINATOR as a, WBTC_TYPE as a0, type ZkLoginProof as a1, ZkLoginSigner as a2, addFeeTransfer as a3, buildSwapTx as a4, calculateFee as a5, classifyAction as a6, classifyLabel as a7, classifyTransaction as a8, extractTransferDetails as a9, validateAddress as aA, CETUS_USDC_SUI_POOL as aB, OPERATION_ASSETS as aC, type Operation as aD, addSwapToTx as aE, assertAllowedAsset as aF, getCoinMeta as aG, isAllowedAsset as aH, isInRegistry as aI, normalizeCoinType as aJ, queryHistory as aK, queryTransaction as aL, simulateTransaction as aM, throwIfSimulationFailed as aN, extractTxCommands as aa, extractTxSender as ab, fallbackLabel as ac, findSwapRoute as ad, formatAssetAmount as ae, formatSui as af, formatUsd as ag, getDecimals as ah, getDecimalsForCoinType as ai, getTier as aj, isSupported as ak, isTier1 as al, isTier2 as am, mapMoveAbortCode as an, mapWalletError as ao, mistToSui as ap, parseSuiRpcTx as aq, rawToStable as ar, rawToUsdc as as, refineLendingLabel as at, resolveSymbol as au, resolveTokenType as av, stableToRaw as aw, suiToMist as ax, truncateAddress as ay, usdcToRaw as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, OVERLAY_FEE_RATE as k, type OverlayFeeConfig as l, STABLE_ASSETS as m, SUI_DECIMALS as n, SUI_TYPE as o, SUPPORTED_ASSETS as p, type SafeguardConfig as q, SafeguardError as r, type SafeguardErrorDetails as s, type SafeguardRule as t, type SimulationResult as u, type StableAsset as v, type SuiRpcTxBlock as w, type SupportedAsset as x, type SwapRouteResult as y, type T2000ErrorCode as z };
|
|
@@ -560,6 +560,16 @@ declare function findSwapRoute(params: {
|
|
|
560
560
|
amount: bigint;
|
|
561
561
|
byAmountIn: boolean;
|
|
562
562
|
overlayFee?: OverlayFeeConfig;
|
|
563
|
+
/**
|
|
564
|
+
* Optional Cetus provider allow-list. When omitted, all 30+ DEXes
|
|
565
|
+
* are eligible. Sponsored flows (Enoki) MUST pass an exclusion list
|
|
566
|
+
* computed via `getProvidersExcluding([...])` from the Cetus SDK to
|
|
567
|
+
* remove Pyth-dependent providers (HAEDALPMM, METASTABLE, OBRIC,
|
|
568
|
+
* STEAMM_OMM, STEAMM_OMM_V2, SEVENK, HAEDALHMMV2) — those reference
|
|
569
|
+
* `tx.gas` for oracle fees, which Enoki rejects in sponsored txs.
|
|
570
|
+
* Non-sponsored callers (CLI, direct SDK) leave this undefined.
|
|
571
|
+
*/
|
|
572
|
+
providers?: string[];
|
|
563
573
|
}): Promise<SwapRouteResult | null>;
|
|
564
574
|
/**
|
|
565
575
|
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
@@ -578,6 +588,70 @@ declare function buildSwapTx(params: {
|
|
|
578
588
|
slippage: number;
|
|
579
589
|
overlayFee?: OverlayFeeConfig;
|
|
580
590
|
}): Promise<TransactionObjectArgument>;
|
|
591
|
+
/**
|
|
592
|
+
* Append a swap fragment to an existing PTB. SPEC 7 § "Layer 1" Cetus
|
|
593
|
+
* appender. Two modes, dispatched by the presence of `input.inputCoin`:
|
|
594
|
+
*
|
|
595
|
+
* - **Wallet mode** (`inputCoin` omitted) — fetches `from`-asset coins
|
|
596
|
+
* from the sender's wallet (paginated), merges/splits to the
|
|
597
|
+
* requested amount, runs the swap. Mirrors the audric host's
|
|
598
|
+
* `transactions/prepare/route.ts` swap branch (P2.2c will retire that
|
|
599
|
+
* branch in favor of this appender via `composeTx`).
|
|
600
|
+
*
|
|
601
|
+
* - **Chain mode** (`inputCoin` provided) — consumes the passed-in coin
|
|
602
|
+
* reference (typically produced by an upstream appender like
|
|
603
|
+
* `addWithdrawToTx`) directly, no wallet fetch / no merge / no
|
|
604
|
+
* split. This is the SPEC 7 multi-write enabler ("withdraw → swap →
|
|
605
|
+
* save" without intermediate wallet materialization).
|
|
606
|
+
*
|
|
607
|
+
* **SUI in wallet mode:** uses `client.getCoins` like every other
|
|
608
|
+
* token. This works for sponsored flows (Enoki — `tx.gas` belongs to
|
|
609
|
+
* the sponsor, swap input comes from the user's separate SUI coin
|
|
610
|
+
* objects). For non-sponsored flows where `tx.gas` IS the user's SUI,
|
|
611
|
+
* the caller should pre-build the inputCoin via
|
|
612
|
+
* `tx.splitCoins(tx.gas, [rawAmount])[0]` and pass it via chain mode
|
|
613
|
+
* instead. (`T2000.swap()` already handles this internally — direct SDK
|
|
614
|
+
* users go through the high-level class, not through this appender.)
|
|
615
|
+
*
|
|
616
|
+
* **`swapAll` semantics (wallet mode):** if the requested raw amount
|
|
617
|
+
* is >= the wallet's total `from` balance, the appender consumes the
|
|
618
|
+
* entire merged primary coin (not a split), matching audric's host
|
|
619
|
+
* route's `swapAll` clipping. The returned `effectiveAmountIn` reflects
|
|
620
|
+
* the actual consumed amount in display units.
|
|
621
|
+
*
|
|
622
|
+
* **Slippage:** clamped to [0.001, 0.05] (0.1% – 5%). Defaults to 0.01.
|
|
623
|
+
*
|
|
624
|
+
* @returns
|
|
625
|
+
* - `coin` — output coin reference, ready for downstream consumption
|
|
626
|
+
* (e.g. `addSaveToTx`) or wallet transfer (`tx.transferObjects`).
|
|
627
|
+
* - `effectiveAmountIn` — display-units input amount the swap actually
|
|
628
|
+
* consumes (handles `swapAll` clipping in wallet mode; in chain mode
|
|
629
|
+
* echoes the requested `input.amount`).
|
|
630
|
+
* - `expectedAmountOut` — display-units output amount per the route
|
|
631
|
+
* quote. Actual on-chain output may differ within slippage.
|
|
632
|
+
* - `route` — raw `SwapRouteResult` for downstream telemetry / logging.
|
|
633
|
+
*/
|
|
634
|
+
declare function addSwapToTx(tx: Transaction, client: SuiJsonRpcClient, address: string, input: {
|
|
635
|
+
from: string;
|
|
636
|
+
to: string;
|
|
637
|
+
amount: number;
|
|
638
|
+
slippage?: number;
|
|
639
|
+
byAmountIn?: boolean;
|
|
640
|
+
overlayFee?: OverlayFeeConfig;
|
|
641
|
+
inputCoin?: TransactionObjectArgument;
|
|
642
|
+
/**
|
|
643
|
+
* Optional Cetus provider allow-list. Forwarded to `findSwapRoute`.
|
|
644
|
+
* Sponsored flows (Enoki) MUST pass `getProvidersExcluding([...])`
|
|
645
|
+
* to remove Pyth-dependent providers — see `findSwapRoute`'s JSDoc
|
|
646
|
+
* for the exclusion list. Non-sponsored callers omit this.
|
|
647
|
+
*/
|
|
648
|
+
providers?: string[];
|
|
649
|
+
}): Promise<{
|
|
650
|
+
coin: TransactionObjectArgument;
|
|
651
|
+
effectiveAmountIn: number;
|
|
652
|
+
expectedAmountOut: number;
|
|
653
|
+
route: SwapRouteResult;
|
|
654
|
+
}>;
|
|
581
655
|
|
|
582
656
|
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
583
657
|
interface SafeguardErrorDetails {
|
|
@@ -618,4 +692,4 @@ interface TxMetadata {
|
|
|
618
692
|
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
619
693
|
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
620
694
|
|
|
621
|
-
export { WAL_TYPE as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type T2000ErrorData as H, IKA_TYPE as I, T2000_OVERLAY_FEE_WALLET as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, TOKEN_MAP as Q, type TransactionSigner as R, SAVE_FEE_BPS as S, T2000Error as T, type TxDirection as U, type TxMetadata as V, USDC_DECIMALS as W, USDC_TYPE as X, USDE_TYPE as Y, USDSUI_TYPE as Z, USDT_TYPE as _, BPS_DENOMINATOR as a, WBTC_TYPE as a0, type ZkLoginProof as a1, ZkLoginSigner as a2, addFeeTransfer as a3, buildSwapTx as a4, calculateFee as a5, classifyAction as a6, classifyLabel as a7, classifyTransaction as a8, extractTransferDetails as a9, validateAddress as aA, CETUS_USDC_SUI_POOL as aB, OPERATION_ASSETS as aC, type Operation as aD,
|
|
695
|
+
export { WAL_TYPE as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type T2000ErrorData as H, IKA_TYPE as I, T2000_OVERLAY_FEE_WALLET as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, TOKEN_MAP as Q, type TransactionSigner as R, SAVE_FEE_BPS as S, T2000Error as T, type TxDirection as U, type TxMetadata as V, USDC_DECIMALS as W, USDC_TYPE as X, USDE_TYPE as Y, USDSUI_TYPE as Z, USDT_TYPE as _, BPS_DENOMINATOR as a, WBTC_TYPE as a0, type ZkLoginProof as a1, ZkLoginSigner as a2, addFeeTransfer as a3, buildSwapTx as a4, calculateFee as a5, classifyAction as a6, classifyLabel as a7, classifyTransaction as a8, extractTransferDetails as a9, validateAddress as aA, CETUS_USDC_SUI_POOL as aB, OPERATION_ASSETS as aC, type Operation as aD, addSwapToTx as aE, assertAllowedAsset as aF, getCoinMeta as aG, isAllowedAsset as aH, isInRegistry as aI, normalizeCoinType as aJ, queryHistory as aK, queryTransaction as aL, simulateTransaction as aM, throwIfSimulationFailed as aN, extractTxCommands as aa, extractTxSender as ab, fallbackLabel as ac, findSwapRoute as ad, formatAssetAmount as ae, formatSui as af, formatUsd as ag, getDecimals as ah, getDecimalsForCoinType as ai, getTier as aj, isSupported as ak, isTier1 as al, isTier2 as am, mapMoveAbortCode as an, mapWalletError as ao, mistToSui as ap, parseSuiRpcTx as aq, rawToStable as ar, rawToUsdc as as, refineLendingLabel as at, resolveSymbol as au, resolveTokenType as av, stableToRaw as aw, suiToMist as ax, truncateAddress as ay, usdcToRaw as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, OVERLAY_FEE_RATE as k, type OverlayFeeConfig as l, STABLE_ASSETS as m, SUI_DECIMALS as n, SUI_TYPE as o, SUPPORTED_ASSETS as p, type SafeguardConfig as q, SafeguardError as r, type SafeguardErrorDetails as s, type SafeguardRule as t, type SimulationResult as u, type StableAsset as v, type SuiRpcTxBlock as w, type SupportedAsset as x, type SwapRouteResult as y, type T2000ErrorCode as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2000/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "TypeScript SDK for AI agent bank accounts on Sui — send, save, borrow, swap. NAVI lending + Cetus aggregator routing, sponsored gas, zkLogin compatible.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|