@t2000/sdk 1.24.14 → 1.25.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.
@@ -1,8 +1,7 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- import { T as TransactionRecord } from './types-jAD-e7Pq.js';
3
+ import { T as TransactionRecord } from './types-BaYOyGKJ.js';
4
4
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
- import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
6
5
 
7
6
  /**
8
7
  * Abstract signing interface that decouples the SDK from any specific
@@ -309,6 +308,88 @@ interface ExtractedTransfer {
309
308
  */
310
309
  declare function extractTransferDetails(changes: ClassifyBalanceChange[] | undefined, sender: string): ExtractedTransfer;
311
310
 
311
+ /**
312
+ * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
313
+ *
314
+ * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
315
+ *
316
+ * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
317
+ * Tier 2: 15 curated swap assets — hold, trade, and send only.
318
+ * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
319
+ *
320
+ * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
321
+ * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
322
+ */
323
+ interface CoinMeta {
324
+ type: string;
325
+ decimals: number;
326
+ symbol: string;
327
+ tier?: 1 | 2;
328
+ }
329
+ /**
330
+ * Canonical coin registry.
331
+ * Key = user-friendly name (used in swap_execute, CLI, prompts).
332
+ */
333
+ declare const COIN_REGISTRY: Record<string, CoinMeta>;
334
+ /**
335
+ * Returns the registry metadata for a coin type, or `undefined` if the coin
336
+ * is not in the registry. Use this when you need to distinguish "known coin"
337
+ * from "supported coin" — `isSupported` only flags tiered (active) coins,
338
+ * but legacy coins like USDsui / USDe / USDT are in the registry without a
339
+ * tier and still need canonical-symbol resolution.
340
+ */
341
+ declare function getCoinMeta(coinType: string): CoinMeta | undefined;
342
+ /**
343
+ * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
344
+ * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
345
+ * entries. The blockvision-prices canonical-symbol gate uses this looser
346
+ * check so that USDsui (legacy/no-tier today, but with a registry-canonical
347
+ * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
348
+ */
349
+ declare function isInRegistry(coinType: string): boolean;
350
+ /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
351
+ declare function isTier1(coinType: string): boolean;
352
+ /** Returns true if the coin type is Tier 2 (curated swap asset). */
353
+ declare function isTier2(coinType: string): boolean;
354
+ /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
355
+ declare function isSupported(coinType: string): boolean;
356
+ /** Returns the tier for a coin type, or undefined if legacy/unknown. */
357
+ declare function getTier(coinType: string): 1 | 2 | undefined;
358
+ /**
359
+ * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
360
+ * Works for both tiered and legacy tokens.
361
+ */
362
+ declare function getDecimalsForCoinType(coinType: string): number;
363
+ /**
364
+ * Resolve a full coin type to a user-friendly symbol.
365
+ * Returns the last `::` segment if not in the registry.
366
+ */
367
+ declare function resolveSymbol(coinType: string): string;
368
+ /**
369
+ * Name → type map for swap resolution. Derived from COIN_REGISTRY.
370
+ * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
371
+ */
372
+ declare const TOKEN_MAP: Record<string, string>;
373
+ /**
374
+ * Resolve a user-friendly token name to its full coin type.
375
+ * Returns the input unchanged if already a full coin type (contains "::").
376
+ * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
377
+ */
378
+ declare function resolveTokenType(nameOrType: string): string | null;
379
+ /** Common type constants for direct import. */
380
+ declare const SUI_TYPE: string;
381
+ declare const USDC_TYPE: string;
382
+ declare const USDT_TYPE: string;
383
+ declare const USDSUI_TYPE: string;
384
+ declare const USDE_TYPE: string;
385
+ declare const ETH_TYPE: string;
386
+ declare const WBTC_TYPE: string;
387
+ declare const WAL_TYPE: string;
388
+ declare const NAVX_TYPE: string;
389
+ declare const IKA_TYPE: string;
390
+ declare const LOFI_TYPE: string;
391
+ declare const MANIFEST_TYPE: string;
392
+
312
393
  declare function queryHistory(client: SuiJsonRpcClient, address: string, limit?: number): Promise<TransactionRecord[]>;
313
394
  declare function queryTransaction(client: SuiJsonRpcClient, digest: string, senderAddress: string): Promise<TransactionRecord | null>;
314
395
  /**
@@ -441,231 +522,6 @@ declare function calculateFee(operation: FeeOperation, amount: number): Protocol
441
522
  */
442
523
  declare function addFeeTransfer(tx: Transaction, paymentCoin: TransactionObjectArgument, feeBps: bigint, receiver: string, amount: number, decimals?: number): void;
