@t2000/sdk 5.5.1 → 5.6.1

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.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-KETPmlDo.cjs';
5
- export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-KETPmlDo.cjs';
6
- import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
4
+ import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-D2nKpwJN.cjs';
5
+ export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-D2nKpwJN.cjs';
6
+ import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
9
9
  import '@cetusprotocol/aggregator-sdk';
@@ -376,6 +376,19 @@ declare function normalizeAddressInput(value: string, ctx?: {
376
376
  signal?: AbortSignal;
377
377
  }): Promise<NormalizedAddress>;
378
378
 
379
+ /**
380
+ * Full wallet balance: **every** held coin, not just the curated stables + SUI.
381
+ *
382
+ * Uses one `listBalances` (paginated) instead of N `getBalance` calls, then
383
+ * partitions: stables → priced $1, SUI → Cetus-oracle priced, **everything else
384
+ * → `tokens[]` amount-only** (`usdValue: null` — no price oracle for arbitrary
385
+ * tokens; we don't guess). Decimals for non-registry tokens are read on-chain
386
+ * (the only added call, and only for tokens you actually hold — necessary for a
387
+ * correct amount). `totalUsd` sums **priced holdings only** so it never
388
+ * overstates; `tokens` surfaces the rest honestly.
389
+ */
390
+ declare function queryBalance(client: SuiCoreClient, address: string): Promise<BalanceResponse>;
391
+
379
392
  declare function generateKeypair(): Ed25519Keypair;
380
393
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
381
394
  /**
@@ -409,72 +422,6 @@ declare function walletExists(keyPath?: string): Promise<boolean>;
409
422
  declare function exportPrivateKey(keypair: Ed25519Keypair): string;
410
423
  declare function getAddress(keypair: Ed25519Keypair): string;
411
424
 
412
- /**
413
- * Build a PTB that sends `amount` of `asset` from `address` to `to`.
414
- *
415
- * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
416
- *
417
- * Asset constraint: `'USDC' | 'USDsui' | 'SUI'` only. Other assets throw
418
- * `INVALID_ASSET` via `assertAllowedAsset('send', asset)`. The constrained
419
- * set matches Sui mainnet's gasless allowlist (USDC + USDsui) plus SUI
420
- * for users who want a gas-native transfer.
421
- *
422
- * Build paths:
423
- * - **USDC / USDsui** — `0x2::balance::send_funds` Move call with a
424
- * `tx.balance({ type, balance })` input. When built via `SuiGrpcClient`,
425
- * the gRPC resolver auto-detects gasless eligibility and zeros gas.
426
- * When built via `SuiJsonRpcClient`, the same PTB still executes but
427
- * the caller pays normal gas. Minimum 0.01 (protocol allowlist floor).
428
- * - **SUI** — `tx.splitCoins(tx.gas, [amount]) → tx.transferObjects()`.
429
- * Standard gas-native transfer. No minimum.
430
- *
431
- * Pre-flight balance check stays on JSON-RPC (`client.getBalance`) — it
432
- * sums coin objects + address balance so the legacy `getCoins` page miss
433
- * doesn't break for users whose stables landed via gasless deposits.
434
- *
435
- * `asset` is REQUIRED (no implicit USDC default — pre-v4 hid LLM intent
436
- * errors). Callers passing the wrong asset get an explicit error rather
437
- * than a silent currency substitution.
438
- */
439
- declare function buildSendTx({ client, address, to, amount, asset, }: {
440
- client: SuiCoreClient;
441
- address: string;
442
- to: string;
443
- amount: number;
444
- asset: SendableAsset;
445
- }): Promise<Transaction>;
446
- /**
447
- * Fragment-appender for the chain-mode send leg of SPEC 7 multi-write
448
- * Payment Intents. Consumes a coin reference produced by a previous
449
- * appender (e.g. `addWithdrawToTx`, `addSwapToTx`) and transfers it to
450
- * `recipient` within the same Payment Intent — no intermediate wallet
451
- * materialization.
452
- *
453
- * Codifies the hand-built send leg from
454
- * `scripts/smoke-spec7-withdraw-then-send.ts` (P2.1) into a typed
455
- * appender. SPEC 7 § "Layer 1" — P2.2b will register this in the
456
- * `WRITE_APPENDER_REGISTRY` under `send_transfer` for chain-mode
457
- * dispatch; the registry adapter will handle the wallet-fetch fallback
458
- * by delegating to `buildSendTx` when no upstream coin is available.
459
- *
460
- * For single-step send_transfer flows (no chained predecessor), use
461
- * `buildSendTx` directly — it builds a complete tx including the
462
- * wallet-coin selection / merge / split prelude.
463
- *
464
- * [v4.0 Phase A Day 2] Stays on the legacy `transferObjects` path
465
- * because chain-mode bundles are NEVER gasless — by definition they
466
- * combine multiple Move calls (`withdraw → send`, `swap → send`) which
467
- * fail the protocol allowlist check (only `balance::send_funds` and
468
- * a few related helpers are eligible). The bundled flow still works,
469
- * the user just pays gas (or has it sponsored by audric via Enoki).
470
- *
471
- * @returns void — the coin is consumed by `tx.transferObjects`. Callers
472
- * that need the post-transfer "effective amount" should rely on the
473
- * upstream appender's `effectiveAmount` (e.g. `addWithdrawToTx`'s
474
- * return), not on this appender.
475
- */
476
- declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, recipient: string): void;
477
-
478
425
  /**
479
426
  * SPEC 7 v0.4 § Layer 0 — Canonical Write Architecture.
480
427
  *
@@ -981,4 +928,4 @@ declare function fullHandle(label: string): string;
981
928
  */
