@t2000/sdk 1.0.1 → 1.1.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/README.md +15 -15
- package/dist/adapters/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/index.cjs +30 -42
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +7 -9
- package/dist/adapters/index.d.ts +7 -9
- package/dist/adapters/index.js +30 -42
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +194 -77
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -1
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +186 -74
- package/dist/browser.js.map +1 -1
- package/dist/{descriptors-CDVXo3BM.d.cts → descriptors-BnbL3xN8.d.cts} +11 -7
- package/dist/{descriptors-CDVXo3BM.d.ts → descriptors-BnbL3xN8.d.ts} +11 -7
- package/dist/index.cjs +85 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -50
- package/dist/index.d.ts +7 -50
- package/dist/index.js +84 -91
- package/dist/index.js.map +1 -1
- package/dist/{token-registry-DAHghHh2.d.cts → types-Bx0uh6g9.d.cts} +154 -45
- package/dist/{token-registry-CoTPqCbS.d.ts → types-CWnyOY9f.d.ts} +154 -45
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { T as TransactionRecord } from './types-jAD-e7Pq.cjs';
|
|
4
4
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
5
|
+
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Abstract signing interface that decouples the SDK from any specific
|
|
@@ -153,6 +154,7 @@ declare function isAllowedAsset(op: Operation, asset: string): boolean;
|
|
|
153
154
|
* Passing `undefined` (omitted) is always valid — defaults to USDC.
|
|
154
155
|
*/
|
|
155
156
|
declare function assertAllowedAsset(op: Operation, asset: string | undefined): void;
|
|
157
|
+
declare const T2000_OVERLAY_FEE_WALLET: string;
|
|
156
158
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
157
159
|
declare const CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
158
160
|
declare const GAS_RESERVE_MIN = 0.05;
|
|
@@ -381,59 +383,58 @@ interface SimulationResult {
|
|
|
381
383
|
declare function simulateTransaction(client: SuiJsonRpcClient, tx: Transaction, sender: string): Promise<SimulationResult>;
|
|
382
384
|
declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
383
385
|
|
|
384
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Protocol fee primitives — wallet-direct transfer model.
|
|
388
|
+
*
|
|
389
|
+
* [B5 v2 / @t2000/sdk@1.1.0 / 2026-04-30]
|
|
390
|
+
* Replaces the deprecated `t2000::treasury::collect_fee` Move call. Fees are now
|
|
391
|
+
* collected by splitting from the payment coin and transferring directly to the
|
|
392
|
+
* treasury wallet inside the same PTB. Atomic with the operation (PTB semantics);
|
|
393
|
+
* the wallet IS the ledger; the server-side indexer reads `balanceChanges` and
|
|
394
|
+
* writes a `ProtocolFeeLedger` row tagged with the operation classified from the
|
|
395
|
+
* tx's moveCall targets.
|
|
396
|
+
*
|
|
397
|
+
* The SDK / CLI never call this helper — they're fee-free by design (t2000 = infra
|
|
398
|
+
* brand, no opinion on fees). Audric's `prepare/route.ts` is the canonical caller.
|
|
399
|
+
*
|
|
400
|
+
* Pre-1.1.0 callers: `addCollectFeeToTx` and `reportFee` were removed in this
|
|
401
|
+
* release. Migration: replace `addCollectFeeToTx(tx, coin, op)` with
|
|
402
|
+
* `addFeeTransfer(tx, coin, FEE_BPS_FOR_OP, T2000_OVERLAY_FEE_WALLET)` BEFORE the
|
|
403
|
+
* NAVI deposit step (order matters — the deposit consumes the coin).
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
type FeeOperation = 'save' | 'borrow' | 'swap';
|
|
385
407
|
interface ProtocolFeeInfo {
|
|
386
408
|
amount: number;
|
|
387
409
|
asset: string;
|
|
388
410
|
rate: number;
|
|
389
411
|
rawAmount: bigint;
|
|
390
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Compute the fee amount for a given operation against a USD-denominated input.
|
|
415
|
+
* Used pre-tx for receipt display + quote math. Does not modify any tx.
|
|
416
|
+
*/
|
|
391
417
|
declare function calculateFee(operation: FeeOperation, amount: number): ProtocolFeeInfo;
|
|
392
418
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
419
|
+
* Split a fee from `paymentCoin` and transfer it to `receiver` inside the given PTB.
|
|
420
|
+
*
|
|
421
|
+
* **Order is load-bearing.** Call this BEFORE the protocol operation that consumes
|
|
422
|
+
* `paymentCoin` (e.g. NAVI deposit). `splitCoins` mutates the source coin in place,
|
|
423
|
+
* leaving the remainder for the protocol step. If you split AFTER the deposit,
|
|
424
|
+
* the deposit will have consumed the coin and the split will fail.
|
|
425
|
+
*
|
|
426
|
+
* Atomicity: `splitCoins` + `transferObjects` are PTB ops; if anything later in
|
|
427
|
+
* the PTB reverts, the fee transfer reverts too. Same atomicity guarantee as the
|
|
428
|
+
* deprecated `t2000::treasury::collect_fee` Move call.
|
|
429
|
+
*
|
|
430
|
+
* @param tx Active PTB
|
|
431
|
+
* @param paymentCoin Coin to split the fee from (mutated in place)
|
|
432
|
+
* @param feeBps Fee rate in basis points (e.g. `SAVE_FEE_BPS = 10n` = 0.1%)
|
|
433
|
+
* @param receiver Treasury wallet address (typically `T2000_OVERLAY_FEE_WALLET`)
|
|
434
|
+
* @param amount USD-denominated input amount (matches what was passed to the
|
|
435
|
+
* protocol operation; used to compute the raw fee amount)
|
|
396
436
|
*/
|
|
397
|
-
declare function
|
|
398
|
-
|
|
399
|
-
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
400
|
-
interface SafeguardErrorDetails {
|
|
401
|
-
attempted?: number;
|
|
402
|
-
limit?: number;
|
|
403
|
-
current?: number;
|
|
404
|
-
}
|
|
405
|
-
declare class SafeguardError extends T2000Error {
|
|
406
|
-
readonly rule: SafeguardRule;
|
|
407
|
-
readonly details: SafeguardErrorDetails;
|
|
408
|
-
constructor(rule: SafeguardRule, details: SafeguardErrorDetails, message?: string);
|
|
409
|
-
toJSON(): {
|
|
410
|
-
error: "SAFEGUARD_BLOCKED";
|
|
411
|
-
message: string;
|
|
412
|
-
retryable: boolean;
|
|
413
|
-
data: {
|
|
414
|
-
attempted?: number;
|
|
415
|
-
limit?: number;
|
|
416
|
-
current?: number;
|
|
417
|
-
rule: SafeguardRule;
|
|
418
|
-
};
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
interface SafeguardConfig {
|
|
423
|
-
locked: boolean;
|
|
424
|
-
maxPerTx: number;
|
|
425
|
-
maxDailySend: number;
|
|
426
|
-
dailyUsed: number;
|
|
427
|
-
dailyResetDate: string;
|
|
428
|
-
maxLeverage?: number;
|
|
429
|
-
maxPositionSize?: number;
|
|
430
|
-
}
|
|
431
|
-
interface TxMetadata {
|
|
432
|
-
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | 'pay';
|
|
433
|
-
amount?: number;
|
|
434
|
-
}
|
|
435
|
-
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
436
|
-
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
437
|
+
declare function addFeeTransfer(tx: Transaction, paymentCoin: TransactionObjectArgument, feeBps: bigint, receiver: string, amount: number): void;
|
|
437
438
|
|
|
438
439
|
/**
|
|
439
440
|
* Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
|
|
@@ -501,4 +502,112 @@ declare const IKA_TYPE: string;
|
|
|
501
502
|
declare const LOFI_TYPE: string;
|
|
502
503
|
declare const MANIFEST_TYPE: string;
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Cetus Aggregator V3 SDK wrapper — the ONLY file that imports @cetusprotocol/aggregator-sdk.
|
|
507
|
+
* Documented CLAUDE.md exception: multi-DEX routing cannot be feasibly replaced by thin tx builders.
|
|
508
|
+
*
|
|
509
|
+
* [B5 v2 / @t2000/sdk@1.1.0 / 2026-04-30]
|
|
510
|
+
* Overlay fee config is now per-call instead of a module-level singleton. CLI / direct
|
|
511
|
+
* SDK callers (`T2000.swap()`) DON'T pass `overlayFee` → fee-free swap. Audric's
|
|
512
|
+
* prepare/route.ts ALWAYS passes `overlayFee = { rate: OVERLAY_FEE_RATE, receiver:
|
|
513
|
+
* T2000_OVERLAY_FEE_WALLET }` → fee charged. Structural inclusion (Audric's code can't
|
|
514
|
+
* forget to pass it because it IS the code), not a toggle that defaults to safe.
|
|
515
|
+
*
|
|
516
|
+
* Pre-1.1.0: a module-level `OVERLAY_FEE_RECEIVER` constant defaulted to a Move object
|
|
517
|
+
* ID. USDC sent there became OwnedObjects keyed to the object and was inaccessible.
|
|
518
|
+
* Fixed by making the receiver a regular wallet address (T2000_OVERLAY_FEE_WALLET) AND
|
|
519
|
+
* by removing the singleton pattern that hid the misconfig.
|
|
520
|
+
*/
|
|
521
|
+
|
|
522
|
+
interface OverlayFeeConfig {
|
|
523
|
+
/** Fee rate as a fraction (e.g. 0.001 = 0.1%). Pass 0 to disable. */
|
|
524
|
+
rate: number;
|
|
525
|
+
/** Wallet address that receives the overlay fee. */
|
|
526
|
+
receiver: string;
|
|
527
|
+
}
|
|
528
|
+
interface SwapRouteResult {
|
|
529
|
+
routerData: RouterDataV3;
|
|
530
|
+
amountIn: string;
|
|
531
|
+
amountOut: string;
|
|
532
|
+
byAmountIn: boolean;
|
|
533
|
+
priceImpact: number;
|
|
534
|
+
insufficientLiquidity: boolean;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Default Audric swap overlay fee — 0.1%. Exported for consumers that want to use
|
|
538
|
+
* the canonical Audric rate (the Audric prepare-route does this). Changing this
|
|
539
|
+
* rate requires a coordinated SDK + audric release.
|
|
540
|
+
*/
|
|
541
|
+
declare const OVERLAY_FEE_RATE = 0.001;
|
|
542
|
+
/**
|
|
543
|
+
* Find the optimal swap route via Cetus Aggregator REST API.
|
|
544
|
+
*
|
|
545
|
+
* Pass `overlayFee` to charge an overlay fee on the output (Audric's pattern).
|
|
546
|
+
* Omit it for a fee-free swap (CLI / direct SDK pattern).
|
|
547
|
+
*/
|
|
548
|
+
declare function findSwapRoute(params: {
|
|
549
|
+
walletAddress: string;
|
|
550
|
+
from: string;
|
|
551
|
+
to: string;
|
|
552
|
+
amount: bigint;
|
|
553
|
+
byAmountIn: boolean;
|
|
554
|
+
overlayFee?: OverlayFeeConfig;
|
|
555
|
+
}): Promise<SwapRouteResult | null>;
|
|
556
|
+
/**
|
|
557
|
+
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
558
|
+
* obtained by splitting/merging wallet coins.
|
|
559
|
+
*
|
|
560
|
+
* **Important:** Cetus's `routerSwap` reads the overlay-fee config from the
|
|
561
|
+
* AggregatorClient instance. The `overlayFee` param here MUST match the one
|
|
562
|
+
* passed to `findSwapRoute` for the same swap (otherwise you'll hit the cache
|
|
563
|
+
* boundary and get a different client with different overlay config).
|
|
564
|
+
*/
|
|
565
|
+
declare function buildSwapTx(params: {
|
|
566
|
+
walletAddress: string;
|
|
567
|
+
route: SwapRouteResult;
|
|
568
|
+
tx: Transaction;
|
|
569
|
+
inputCoin: TransactionObjectArgument;
|
|
570
|
+
slippage: number;
|
|
571
|
+
overlayFee?: OverlayFeeConfig;
|
|
572
|
+
}): Promise<TransactionObjectArgument>;
|
|
573
|
+
|
|
574
|
+
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
575
|
+
interface SafeguardErrorDetails {
|
|
576
|
+
attempted?: number;
|
|
577
|
+
limit?: number;
|
|
578
|
+
current?: number;
|
|
579
|
+
}
|
|
580
|
+
declare class SafeguardError extends T2000Error {
|
|
581
|
+
readonly rule: SafeguardRule;
|
|
582
|
+
readonly details: SafeguardErrorDetails;
|
|
583
|
+
constructor(rule: SafeguardRule, details: SafeguardErrorDetails, message?: string);
|
|
584
|
+
toJSON(): {
|
|
585
|
+
error: "SAFEGUARD_BLOCKED";
|
|
586
|
+
message: string;
|
|
587
|
+
retryable: boolean;
|
|
588
|
+
data: {
|
|
589
|
+
attempted?: number;
|
|
590
|
+
limit?: number;
|
|
591
|
+
current?: number;
|
|
592
|
+
rule: SafeguardRule;
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
interface SafeguardConfig {
|
|
598
|
+
locked: boolean;
|
|
599
|
+
maxPerTx: number;
|
|
600
|
+
maxDailySend: number;
|
|
601
|
+
dailyUsed: number;
|
|
602
|
+
dailyResetDate: string;
|
|
603
|
+
maxLeverage?: number;
|
|
604
|
+
maxPositionSize?: number;
|
|
605
|
+
}
|
|
606
|
+
interface TxMetadata {
|
|
607
|
+
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | 'pay';
|
|
608
|
+
amount?: number;
|
|
609
|
+
}
|
|
610
|
+
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
611
|
+
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
612
|
+
|
|
613
|
+
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, assertAllowedAsset as aE, isAllowedAsset as aF, normalizeCoinType as aG, queryHistory as aH, queryTransaction as aI, simulateTransaction as aJ, throwIfSimulationFailed as aK, 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 };
|
|
@@ -2,6 +2,7 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { T as TransactionRecord } from './types-jAD-e7Pq.js';
|
|
4
4
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
5
|
+
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Abstract signing interface that decouples the SDK from any specific
|
|
@@ -153,6 +154,7 @@ declare function isAllowedAsset(op: Operation, asset: string): boolean;
|
|
|
153
154
|
* Passing `undefined` (omitted) is always valid — defaults to USDC.
|
|
154
155
|
*/
|
|
155
156
|
declare function assertAllowedAsset(op: Operation, asset: string | undefined): void;
|
|
157
|
+
declare const T2000_OVERLAY_FEE_WALLET: string;
|
|
156
158
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
157
159
|
declare const CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
158
160
|
declare const GAS_RESERVE_MIN = 0.05;
|
|
@@ -381,59 +383,58 @@ interface SimulationResult {
|
|
|
381
383
|
declare function simulateTransaction(client: SuiJsonRpcClient, tx: Transaction, sender: string): Promise<SimulationResult>;
|
|
382
384
|
declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
383
385
|
|
|
384
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Protocol fee primitives — wallet-direct transfer model.
|
|
388
|
+
*
|
|
389
|
+
* [B5 v2 / @t2000/sdk@1.1.0 / 2026-04-30]
|
|
390
|
+
* Replaces the deprecated `t2000::treasury::collect_fee` Move call. Fees are now
|
|
391
|
+
* collected by splitting from the payment coin and transferring directly to the
|
|
392
|
+
* treasury wallet inside the same PTB. Atomic with the operation (PTB semantics);
|
|
393
|
+
* the wallet IS the ledger; the server-side indexer reads `balanceChanges` and
|
|
394
|
+
* writes a `ProtocolFeeLedger` row tagged with the operation classified from the
|
|
395
|
+
* tx's moveCall targets.
|
|
396
|
+
*
|
|
397
|
+
* The SDK / CLI never call this helper — they're fee-free by design (t2000 = infra
|
|
398
|
+
* brand, no opinion on fees). Audric's `prepare/route.ts` is the canonical caller.
|
|
399
|
+
*
|
|
400
|
+
* Pre-1.1.0 callers: `addCollectFeeToTx` and `reportFee` were removed in this
|
|
401
|
+
* release. Migration: replace `addCollectFeeToTx(tx, coin, op)` with
|
|
402
|
+
* `addFeeTransfer(tx, coin, FEE_BPS_FOR_OP, T2000_OVERLAY_FEE_WALLET)` BEFORE the
|
|
403
|
+
* NAVI deposit step (order matters — the deposit consumes the coin).
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
type FeeOperation = 'save' | 'borrow' | 'swap';
|
|
385
407
|
interface ProtocolFeeInfo {
|
|
386
408
|
amount: number;
|
|
387
409
|
asset: string;
|
|
388
410
|
rate: number;
|
|
389
411
|
rawAmount: bigint;
|
|
390
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Compute the fee amount for a given operation against a USD-denominated input.
|
|
415
|
+
* Used pre-tx for receipt display + quote math. Does not modify any tx.
|
|
416
|
+
*/
|
|
391
417
|
declare function calculateFee(operation: FeeOperation, amount: number): ProtocolFeeInfo;
|
|
392
418
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
419
|
+
* Split a fee from `paymentCoin` and transfer it to `receiver` inside the given PTB.
|
|
420
|
+
*
|
|
421
|
+
* **Order is load-bearing.** Call this BEFORE the protocol operation that consumes
|
|
422
|
+
* `paymentCoin` (e.g. NAVI deposit). `splitCoins` mutates the source coin in place,
|
|
423
|
+
* leaving the remainder for the protocol step. If you split AFTER the deposit,
|
|
424
|
+
* the deposit will have consumed the coin and the split will fail.
|
|
425
|
+
*
|
|
426
|
+
* Atomicity: `splitCoins` + `transferObjects` are PTB ops; if anything later in
|
|
427
|
+
* the PTB reverts, the fee transfer reverts too. Same atomicity guarantee as the
|
|
428
|
+
* deprecated `t2000::treasury::collect_fee` Move call.
|
|
429
|
+
*
|
|
430
|
+
* @param tx Active PTB
|
|
431
|
+
* @param paymentCoin Coin to split the fee from (mutated in place)
|
|
432
|
+
* @param feeBps Fee rate in basis points (e.g. `SAVE_FEE_BPS = 10n` = 0.1%)
|
|
433
|
+
* @param receiver Treasury wallet address (typically `T2000_OVERLAY_FEE_WALLET`)
|
|
434
|
+
* @param amount USD-denominated input amount (matches what was passed to the
|
|
435
|
+
* protocol operation; used to compute the raw fee amount)
|
|
396
436
|
*/
|
|
397
|
-
declare function
|
|
398
|
-
|
|
399
|
-
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
400
|
-
interface SafeguardErrorDetails {
|
|
401
|
-
attempted?: number;
|
|
402
|
-
limit?: number;
|
|
403
|
-
current?: number;
|
|
404
|
-
}
|
|
405
|
-
declare class SafeguardError extends T2000Error {
|
|
406
|
-
readonly rule: SafeguardRule;
|
|
407
|
-
readonly details: SafeguardErrorDetails;
|
|
408
|
-
constructor(rule: SafeguardRule, details: SafeguardErrorDetails, message?: string);
|
|
409
|
-
toJSON(): {
|
|
410
|
-
error: "SAFEGUARD_BLOCKED";
|
|
411
|
-
message: string;
|
|
412
|
-
retryable: boolean;
|
|
413
|
-
data: {
|
|
414
|
-
attempted?: number;
|
|
415
|
-
limit?: number;
|
|
416
|
-
current?: number;
|
|
417
|
-
rule: SafeguardRule;
|
|
418
|
-
};
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
interface SafeguardConfig {
|
|
423
|
-
locked: boolean;
|
|
424
|
-
maxPerTx: number;
|
|
425
|
-
maxDailySend: number;
|
|
426
|
-
dailyUsed: number;
|
|
427
|
-
dailyResetDate: string;
|
|
428
|
-
maxLeverage?: number;
|
|
429
|
-
maxPositionSize?: number;
|
|
430
|
-
}
|
|
431
|
-
interface TxMetadata {
|
|
432
|
-
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | 'pay';
|
|
433
|
-
amount?: number;
|
|
434
|
-
}
|
|
435
|
-
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
436
|
-
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
437
|
+
declare function addFeeTransfer(tx: Transaction, paymentCoin: TransactionObjectArgument, feeBps: bigint, receiver: string, amount: number): void;
|
|
437
438
|
|
|
438
439
|
/**
|
|
439
440
|
* Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
|
|
@@ -501,4 +502,112 @@ declare const IKA_TYPE: string;
|
|
|
501
502
|
declare const LOFI_TYPE: string;
|
|
502
503
|
declare const MANIFEST_TYPE: string;
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Cetus Aggregator V3 SDK wrapper — the ONLY file that imports @cetusprotocol/aggregator-sdk.
|
|
507
|
+
* Documented CLAUDE.md exception: multi-DEX routing cannot be feasibly replaced by thin tx builders.
|
|
508
|
+
*
|
|
509
|
+
* [B5 v2 / @t2000/sdk@1.1.0 / 2026-04-30]
|
|
510
|
+
* Overlay fee config is now per-call instead of a module-level singleton. CLI / direct
|
|
511
|
+
* SDK callers (`T2000.swap()`) DON'T pass `overlayFee` → fee-free swap. Audric's
|
|
512
|
+
* prepare/route.ts ALWAYS passes `overlayFee = { rate: OVERLAY_FEE_RATE, receiver:
|
|
513
|
+
* T2000_OVERLAY_FEE_WALLET }` → fee charged. Structural inclusion (Audric's code can't
|
|
514
|
+
* forget to pass it because it IS the code), not a toggle that defaults to safe.
|
|
515
|
+
*
|
|
516
|
+
* Pre-1.1.0: a module-level `OVERLAY_FEE_RECEIVER` constant defaulted to a Move object
|
|
517
|
+
* ID. USDC sent there became OwnedObjects keyed to the object and was inaccessible.
|
|
518
|
+
* Fixed by making the receiver a regular wallet address (T2000_OVERLAY_FEE_WALLET) AND
|
|
519
|
+
* by removing the singleton pattern that hid the misconfig.
|
|
520
|
+
*/
|
|
521
|
+
|
|
522
|
+
interface OverlayFeeConfig {
|
|
523
|
+
/** Fee rate as a fraction (e.g. 0.001 = 0.1%). Pass 0 to disable. */
|
|
524
|
+
rate: number;
|
|
525
|
+
/** Wallet address that receives the overlay fee. */
|
|
526
|
+
receiver: string;
|
|
527
|
+
}
|
|
528
|
+
interface SwapRouteResult {
|
|
529
|
+
routerData: RouterDataV3;
|
|
530
|
+
amountIn: string;
|
|
531
|
+
amountOut: string;
|
|
532
|
+
byAmountIn: boolean;
|
|
533
|
+
priceImpact: number;
|
|
534
|
+
insufficientLiquidity: boolean;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Default Audric swap overlay fee — 0.1%. Exported for consumers that want to use
|
|
538
|
+
* the canonical Audric rate (the Audric prepare-route does this). Changing this
|
|
539
|
+
* rate requires a coordinated SDK + audric release.
|
|
540
|
+
*/
|
|
541
|
+
declare const OVERLAY_FEE_RATE = 0.001;
|
|
542
|
+
/**
|
|
543
|
+
* Find the optimal swap route via Cetus Aggregator REST API.
|
|
544
|
+
*
|
|
545
|
+
* Pass `overlayFee` to charge an overlay fee on the output (Audric's pattern).
|
|
546
|
+
* Omit it for a fee-free swap (CLI / direct SDK pattern).
|
|
547
|
+
*/
|
|
548
|
+
declare function findSwapRoute(params: {
|
|
549
|
+
walletAddress: string;
|
|
550
|
+
from: string;
|
|
551
|
+
to: string;
|
|
552
|
+
amount: bigint;
|
|
553
|
+
byAmountIn: boolean;
|
|
554
|
+
overlayFee?: OverlayFeeConfig;
|
|
555
|
+
}): Promise<SwapRouteResult | null>;
|
|
556
|
+
/**
|
|
557
|
+
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
558
|
+
* obtained by splitting/merging wallet coins.
|
|
559
|
+
*
|
|
560
|
+
* **Important:** Cetus's `routerSwap` reads the overlay-fee config from the
|
|
561
|
+
* AggregatorClient instance. The `overlayFee` param here MUST match the one
|
|
562
|
+
* passed to `findSwapRoute` for the same swap (otherwise you'll hit the cache
|
|
563
|
+
* boundary and get a different client with different overlay config).
|
|
564
|
+
*/
|
|
565
|
+
declare function buildSwapTx(params: {
|
|
566
|
+
walletAddress: string;
|
|
567
|
+
route: SwapRouteResult;
|
|
568
|
+
tx: Transaction;
|
|
569
|
+
inputCoin: TransactionObjectArgument;
|
|
570
|
+
slippage: number;
|
|
571
|
+
overlayFee?: OverlayFeeConfig;
|
|
572
|
+
}): Promise<TransactionObjectArgument>;
|
|
573
|
+
|
|
574
|
+
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
575
|
+
interface SafeguardErrorDetails {
|
|
576
|
+
attempted?: number;
|
|
577
|
+
limit?: number;
|
|
578
|
+
current?: number;
|
|
579
|
+
}
|
|
580
|
+
declare class SafeguardError extends T2000Error {
|
|
581
|
+
readonly rule: SafeguardRule;
|
|
582
|
+
readonly details: SafeguardErrorDetails;
|
|
583
|
+
constructor(rule: SafeguardRule, details: SafeguardErrorDetails, message?: string);
|
|
584
|
+
toJSON(): {
|
|
585
|
+
error: "SAFEGUARD_BLOCKED";
|
|
586
|
+
message: string;
|
|
587
|
+
retryable: boolean;
|
|
588
|
+
data: {
|
|
589
|
+
attempted?: number;
|
|
590
|
+
limit?: number;
|
|
591
|
+
current?: number;
|
|
592
|
+
rule: SafeguardRule;
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
interface SafeguardConfig {
|
|
598
|
+
locked: boolean;
|
|
599
|
+
maxPerTx: number;
|
|
600
|
+
maxDailySend: number;
|
|
601
|
+
dailyUsed: number;
|
|
602
|
+
dailyResetDate: string;
|
|
603
|
+
maxLeverage?: number;
|
|
604
|
+
maxPositionSize?: number;
|
|
605
|
+
}
|
|
606
|
+
interface TxMetadata {
|
|
607
|
+
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | 'pay';
|
|
608
|
+
amount?: number;
|
|
609
|
+
}
|
|
610
|
+
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
|
|
611
|
+
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
612
|
+
|
|
613
|
+
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, assertAllowedAsset as aE, isAllowedAsset as aF, normalizeCoinType as aG, queryHistory as aH, queryTransaction as aI, simulateTransaction as aJ, throwIfSimulationFailed as aK, extractTxCommands as aa, extractTxSender as ab, fallbackLabel as ac, findSwapRoute as ad, formatAssetAmount as ae, formatSui as af, formatUsd as ag, getDecimals as ah, getDecimalsForCoinType as ai, getTier as aj, isSupported as ak, isTier1 as al, isTier2 as am, mapMoveAbortCode as an, mapWalletError as ao, mistToSui as ap, parseSuiRpcTx as aq, rawToStable as ar, rawToUsdc as as, refineLendingLabel as at, resolveSymbol as au, resolveTokenType as av, stableToRaw as aw, suiToMist as ax, truncateAddress as ay, usdcToRaw as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, OVERLAY_FEE_RATE as k, type OverlayFeeConfig as l, STABLE_ASSETS as m, SUI_DECIMALS as n, SUI_TYPE as o, SUPPORTED_ASSETS as p, type SafeguardConfig as q, SafeguardError as r, type SafeguardErrorDetails as s, type SafeguardRule as t, type SimulationResult as u, type StableAsset as v, type SuiRpcTxBlock as w, type SupportedAsset as x, type SwapRouteResult as y, type T2000ErrorCode as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2000/sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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",
|