443
524
 
444
- /**
445
- * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
446
- *
447
- * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
448
- *
449
- * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
450
- * Tier 2: 15 curated swap assets — hold, trade, and send only.
451
- * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
452
- *
453
- * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
454
- * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
455
- */
456
- interface CoinMeta {
457
- type: string;
458
- decimals: number;
459
- symbol: string;
460
- tier?: 1 | 2;
461
- }
462
- /**
463
- * Canonical coin registry.
464
- * Key = user-friendly name (used in swap_execute, CLI, prompts).
465
- */
466
- declare const COIN_REGISTRY: Record<string, CoinMeta>;
467
- /**
468
- * Returns the registry metadata for a coin type, or `undefined` if the coin
469
- * is not in the registry. Use this when you need to distinguish "known coin"
470
- * from "supported coin" — `isSupported` only flags tiered (active) coins,
471
- * but legacy coins like USDsui / USDe / USDT are in the registry without a
472
- * tier and still need canonical-symbol resolution.
473
- */
474
- declare function getCoinMeta(coinType: string): CoinMeta | undefined;
475
- /**
476
- * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
477
- * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
478
- * entries. The blockvision-prices canonical-symbol gate uses this looser
479
- * check so that USDsui (legacy/no-tier today, but with a registry-canonical
480
- * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
481
- */
482
- declare function isInRegistry(coinType: string): boolean;
483
- /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
484
- declare function isTier1(coinType: string): boolean;
485
- /** Returns true if the coin type is Tier 2 (curated swap asset). */
486
- declare function isTier2(coinType: string): boolean;
487
- /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
488
- declare function isSupported(coinType: string): boolean;
489
- /** Returns the tier for a coin type, or undefined if legacy/unknown. */
490
- declare function getTier(coinType: string): 1 | 2 | undefined;
491
- /**
492
- * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
493
- * Works for both tiered and legacy tokens.
494
- */
495
- declare function getDecimalsForCoinType(coinType: string): number;
496
- /**
497
- * Resolve a full coin type to a user-friendly symbol.
498
- * Returns the last `::` segment if not in the registry.
499
- */
500
- declare function resolveSymbol(coinType: string): string;
501
- /**
502
- * Name → type map for swap resolution. Derived from COIN_REGISTRY.
503
- * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
504
- */
505
- declare const TOKEN_MAP: Record<string, string>;
506
- /**
507
- * Resolve a user-friendly token name to its full coin type.
508
- * Returns the input unchanged if already a full coin type (contains "::").
509
- * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
510
- */
511
- declare function resolveTokenType(nameOrType: string): string | null;
512
- /** Common type constants for direct import. */
513
- declare const SUI_TYPE: string;
514
- declare const USDC_TYPE: string;
515
- declare const USDT_TYPE: string;
516
- declare const USDSUI_TYPE: string;
517
- declare const USDE_TYPE: string;
518
- declare const ETH_TYPE: string;
519
- declare const WBTC_TYPE: string;
520
- declare const WAL_TYPE: string;
521
- declare const NAVX_TYPE: string;
522
- declare const IKA_TYPE: string;
523
- declare const LOFI_TYPE: string;
524
- declare const MANIFEST_TYPE: string;
525
-
526
- /**
527
- * Cetus Aggregator V3 SDK wrapper — the ONLY file that imports @cetusprotocol/aggregator-sdk.
528
- * Documented CLAUDE.md exception: multi-DEX routing cannot be feasibly replaced by thin tx builders.
529
- *
530
- * [B5 v2 / @t2000/sdk@1.1.0 / 2026-04-30]
531
- * Overlay fee config is now per-call instead of a module-level singleton. CLI / direct
532
- * SDK callers (`T2000.swap()`) DON'T pass `overlayFee` → fee-free swap. Audric's
533
- * prepare/route.ts ALWAYS passes `overlayFee = { rate: OVERLAY_FEE_RATE, receiver:
534
- * T2000_OVERLAY_FEE_WALLET }` → fee charged. Structural inclusion (Audric's code can't
535
- * forget to pass it because it IS the code), not a toggle that defaults to safe.
536
- *
537
- * Pre-1.1.0: a module-level `OVERLAY_FEE_RECEIVER` constant defaulted to a Move object
538
- * ID. USDC sent there became OwnedObjects keyed to the object and was inaccessible.
539
- * Fixed by making the receiver a regular wallet address (T2000_OVERLAY_FEE_WALLET) AND
540
- * by removing the singleton pattern that hid the misconfig.
541
- */
542
-
543
- interface OverlayFeeConfig {
544
- /** Fee rate as a fraction (e.g. 0.001 = 0.1%). Pass 0 to disable. */
545
- rate: number;
546
- /** Wallet address that receives the overlay fee. */
547
- receiver: string;
548
- }
549
- interface SwapRouteResult {
550
- routerData: RouterDataV3;
551
- amountIn: string;
552
- amountOut: string;
553
- byAmountIn: boolean;
554
- priceImpact: number;
555
- insufficientLiquidity: boolean;
556
- }
557
- /**
558
- * Default Audric swap overlay fee — 0.1%. Exported for consumers that want to use
559
- * the canonical Audric rate (the Audric prepare-route does this). Changing this
560
- * rate requires a coordinated SDK + audric release.
561
- */
562
- declare const OVERLAY_FEE_RATE = 0.001;
563
- /**
564
- * Find the optimal swap route via Cetus Aggregator REST API.
565
- *
566
- * Pass `overlayFee` to charge an overlay fee on the output (Audric's pattern).
567
- * Omit it for a fee-free swap (CLI / direct SDK pattern).
568
- */
569
- declare function findSwapRoute(params: {
570
- walletAddress: string;
571
- from: string;
572
- to: string;
573
- amount: bigint;
574
- byAmountIn: boolean;
575
- overlayFee?: OverlayFeeConfig;
576
- /**
577
- * Optional Cetus provider allow-list. When omitted, all 30+ DEXes
578
- * are eligible. Sponsored flows (Enoki) MUST pass an exclusion list
579
- * computed via `getProvidersExcluding([...])` from the Cetus SDK to
580
- * remove Pyth-dependent providers (HAEDALPMM, METASTABLE, OBRIC,
581
- * STEAMM_OMM, STEAMM_OMM_V2, SEVENK, HAEDALHMMV2) — those reference
582
- * `tx.gas` for oracle fees, which Enoki rejects in sponsored txs.
583
- * Non-sponsored callers (CLI, direct SDK) leave this undefined.
584
- */
585
- providers?: string[];
586
- }): Promise<SwapRouteResult | null>;
587
- /**
588
- * Build a swap PTB from a route result. The caller must provide an input coin
589
- * obtained by splitting/merging wallet coins.
590
- *
591
- * **Important:** Cetus's `routerSwap` reads the overlay-fee config from the
592
- * AggregatorClient instance. The `overlayFee` param here MUST match the one
593
- * passed to `findSwapRoute` for the same swap (otherwise you'll hit the cache
594
- * boundary and get a different client with different overlay config).
595
- */
596
- declare function buildSwapTx(params: {
597
- walletAddress: string;
598
- route: SwapRouteResult;
599
- tx: Transaction;
600
- inputCoin: TransactionObjectArgument;
601
- slippage: number;
602
- overlayFee?: OverlayFeeConfig;
603
- }): Promise<TransactionObjectArgument>;
604
- /**
605
- * Append a swap fragment to an existing PTB. SPEC 7 § "Layer 1" Cetus
606
- * appender. Two modes, dispatched by the presence of `input.inputCoin`:
607
- *
608
- * - **Wallet mode** (`inputCoin` omitted) — fetches `from`-asset coins
609
- * from the sender's wallet (paginated), merges/splits to the
610
- * requested amount, runs the swap. Mirrors the audric host's
611
- * `transactions/prepare/route.ts` swap branch (P2.2c will retire that
612
- * branch in favor of this appender via `composeTx`).
613
- *
614
- * - **Chain mode** (`inputCoin` provided) — consumes the passed-in coin
615
- * reference (typically produced by an upstream appender like
616
- * `addWithdrawToTx`) directly, no wallet fetch / no merge / no
617
- * split. This is the SPEC 7 multi-write enabler ("withdraw → swap →
618
- * save" without intermediate wallet materialization).
619
- *
620
- * **SUI in wallet mode:** uses `client.getCoins` like every other
621
- * token. This works for sponsored flows (Enoki — `tx.gas` belongs to
622
- * the sponsor, swap input comes from the user's separate SUI coin
623
- * objects). For non-sponsored flows where `tx.gas` IS the user's SUI,
624
- * the caller should pre-build the inputCoin via
625
- * `tx.splitCoins(tx.gas, [rawAmount])[0]` and pass it via chain mode
626
- * instead. (`T2000.swap()` already handles this internally — direct SDK
627
- * users go through the high-level class, not through this appender.)
628
- *
629
- * **`swapAll` semantics (wallet mode):** if the requested raw amount
630
- * is >= the wallet's total `from` balance, the appender consumes the
631
- * entire merged primary coin (not a split), matching audric's host
632
- * route's `swapAll` clipping. The returned `effectiveAmountIn` reflects
633
- * the actual consumed amount in display units.
634
- *
635
- * **Slippage:** clamped to [0.001, 0.05] (0.1% – 5%). Defaults to 0.01.
636
- *
637
- * @returns
638
- * - `coin` — output coin reference, ready for downstream consumption
639
- * (e.g. `addSaveToTx`) or wallet transfer (`tx.transferObjects`).
640
- * - `effectiveAmountIn` — display-units input amount the swap actually
641
- * consumes (handles `swapAll` clipping in wallet mode; in chain mode
642
- * echoes the requested `input.amount`).
643
- * - `expectedAmountOut` — display-units output amount per the route
644
- * quote. Actual on-chain output may differ within slippage.
645
- * - `route` — raw `SwapRouteResult` for downstream telemetry / logging.
646
- */
647
- declare function addSwapToTx(tx: Transaction, client: SuiJsonRpcClient, address: string, input: {
648
- from: string;
649
- to: string;
650
- amount: number;
651
- slippage?: number;
652
- byAmountIn?: boolean;
653
- overlayFee?: OverlayFeeConfig;
654
- inputCoin?: TransactionObjectArgument;
655
- /**
656
- * Optional Cetus provider allow-list. Forwarded to `findSwapRoute`.
657
- * Sponsored flows (Enoki) MUST pass `getProvidersExcluding([...])`
658
- * to remove Pyth-dependent providers — see `findSwapRoute`'s JSDoc
659
- * for the exclusion list. Non-sponsored callers omit this.
660
- */
661
- providers?: string[];
662
- }): Promise<{
663
- coin: TransactionObjectArgument;
664
- effectiveAmountIn: number;
665
- expectedAmountOut: number;
666
- route: SwapRouteResult;
667
- }>;
668
-
669
525
  type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