982
929
  declare function displayHandle(label: string): string;
983
930
 
984
- export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
931
+ export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-KETPmlDo.js';
5
- export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-KETPmlDo.js';
6
- import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
4
+ import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-D2nKpwJN.js';
5
+ export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-D2nKpwJN.js';
6
+ import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
9
9
  import '@cetusprotocol/aggregator-sdk';
@@ -376,6 +376,19 @@ declare function normalizeAddressInput(value: string, ctx?: {
376
376
  signal?: AbortSignal;
377
377
  }): Promise<NormalizedAddress>;
378
378
 
379
+ /**
380
+ * Full wallet balance: **every** held coin, not just the curated stables + SUI.
381
+ *
382
+ * Uses one `listBalances` (paginated) instead of N `getBalance` calls, then
383
+ * partitions: stables → priced $1, SUI → Cetus-oracle priced, **everything else
384
+ * → `tokens[]` amount-only** (`usdValue: null` — no price oracle for arbitrary
385
+ * tokens; we don't guess). Decimals for non-registry tokens are read on-chain
386
+ * (the only added call, and only for tokens you actually hold — necessary for a
387
+ * correct amount). `totalUsd` sums **priced holdings only** so it never
388
+ * overstates; `tokens` surfaces the rest honestly.
389
+ */
390
+ declare function queryBalance(client: SuiCoreClient, address: string): Promise<BalanceResponse>;
391
+
379
392
  declare function generateKeypair(): Ed25519Keypair;
