@t2000/sdk 1.24.13 → 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.
- package/dist/adapters/index.d.cts +2 -1
- package/dist/adapters/index.d.ts +2 -1
- package/dist/browser.cjs +1 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +135 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +128 -14
- package/dist/index.js.map +1 -1
- package/dist/types-BaYOyGKJ.d.cts +509 -0
- package/dist/types-BaYOyGKJ.d.ts +509 -0
- package/dist/{types-D1-rO-J4.d.ts → types-Bheg9UZP.d.ts} +84 -228
- package/dist/{types-DvNhsBbN.d.cts → types-Cv9ZQ7KK.d.cts} +84 -228
- package/package.json +3 -1
- package/dist/types-jAD-e7Pq.d.cts +0 -254
- package/dist/types-jAD-e7Pq.d.ts +0 -254
|
@@ -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-
|
|
3
|
+
import { T as TransactionRecord } from './types-BaYOyGKJ.cjs';
|
|
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 {
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2000/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.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",
|
|
@@ -57,10 +57,12 @@
|
|
|
57
57
|
"@naviprotocol/lending": "^1.4.0",
|
|
58
58
|
"@pythnetwork/pyth-sui-js": "^2.4.0",
|
|
59
59
|
"@suimpp/mpp": "^0.3.1",
|
|
60
|
+
"bn.js": "^5.2.1",
|
|
60
61
|
"eventemitter3": "^5",
|
|
61
62
|
"mppx": "^0.4.9"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
65
|
+
"@types/bn.js": "^5.1.5",
|
|
64
66
|
"@types/node": "^20",
|
|
65
67
|
"eslint": "^9",
|
|
66
68
|
"tsup": "^8",
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
interface T2000Options {
|
|
2
|
-
keyPath?: string;
|
|
3
|
-
/** PIN to decrypt the key file. Accepts any string (4+ chars). */
|
|
4
|
-
pin?: string;
|
|
5
|
-
/** @deprecated Use `pin` instead. */
|
|
6
|
-
passphrase?: string;
|
|
7
|
-
network?: 'mainnet' | 'testnet';
|
|
8
|
-
rpcUrl?: string;
|
|
9
|
-
}
|
|
10
|
-
interface GasReserve {
|
|
11
|
-
sui: number;
|
|
12
|
-
usdEquiv: number;
|
|
13
|
-
}
|
|
14
|
-
interface BalanceResponse {
|
|
15
|
-
available: number;
|
|
16
|
-
savings: number;
|
|
17
|
-
debt: number;
|
|
18
|
-
pendingRewards: number;
|
|
19
|
-
gasReserve: GasReserve;
|
|
20
|
-
total: number;
|
|
21
|
-
stables: Record<string, number>;
|
|
22
|
-
}
|
|
23
|
-
interface SendResult {
|
|
24
|
-
success: boolean;
|
|
25
|
-
tx: string;
|
|
26
|
-
amount: number;
|
|
27
|
-
to: string;
|
|
28
|
-
contactName?: string;
|
|
29
|
-
gasCost: number;
|
|
30
|
-
gasCostUnit: string;
|
|
31
|
-
balance: BalanceResponse;
|
|
32
|
-
}
|
|
33
|
-
interface SaveResult {
|
|
34
|
-
success: boolean;
|
|
35
|
-
tx: string;
|
|
36
|
-
amount: number;
|
|
37
|
-
apy: number;
|
|
38
|
-
fee: number;
|
|
39
|
-
gasCost: number;
|
|
40
|
-
savingsBalance: number;
|
|
41
|
-
}
|
|
42
|
-
interface WithdrawResult {
|
|
43
|
-
success: boolean;
|
|
44
|
-
tx: string;
|
|
45
|
-
amount: number;
|
|
46
|
-
asset?: string;
|
|
47
|
-
gasCost: number;
|
|
48
|
-
}
|
|
49
|
-
interface BorrowResult {
|
|
50
|
-
success: boolean;
|
|
51
|
-
tx: string;
|
|
52
|
-
amount: number;
|
|
53
|
-
/** [v0.51.0] Asset borrowed — 'USDC' or 'USDsui'. Optional for backward compat. */
|
|
54
|
-
asset?: string;
|
|
55
|
-
fee: number;
|
|
56
|
-
healthFactor: number;
|
|
57
|
-
gasCost: number;
|
|
58
|
-
}
|
|
59
|
-
interface RepayResult {
|
|
60
|
-
success: boolean;
|
|
61
|
-
tx: string;
|
|
62
|
-
amount: number;
|
|
63
|
-
/** [v0.51.1] Asset repaid — 'USDC' or 'USDsui'. Optional for backward compat. */
|
|
64
|
-
asset?: string;
|
|
65
|
-
remainingDebt: number;
|
|
66
|
-
gasCost: number;
|
|
67
|
-
}
|
|
68
|
-
interface HealthFactorResult {
|
|
69
|
-
healthFactor: number;
|
|
70
|
-
supplied: number;
|
|
71
|
-
borrowed: number;
|
|
72
|
-
maxBorrow: number;
|
|
73
|
-
liquidationThreshold: number;
|
|
74
|
-
}
|
|
75
|
-
interface MaxWithdrawResult {
|
|
76
|
-
maxAmount: number;
|
|
77
|
-
healthFactorAfter: number;
|
|
78
|
-
currentHF: number;
|
|
79
|
-
}
|
|
80
|
-
interface MaxBorrowResult {
|
|
81
|
-
maxAmount: number;
|
|
82
|
-
healthFactorAfter: number;
|
|
83
|
-
currentHF: number;
|
|
84
|
-
}
|
|
85
|
-
interface AssetRates {
|
|
86
|
-
saveApy: number;
|
|
87
|
-
borrowApy: number;
|
|
88
|
-
}
|
|
89
|
-
interface RatesResult {
|
|
90
|
-
[asset: string]: AssetRates;
|
|
91
|
-
}
|
|
92
|
-
interface PositionEntry {
|
|
93
|
-
protocol: string;
|
|
94
|
-
asset: string;
|
|
95
|
-
type: 'save' | 'borrow';
|
|
96
|
-
amount: number;
|
|
97
|
-
amountUsd?: number;
|
|
98
|
-
apy: number;
|
|
99
|
-
}
|
|
100
|
-
interface PositionsResult {
|
|
101
|
-
positions: PositionEntry[];
|
|
102
|
-
}
|
|
103
|
-
interface EarningsResult {
|
|
104
|
-
totalYieldEarned: number;
|
|
105
|
-
currentApy: number;
|
|
106
|
-
dailyEarning: number;
|
|
107
|
-
supplied: number;
|
|
108
|
-
}
|
|
109
|
-
interface FundStatusResult {
|
|
110
|
-
supplied: number;
|
|
111
|
-
apy: number;
|
|
112
|
-
earnedToday: number;
|
|
113
|
-
earnedAllTime: number;
|
|
114
|
-
projectedMonthly: number;
|
|
115
|
-
}
|
|
116
|
-
interface DepositInfo {
|
|
117
|
-
address: string;
|
|
118
|
-
network: string;
|
|
119
|
-
supportedAssets: string[];
|
|
120
|
-
instructions: string;
|
|
121
|
-
}
|
|
122
|
-
interface PaymentRequest {
|
|
123
|
-
address: string;
|
|
124
|
-
network: string;
|
|
125
|
-
amount: number | null;
|
|
126
|
-
currency: string;
|
|
127
|
-
memo: string | null;
|
|
128
|
-
label: string | null;
|
|
129
|
-
/** Unique payment identifier (UUID) for Payment Kit registry */
|
|
130
|
-
nonce: string;
|
|
131
|
-
/** Payment Kit URI (sui:pay?...) for QR codes and wallet deep links */
|
|
132
|
-
qrUri: string;
|
|
133
|
-
/** Human-readable summary */
|
|
134
|
-
displayText: string;
|
|
135
|
-
}
|
|
136
|
-
interface TransactionRecord {
|
|
137
|
-
digest: string;
|
|
138
|
-
/** Coarse bucket — `'send' | 'lending' | 'swap' | 'transaction'`. STABLE. */
|
|
139
|
-
action: string;
|
|
140
|
-
/**
|
|
141
|
-
* Finer-grained display label derived from the Move-call function
|
|
142
|
-
* name (e.g. `'deposit'`, `'withdraw'`, `'payment_link'`,
|
|
143
|
-
* `'on-chain'`). Optional — frontends should fall back to `action`
|
|
144
|
-
* when missing. Never used by ACI filters.
|
|
145
|
-
*/
|
|
146
|
-
label?: string;
|
|
147
|
-
amount?: number;
|
|
148
|
-
asset?: string;
|
|
149
|
-
recipient?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Direction of the user's principal (non-gas) balance movement on
|
|
152
|
-
* this tx — `'out'` if they spent, `'in'` if they received.
|
|
153
|
-
* Computed from on-chain balance changes (NOT from `label`), so the
|
|
154
|
-
* card can render the correct sign even for opaque actions like
|
|
155
|
-
* `swap`/`router`. Undefined when no user balance change is
|
|
156
|
-
* detectable (e.g. pure read-only or admin txs).
|
|
157
|
-
*/
|
|
158
|
-
direction?: 'in' | 'out';
|
|
159
|
-
timestamp: number;
|
|
160
|
-
gasCost?: number;
|
|
161
|
-
}
|
|
162
|
-
interface PendingReward {
|
|
163
|
-
protocol: string;
|
|
164
|
-
asset: string;
|
|
165
|
-
coinType: string;
|
|
166
|
-
symbol: string;
|
|
167
|
-
amount: number;
|
|
168
|
-
estimatedValueUsd: number;
|
|
169
|
-
}
|
|
170
|
-
interface ClaimRewardsResult {
|
|
171
|
-
success: boolean;
|
|
172
|
-
tx: string;
|
|
173
|
-
rewards: PendingReward[];
|
|
174
|
-
totalValueUsd: number;
|
|
175
|
-
gasCost: number;
|
|
176
|
-
}
|
|
177
|
-
interface CompoundRewardsResult {
|
|
178
|
-
success: boolean;
|
|
179
|
-
claimTx: string;
|
|
180
|
-
swapTxs: string[];
|
|
181
|
-
depositTx: string;
|
|
182
|
-
rewards: PendingReward[];
|
|
183
|
-
totalCompoundedUsdc: number;
|
|
184
|
-
totalGasCost: number;
|
|
185
|
-
}
|
|
186
|
-
interface StakeVSuiResult {
|
|
187
|
-
success: boolean;
|
|
188
|
-
tx: string;
|
|
189
|
-
amountSui: number;
|
|
190
|
-
vSuiReceived: number;
|
|
191
|
-
apy: number;
|
|
192
|
-
gasCost: number;
|
|
193
|
-
}
|
|
194
|
-
interface UnstakeVSuiResult {
|
|
195
|
-
success: boolean;
|
|
196
|
-
tx: string;
|
|
197
|
-
vSuiAmount: number;
|
|
198
|
-
suiReceived: number;
|
|
199
|
-
gasCost: number;
|
|
200
|
-
}
|
|
201
|
-
interface SwapResult {
|
|
202
|
-
success: boolean;
|
|
203
|
-
tx: string;
|
|
204
|
-
fromToken: string;
|
|
205
|
-
toToken: string;
|
|
206
|
-
fromAmount: number;
|
|
207
|
-
toAmount: number;
|
|
208
|
-
priceImpact: number;
|
|
209
|
-
route: string;
|
|
210
|
-
gasCost: number;
|
|
211
|
-
}
|
|
212
|
-
interface SwapQuoteResult {
|
|
213
|
-
fromToken: string;
|
|
214
|
-
toToken: string;
|
|
215
|
-
fromAmount: number;
|
|
216
|
-
toAmount: number;
|
|
217
|
-
priceImpact: number;
|
|
218
|
-
route: string;
|
|
219
|
-
}
|
|
220
|
-
interface PayOptions {
|
|
221
|
-
url: string;
|
|
222
|
-
method?: string;
|
|
223
|
-
body?: string;
|
|
224
|
-
headers?: Record<string, string>;
|
|
225
|
-
maxPrice?: number;
|
|
226
|
-
}
|
|
227
|
-
interface PayResult {
|
|
228
|
-
status: number;
|
|
229
|
-
body: unknown;
|
|
230
|
-
paid: boolean;
|
|
231
|
-
cost?: number;
|
|
232
|
-
receipt?: {
|
|
233
|
-
reference: string;
|
|
234
|
-
timestamp: string;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
type HFAlertLevel = 'none' | 'warn' | 'critical';
|
|
238
|
-
interface FinancialSummary {
|
|
239
|
-
walletAddress: string;
|
|
240
|
-
usdcAvailable: number;
|
|
241
|
-
savingsBalance: number;
|
|
242
|
-
debtBalance: number;
|
|
243
|
-
idleUsdc: number;
|
|
244
|
-
healthFactor: number;
|
|
245
|
-
hfAlertLevel: HFAlertLevel;
|
|
246
|
-
saveApy: number;
|
|
247
|
-
borrowApy: number;
|
|
248
|
-
dailyYield: number;
|
|
249
|
-
gasReserveSui: number;
|
|
250
|
-
gasReserveUsd: number;
|
|
251
|
-
fetchedAt: number;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export type { AssetRates as A, BalanceResponse as B, ClaimRewardsResult as C, DepositInfo as D, EarningsResult as E, FundStatusResult as F, GasReserve as G, HealthFactorResult as H, MaxBorrowResult as M, PayOptions as P, RatesResult as R, SaveResult as S, TransactionRecord as T, UnstakeVSuiResult as U, WithdrawResult as W, BorrowResult as a, MaxWithdrawResult as b, PayResult as c, PendingReward as d, PositionEntry as e, PositionsResult as f, RepayResult as g, SendResult as h, T2000Options as i, StakeVSuiResult as j, SwapResult as k, SwapQuoteResult as l, PaymentRequest as m, CompoundRewardsResult as n, FinancialSummary as o, HFAlertLevel as p };
|