670
526
  interface SafeguardErrorDetails {
671
527
  attempted?: number;
@@ -705,4 +561,4 @@ interface TxMetadata {
705
561
  declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
706
562
  declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
707
563
 
708
- 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, normalizeAsset as aJ, normalizeCoinType as aK, queryHistory as aL, queryTransaction as aM, simulateTransaction as aN, throwIfSimulationFailed as aO, 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 };
564
+ export { ZkLoginSigner 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 TransactionSigner as H, IKA_TYPE as I, type TxDirection 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, type TxMetadata as Q, USDC_TYPE as R, SAVE_FEE_BPS as S, T2000Error as T, USDC_DECIMALS as U, USDE_TYPE as V, USDSUI_TYPE as W, USDT_TYPE as X, WAL_TYPE as Y, WBTC_TYPE as Z, type ZkLoginProof as _, BPS_DENOMINATOR as a, addFeeTransfer as a0, calculateFee as a1, classifyAction as a2, classifyLabel as a3, classifyTransaction as a4, extractTransferDetails as a5, extractTxCommands as a6, extractTxSender as a7, fallbackLabel as a8, formatAssetAmount as a9, getCoinMeta as aA, isAllowedAsset as aB, isInRegistry as aC, normalizeAsset as aD, normalizeCoinType as aE, queryHistory as aF, queryTransaction as aG, simulateTransaction as aH, throwIfSimulationFailed as aI, formatSui as aa, formatUsd as ab, getDecimals as ac, getDecimalsForCoinType as ad, getTier as ae, isSupported as af, isTier1 as ag, isTier2 as ah, mapMoveAbortCode as ai, mapWalletError as aj, mistToSui as ak, parseSuiRpcTx as al, rawToStable as am, rawToUsdc as an, refineLendingLabel as ao, resolveSymbol as ap, resolveTokenType as aq, stableToRaw as ar, suiToMist as as, truncateAddress as at, usdcToRaw as au, validateAddress as av, CETUS_USDC_SUI_POOL as aw, OPERATION_ASSETS as ax, type Operation as ay, assertAllowedAsset 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, STABLE_ASSETS as k, SUI_DECIMALS as l, SUI_TYPE as m, SUPPORTED_ASSETS as n, type SafeguardConfig as o, SafeguardError as p, type SafeguardErrorDetails as q, type SafeguardRule as r, type SimulationResult as s, type StableAsset as t, type SuiRpcTxBlock as u, type SupportedAsset as v, type T2000ErrorCode as w, type T2000ErrorData as x, T2000_OVERLAY_FEE_WALLET as y, TOKEN_MAP as z };