380
393
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
381
394
  /**
@@ -409,72 +422,6 @@ declare function walletExists(keyPath?: string): Promise<boolean>;
409
422
  declare function exportPrivateKey(keypair: Ed25519Keypair): string;
410
423
  declare function getAddress(keypair: Ed25519Keypair): string;
411
424
 
412
- /**
413
- * Build a PTB that sends `amount` of `asset` from `address` to `to`.
414
- *
415
- * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
416
- *
417
- * Asset constraint: `'USDC' | 'USDsui' | 'SUI'` only. Other assets throw
418
- * `INVALID_ASSET` via `assertAllowedAsset('send', asset)`. The constrained
419
- * set matches Sui mainnet's gasless allowlist (USDC + USDsui) plus SUI
420
- * for users who want a gas-native transfer.
421
- *
422
- * Build paths:
423
- * - **USDC / USDsui** — `0x2::balance::send_funds` Move call with a
424
- * `tx.balance({ type, balance })` input. When built via `SuiGrpcClient`,
425
- * the gRPC resolver auto-detects gasless eligibility and zeros gas.
426
- * When built via `SuiJsonRpcClient`, the same PTB still executes but
427
- * the caller pays normal gas. Minimum 0.01 (protocol allowlist floor).
428
- * - **SUI** — `tx.splitCoins(tx.gas, [amount]) → tx.transferObjects()`.
429
- * Standard gas-native transfer. No minimum.
430
- *
431
- * Pre-flight balance check stays on JSON-RPC (`client.getBalance`) — it
432
- * sums coin objects + address balance so the legacy `getCoins` page miss
433
- * doesn't break for users whose stables landed via gasless deposits.
434
- *
435
- * `asset` is REQUIRED (no implicit USDC default — pre-v4 hid LLM intent
436
- * errors). Callers passing the wrong asset get an explicit error rather
437
- * than a silent currency substitution.
438
- */
439
- declare function buildSendTx({ client, address, to, amount, asset, }: {
440
- client: SuiCoreClient;
441
- address: string;
442
- to: string;
443
- amount: number;
444
- asset: SendableAsset;
445
- }): Promise<Transaction>;
446
- /**
447
- * Fragment-appender for the chain-mode send leg of SPEC 7 multi-write
448
- * Payment Intents. Consumes a coin reference produced by a previous
449
- * appender (e.g. `addWithdrawToTx`, `addSwapToTx`) and transfers it to
450
- * `recipient` within the same Payment Intent — no intermediate wallet
451
- * materialization.
452
- *
453
- * Codifies the hand-built send leg from
454
- * `scripts/smoke-spec7-withdraw-then-send.ts` (P2.1) into a typed
455
- * appender. SPEC 7 § "Layer 1" — P2.2b will register this in the
456
- * `WRITE_APPENDER_REGISTRY` under `send_transfer` for chain-mode
457
- * dispatch; the registry adapter will handle the wallet-fetch fallback
458
- * by delegating to `buildSendTx` when no upstream coin is available.
459
- *
460
- * For single-step send_transfer flows (no chained predecessor), use
461
- * `buildSendTx` directly — it builds a complete tx including the
462
- * wallet-coin selection / merge / split prelude.
463
- *
464
- * [v4.0 Phase A Day 2] Stays on the legacy `transferObjects` path
465
- * because chain-mode bundles are NEVER gasless — by definition they
466
- * combine multiple Move calls (`withdraw → send`, `swap → send`) which
467
- * fail the protocol allowlist check (only `balance::send_funds` and
468
- * a few related helpers are eligible). The bundled flow still works,
469
- * the user just pays gas (or has it sponsored by audric via Enoki).
470
- *
471
- * @returns void — the coin is consumed by `tx.transferObjects`. Callers
472
- * that need the post-transfer "effective amount" should rely on the
473
- * upstream appender's `effectiveAmount` (e.g. `addWithdrawToTx`'s
474
- * return), not on this appender.
475
- */
476
- declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, recipient: string): void;
477
-
478
425
  /**
479
426
  * SPEC 7 v0.4 § Layer 0 — Canonical Write Architecture.
480
427
  *
@@ -981,4 +928,4 @@ declare function fullHandle(label: string): string;
981
928
  */
982
929
  declare function displayHandle(label: string): string;
983
930
 
984
- export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
931
+ export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { normalizeStructTag, isValidSuiAddress, normalizeSuiAddress, fromBase64 } from '@mysten/sui/utils';
1
2
  import { coinWithBalance, Transaction } from '@mysten/sui/transactions';
2
3
  import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
3
4
  import BN from 'bn.js';
@@ -5,7 +6,6 @@ import { EventEmitter } from 'eventemitter3';
5
6
  import { createPaymentTransactionUri } from '@mysten/payment-kit';
6
7
  import { SuiGrpcClient } from '@mysten/sui/grpc';
7
8
  import { SuiGraphQLClient } from '@mysten/sui/graphql';
8
- import { normalizeStructTag, normalizeSuiAddress, isValidSuiAddress, fromBase64 } from '@mysten/sui/utils';
9
9
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
10
10
  import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
11
11
  import { access, mkdir, writeFile, readFile } from 'fs/promises';
@@ -112,6 +112,37 @@ var init_errors = __esm({
112
112
  };
113
113
  }
114
114
  });
115
+ function preflightFail(code, error) {
116
+ return { valid: false, code, error };
117
+ }
118
+ function checkPositiveAmount(amount, label = "Amount", max = PREFLIGHT_MAX_AMOUNT) {
119
+ if (typeof amount !== "number" || !Number.isFinite(amount)) {
120
+ return preflightFail("INVALID_AMOUNT", `${label} must be a finite number`);
121
+ }
122
+ if (amount <= 0) {
123
+ return preflightFail("INVALID_AMOUNT", `${label} must be greater than zero`);
124
+ }
125
+ if (amount > max) {
126
+ return preflightFail("INVALID_AMOUNT", `${label} ${amount} exceeds the sane maximum (${max})`);
127
+ }
128
+ return PREFLIGHT_OK;
129
+ }
130
+ function checkSuiAddress(address, label = "recipient") {
131
+ try {
132
+ if (typeof address === "string" && address.trim() !== "" && isValidSuiAddress(normalizeSuiAddress(address))) {
133
+ return PREFLIGHT_OK;
134
+ }
135
+ } catch {
136
+ }
137
+ return preflightFail("INVALID_ADDRESS", `Invalid ${label} address: ${address}`);
138
+ }
139
+ var PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK;
140
+ var init_preflight = __esm({
141
+ "src/preflight.ts"() {
142
+ PREFLIGHT_MAX_AMOUNT = 1e6;
143
+ PREFLIGHT_OK = { valid: true };
144
+ }
145
+ });
115
146
 
116
147
  // src/token-registry.ts
117
148
  var token_registry_exports = {};
@@ -238,6 +269,7 @@ var init_token_registry = __esm({
238
269
  // src/wallet/coinSelection.ts
239
270
  var coinSelection_exports = {};
240
271
  __export(coinSelection_exports, {
272
+ buildCoinToAddressBalanceMigration: () => buildCoinToAddressBalanceMigration,
241
273
  fetchAllCoins: () => fetchAllCoins,
242
274
  selectAndSplitCoin: () => selectAndSplitCoin,
243
275
  selectSuiCoin: () => selectSuiCoin
@@ -351,6 +383,32 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
351
383
  });
352
384
  return { coin, effectiveAmount, swapAll };
353
385
  }
386
+ function buildCoinToAddressBalanceMigration(args) {
387
+ const { coins, coinType, owner, minAmount } = args;
388
+ const sorted = [...coins].filter((c) => c.balance > 0n).sort((a, b) => b.balance > a.balance ? 1 : b.balance < a.balance ? -1 : 0);
389
+ const selected = [];
390
+ let migratedRaw = 0n;
391
+ for (const c of sorted) {
392
+ if (migratedRaw >= minAmount) break;
393
+ selected.push(c);
394
+ migratedRaw += c.balance;
395
+ }
396
+ if (migratedRaw < minAmount) {
397
+ throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
398
+ available: migratedRaw.toString(),
399
+ required: minAmount.toString()
400
+ });
401
+ }
402
+ const tx = new Transaction();
403
+ for (const c of selected) {
404
+ tx.moveCall({
405
+ target: "0x2::coin::send_funds",
406
+ typeArguments: [coinType],
407
+ arguments: [tx.object(c.objectId), tx.pure.address(owner)]
408
+ });
409
+ }
410
+ return { tx, migratedRaw };
411
+ }
354
412
  async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
355
413
  if (sponsoredContext) {
356
414
  const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
@@ -376,10 +434,28 @@ __export(cetus_swap_exports, {
376
434
  findSwapRoute: () => findSwapRoute,
377
435
  isCetusRouteFresh: () => isCetusRouteFresh,
378
436
  isPrecomputedRouteCompatibleWithProviders: () => isPrecomputedRouteCompatibleWithProviders,
437
+ preflightSwap: () => preflightSwap,
379
438
  resolveTokenType: () => resolveTokenType,
380
439
  serializeCetusRoute: () => serializeCetusRoute,
381
440
  verifyCetusRouteCoinMatch: () => verifyCetusRouteCoinMatch
382
441
  });
442
+ function preflightSwap(input) {
443
+ if (typeof input.from !== "string" || input.from.trim() === "") {
444
+ return preflightFail("INVALID_ASSET", "A `from` token is required to swap");
445
+ }
446
+ if (typeof input.to !== "string" || input.to.trim() === "") {
447
+ return preflightFail("INVALID_ASSET", "A `to` token is required to swap");
448
+ }
449
+ const amountCheck = checkPositiveAmount(input.amount, "Amount", Number.POSITIVE_INFINITY);
450
+ if (!amountCheck.valid) return amountCheck;
451
+ const resolvedFrom = resolveTokenType(input.from);
452
+ const resolvedTo = resolveTokenType(input.to);
453
+ const sameToken = input.from.trim() === input.to.trim() || resolvedFrom !== null && resolvedFrom === resolvedTo;
454
+ if (sameToken) {
455
+ return preflightFail("INVALID_ASSET", `Cannot swap ${input.from} to itself`);
456
+ }
457
+ return PREFLIGHT_OK;
458
+ }
383
459
  function serializeCetusRoute(route, context) {
384
460
  return {
385
461
  routerData: serializeRouterDataV3(route.routerData),
@@ -631,6 +707,7 @@ var OVERLAY_FEE_RATE, clientCache;
631
707
  var init_cetus_swap = __esm({
632
708
  "src/protocols/cetus-swap.ts"() {
633
709
  init_token_registry();
710
+ init_preflight();
634
711
  init_token_registry();
635
712
  OVERLAY_FEE_RATE = 1e-3;
636
713
  clientCache = /* @__PURE__ */ new Map();
@@ -1004,8 +1081,33 @@ async function executeTx(client, signer, buildTx, options = {}) {
1004
1081
 
1005
1082
  // src/wallet/pay.ts
1006
1083
  init_errors();
1084
+ init_preflight();
1085
+ function preflightPay(input) {
1086
+ if (typeof input.url !== "string" || input.url.trim() === "") {
1087
+ return preflightFail("FACILITATOR_REJECTION", "A target URL is required to pay");
1088
+ }
1089
+ let parsed;
1090
+ try {
1091
+ parsed = new URL(input.url);
1092
+ } catch {
1093
+ return preflightFail("FACILITATOR_REJECTION", `Invalid URL: ${input.url}`);
1094
+ }
1095
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
1096
+ return preflightFail(
1097
+ "FACILITATOR_REJECTION",
1098
+ `URL must be http(s): got ${parsed.protocol}//`
1099
+ );
1100
+ }
1101
+ if (input.maxPrice !== void 0) {
1102
+ const priceCheck = checkPositiveAmount(input.maxPrice, "maxPrice");
1103
+ if (!priceCheck.valid) return priceCheck;
1104
+ }
1105
+ return PREFLIGHT_OK;
1106
+ }
1007
1107
  async function payWithMpp(args) {
1008
1108
  const { signer, client, options } = args;
1109
+ const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
1110
+ if (!pf.valid) throw new T2000Error(pf.code, pf.error);
1009
1111
  const method = (options.method ?? "GET").toUpperCase();
1010
1112
  const canHaveBody = method !== "GET" && method !== "HEAD";
1011
1113
  const reqInit = {
@@ -1085,40 +1187,26 @@ async function ensureAddressBalanceCovers(args) {
1085
1187
  required: amountRaw.toString()
1086
1188
  });
1087
1189
  }
1190
+ const coins = [];
1088
1191
  let coinSum = 0n;
1089
1192
  let cursor;
1090
1193
  let hasNext = true;
1091
1194
  while (hasNext) {
1092
1195
  const page = await client.core.listCoins({ owner, coinType: asset, cursor: cursor ?? void 0 });
1093
- for (const c of page.objects) coinSum += BigInt(c.balance);
1196
+ for (const c of page.objects) {
1197
+ coins.push({ objectId: c.objectId, balance: BigInt(c.balance) });
1198
+ coinSum += BigInt(c.balance);
1199
+ }
1094
1200
  cursor = page.cursor;
1095
1201
  hasNext = page.hasNextPage;
1096
1202
  }
1097
1203
  const addressBalance = total - coinSum;
1098
1204
  if (addressBalance >= amountRaw) return 0;
1099
1205
  const shortfall = amountRaw - addressBalance;
1100
- const { Transaction: Transaction6 } = await import('@mysten/sui/transactions');
1101
- const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
1206
+ const { buildCoinToAddressBalanceMigration: buildCoinToAddressBalanceMigration2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
1102
1207
  const grpcClient = await makeGrpcBuildClient(client);
1103
- const migration = await executeTx(
1104
- client,
1105
- signer,
1106
- async () => {
1107
- const tx = new Transaction6();
1108
- const { coin } = await selectAndSplitCoin2(tx, client, owner, asset, shortfall, {
1109
- sponsoredContext: true,
1110
- // coin-objects-only — never the address balance
1111
- allowSwapAll: false
1112
- });
1113
- tx.moveCall({
1114
- target: "0x2::coin::send_funds",
1115
- typeArguments: [asset],
1116
- arguments: [coin, tx.pure.address(owner)]
1117
- });
1118
- return tx;
1119
- },
1120
- { buildClient: grpcClient }
1121
- );
1208
+ const { tx } = buildCoinToAddressBalanceMigration2({ coins, coinType: asset, owner, minAmount: shortfall });
1209
+ const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1122
1210
  return migration.gasCostSui;
1123
1211
  }
1124
1212
  async function finalize(response, opts) {
@@ -1240,6 +1328,25 @@ function normalizeAsset(input) {
1240
1328
  }
1241
1329
 
1242
1330
  // src/wallet/send.ts
1331
+ init_preflight();
1332
+ function preflightSend(input) {
1333
+ try {
1334
+ assertAllowedAsset("send", input.asset);
1335
+ } catch (e) {
1336
+ return preflightFail("INVALID_ASSET", e.message);
1337
+ }
1338
+ const amountCheck = checkPositiveAmount(input.amount);
1339
+ if (!amountCheck.valid) return amountCheck;
1340
+ if ((input.asset === "USDC" || input.asset === "USDsui") && input.amount < GASLESS_MIN_STABLE_AMOUNT) {
1341
+ return preflightFail(
1342
+ "INVALID_AMOUNT",
1343
+ `Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${input.asset}. Got ${input.amount}.`
1344
+ );
1345
+ }
1346
+ const addressCheck = checkSuiAddress(input.to);
1347
+ if (!addressCheck.valid) return addressCheck;
1348
+ return PREFLIGHT_OK;
1349
+ }
1243
1350
  async function buildSendTx({
1244
1351
  client,
1245
1352
  address,
@@ -1247,17 +1354,11 @@ async function buildSendTx({
1247
1354
  amount,
1248
1355
  asset
1249
1356
  }) {
1250
- assertAllowedAsset("send", asset);
1357
+ const pf = preflightSend({ to, amount, asset });
1358
+ if (!pf.valid) throw new T2000Error(pf.code, pf.error);
1251
1359
  const recipient = validateAddress(to);
1252
1360
  const assetInfo = SUPPORTED_ASSETS[asset];
1253
1361
  if (!assetInfo) throw new T2000Error("ASSET_NOT_SUPPORTED", `Asset ${asset} is not supported`);
1254
- if (amount <= 0) throw new T2000Error("INVALID_AMOUNT", "Amount must be greater than zero");
1255
- if ((asset === "USDC" || asset === "USDsui") && amount < GASLESS_MIN_STABLE_AMOUNT) {
1256
- throw new T2000Error(
1257
- "INVALID_AMOUNT",
1258
- `Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${asset}. Got ${amount}.`
1259
- );
1260
- }
1261
1362
  const rawAmount = displayToRaw(amount, assetInfo.decimals);
1262
1363
  const tx = new Transaction();
1263
1364
  tx.setSender(address);
@@ -2053,7 +2154,9 @@ var T2000 = class _T2000 extends EventEmitter {
2053
2154
  amountUsd: approxUsdValue(params.from, params.amount) ?? 0,
2054
2155
  force: params.force
2055
2156
  });
2056
- const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
2157
+ const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2, preflightSwap: preflightSwap2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
2158
+ const pf = preflightSwap2({ from: params.from, to: params.to, amount: params.amount });
2159
+ if (!pf.valid) throw new T2000Error(pf.code, pf.error);
2057
2160
  const fromType = resolveTokenType2(params.from);
2058
2161
  const toType = resolveTokenType2(params.to);
2059
2162
  if (!fromType) throw new T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.from}. Provide the full coin type.`);
@@ -2783,6 +2886,9 @@ function displayHandle(label) {
2783
2886
  return `${label}@${parentDisplay}`;
2784
2887
  }
2785
2888
 
2786
- export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists, writeLimitsFile };
2889
+ // src/index.ts
2890
+ init_preflight();
2891
+
2892
+ export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, preflightFail, preflightPay, preflightSend, preflightSwap, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists, writeLimitsFile };
2787
2893
  //# sourceMappingURL=index.js.map
2788
2894
  //# sourceMappingURL=index.js.map