@t2000/sdk 3.2.0 → 4.0.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,6 +1,7 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- import { T as TransactionLeg, k as TransactionRecord } from './types-Bk7NncQ_.js';
3
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
4
+ import { T as TransactionLeg, k as TransactionRecord } from './types-HJGbXJ37.cjs';
4
5
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
6
 
6
7
  /**
@@ -67,7 +68,7 @@ declare class ZkLoginSigner implements TransactionSigner {
67
68
  isExpired(currentEpoch: number): boolean;
68
69
  }
69
70
 
70
- type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
71
+ type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'WALLET_CORRUPT' | 'INVALID_KEY' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
71
72
  interface T2000ErrorData {
72
73
  reason?: string;
73
74
  [key: string]: unknown;
@@ -161,21 +162,71 @@ declare const OPERATION_ASSETS: {
161
162
  readonly borrow: readonly ["USDC", "USDsui"];
162
163
  readonly withdraw: "*";
163
164
  readonly repay: "*";
164
- readonly send: "*";
165
+ readonly send: readonly ["USDC", "USDsui", "SUI"];
165
166
  readonly swap: "*";
166
167
  };
167
168
  type Operation = keyof typeof OPERATION_ASSETS;
168
169
  declare function isAllowedAsset(op: Operation, asset: string): boolean;
169
170
  /**
170
171
  * Throws if the asset is not permitted for the given operation.
171
- * Passing `undefined` (omitted) is always valid — defaults to USDC.
172
+ *
173
+ * [v4.0 Phase A Day 2] Pre-v4 this allowed `undefined` as a silent default
174
+ * to USDC. Removed because every write path now requires explicit asset
175
+ * (see `T2000.send` + `buildSendTx` + `composeTx.send_transfer`). Save /
176
+ * borrow / repay still call this with `params.asset` (which may be
177
+ * undefined when the caller relies on the per-method `?? 'USDC'` default
178
+ * before this assertion fires), so the `undefined → no-op` branch stays
179
+ * for back-compat; the `send_transfer` flow validates non-undefined.
172
180
  */
173
181
  declare function assertAllowedAsset(op: Operation, asset: string | undefined): void;
182
+ /**
183
+ * [v4.0 Phase A Day 2] Narrow type alias for assets sendable through the
184
+ * Agent Wallet. Matches `OPERATION_ASSETS.send` exactly. Exported so the
185
+ * CLI / SDK / composeTx can share one type without re-declaring it.
186
+ */
187
+ type SendableAsset = 'USDC' | 'USDsui' | 'SUI';
188
+ declare const SENDABLE_ASSETS: readonly SendableAsset[];
189
+ /**
190
+ * [v4.0 Phase A Day 2] Coin types for the two gasless-allowlisted stables.
191
+ * Used by `wallet/send.ts` + `composeTx.send_transfer` to construct the
192
+ * `0x2::balance::send_funds` Move call's `typeArguments`. SUI is excluded
193
+ * because SUI transfers are NOT gasless (gas-native, uses `tx.gas` split +
194
+ * `transferObjects` per the existing path).
195
+ */
196
+ declare const GASLESS_STABLE_TYPES: Record<'USDC' | 'USDsui', string>;
174
197
  declare const T2000_OVERLAY_FEE_WALLET: string;
175
198
  declare const DEFAULT_NETWORK: "mainnet";
199
+ declare const DEFAULT_GRPC_URL = "https://fullnode.mainnet.sui.io:443";
200
+ declare const GASLESS_MIN_STABLE_AMOUNT = 0.01;
176
201
  declare const CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
177
202
  declare const GAS_RESERVE_MIN = 0.05;
178
203
 
204
+ declare function getSuiClient(rpcUrl?: string): SuiJsonRpcClient;
205
+ declare function createSuiClient(network?: 'mainnet' | 'testnet'): SuiJsonRpcClient;
206
+ /**
207
+ * Cached `SuiGrpcClient` for gasless stablecoin transfer builds.
208
+ *
209
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
210
+ *
211
+ * Why this exists: Sui mainnet's protocol-level gasless stablecoin transfers
212
+ * (`0x2::balance::send_funds` on the USDC + USDsui allowlist) are detected
213
+ * ONLY when the transaction is built through a `SuiGrpcClient`. The gRPC
214
+ * client's build resolver inspects the PTB at `tx.build()` time and, if it
215
+ * matches the gasless pattern, sets `gasPrice=0` + `gasBudget=0` automatically.
216
+ * Building the SAME PTB through `SuiJsonRpcClient` produces the same bytes
217
+ * but with non-zero gas — the tx still works, but the user pays SUI gas.
218
+ *
219
+ * Execution stays on JSON-RPC (`SuiJsonRpcClient.executeTransactionBlock`)
220
+ * because (a) the rest of the SDK expects JSON-RPC and (b) Sui's docs
221
+ * explicitly support a "build via gRPC, execute via JSON-RPC" hybrid:
222
+ * https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers
223
+ *
224
+ * Override the endpoint with the `T2000_GRPC_URL` env var or the
225
+ * `grpcUrl` arg. Cache is keyed by URL so multiple endpoints can
226
+ * co-exist (e.g., the rare testnet smoke + production usage from the
227
+ * same process).
228
+ */
229
+ declare function getSuiGrpcClient(grpcUrl?: string): SuiGrpcClient;
179
230
  declare function validateAddress(address: string): string;
180
231
  declare function truncateAddress(address: string): string;
181
232
  /**
@@ -597,4 +648,4 @@ interface TxMetadata {
597
648
  declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
598
649
  declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
599
650
 
600
- 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, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, SAVEABLE_ASSETS as aA, type SaveableAsset as aB, assertAllowedAsset as aC, getCoinMeta as aD, isAllowedAsset as aE, isInRegistry as aF, normalizeAsset as aG, normalizeCoinType as aH, queryHistory as aI, queryTransaction as aJ, simulateTransaction as aK, throwIfSimulationFailed as aL, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, CETUS_USDC_SUI_POOL as ax, OPERATION_ASSETS as ay, type Operation 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 };
651
+ 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, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, GASLESS_MIN_STABLE_AMOUNT as aA, GASLESS_STABLE_TYPES as aB, OPERATION_ASSETS as aC, type Operation as aD, SAVEABLE_ASSETS as aE, SENDABLE_ASSETS as aF, type SaveableAsset as aG, assertAllowedAsset as aH, createSuiClient as aI, getCoinMeta as aJ, getSuiClient as aK, getSuiGrpcClient as aL, isAllowedAsset as aM, isInRegistry as aN, normalizeAsset as aO, normalizeCoinType as aP, queryHistory as aQ, queryTransaction as aR, simulateTransaction as aS, throwIfSimulationFailed as aT, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, type SendableAsset as ax, CETUS_USDC_SUI_POOL as ay, DEFAULT_GRPC_URL 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 };
@@ -494,21 +494,6 @@ interface CompoundRewardsResult {
494
494
  totalCompoundedUsdc: number;
495
495
  totalGasCost: number;
496
496
  }
497
- interface StakeVSuiResult {
498
- success: boolean;
499
- tx: string;
500
- amountSui: number;
501
- vSuiReceived: number;
502
- apy: number;
503
- gasCost: number;
504
- }
505
- interface UnstakeVSuiResult {
506
- success: boolean;
507
- tx: string;
508
- vSuiAmount: number;
509
- suiReceived: number;
510
- gasCost: number;
511
- }
512
497
  interface SwapResult {
513
498
  success: boolean;
514
499
  tx: string;
@@ -579,4 +564,4 @@ interface FinancialSummary {
579
564
  fetchedAt: number;
580
565
  }
581
566
 
582
- export { type AssetRates as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasReserve as G, type HealthFactorResult as H, isCetusRouteFresh as I, serializeCetusRoute as J, verifyCetusRouteCoinMatch as K, type MaxBorrowResult as M, OVERLAY_FEE_RATE as O, type PayOptions as P, type RatesResult as R, type SaveResult as S, type TransactionLeg as T, type UnstakeVSuiResult as U, type WithdrawResult as W, type BorrowResult as a, type MaxWithdrawResult as b, type OverlayFeeConfig as c, type PayResult as d, type PendingReward as e, type PositionEntry as f, type PositionsResult as g, type RepayResult as h, type SendResult as i, type SwapRouteResult as j, type TransactionRecord as k, buildSwapTx as l, findSwapRoute as m, type T2000Options as n, type StakeVSuiResult as o, type SwapResult as p, type SwapQuoteResult as q, type PaymentRequest as r, type CompoundRewardsResult as s, type FinancialSummary as t, type HFAlertLevel as u, type SerializedCetusRoute as v, type SerializedCetusRoutePath as w, type SerializedRouterDataV3 as x, addSwapToTx as y, deserializeCetusRoute as z };
567
+ export { type AssetRates as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasReserve as G, type HealthFactorResult as H, serializeCetusRoute as I, verifyCetusRouteCoinMatch as J, type MaxBorrowResult as M, OVERLAY_FEE_RATE as O, type PayOptions as P, type RatesResult as R, type SaveResult as S, type TransactionLeg as T, type WithdrawResult as W, type BorrowResult as a, type MaxWithdrawResult as b, type OverlayFeeConfig as c, type PayResult as d, type PendingReward as e, type PositionEntry as f, type PositionsResult as g, type RepayResult as h, type SendResult as i, type SwapRouteResult as j, type TransactionRecord as k, buildSwapTx as l, findSwapRoute as m, type T2000Options as n, type SwapResult as o, type SwapQuoteResult as p, type PaymentRequest as q, type CompoundRewardsResult as r, type FinancialSummary as s, type HFAlertLevel as t, type SerializedCetusRoute as u, type SerializedCetusRoutePath as v, type SerializedRouterDataV3 as w, addSwapToTx as x, deserializeCetusRoute as y, isCetusRouteFresh as z };
@@ -494,21 +494,6 @@ interface CompoundRewardsResult {
494
494
  totalCompoundedUsdc: number;
495
495
  totalGasCost: number;
496
496
  }
497
- interface StakeVSuiResult {
498
- success: boolean;
499
- tx: string;
500
- amountSui: number;
501
- vSuiReceived: number;
502
- apy: number;
503
- gasCost: number;
504
- }
505
- interface UnstakeVSuiResult {
506
- success: boolean;
507
- tx: string;
508
- vSuiAmount: number;
509
- suiReceived: number;
510
- gasCost: number;
511
- }
512
497
  interface SwapResult {
513
498
  success: boolean;
514
499
  tx: string;
@@ -579,4 +564,4 @@ interface FinancialSummary {
579
564
  fetchedAt: number;
580
565
  }
581
566
 
582
- export { type AssetRates as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasReserve as G, type HealthFactorResult as H, isCetusRouteFresh as I, serializeCetusRoute as J, verifyCetusRouteCoinMatch as K, type MaxBorrowResult as M, OVERLAY_FEE_RATE as O, type PayOptions as P, type RatesResult as R, type SaveResult as S, type TransactionLeg as T, type UnstakeVSuiResult as U, type WithdrawResult as W, type BorrowResult as a, type MaxWithdrawResult as b, type OverlayFeeConfig as c, type PayResult as d, type PendingReward as e, type PositionEntry as f, type PositionsResult as g, type RepayResult as h, type SendResult as i, type SwapRouteResult as j, type TransactionRecord as k, buildSwapTx as l, findSwapRoute as m, type T2000Options as n, type StakeVSuiResult as o, type SwapResult as p, type SwapQuoteResult as q, type PaymentRequest as r, type CompoundRewardsResult as s, type FinancialSummary as t, type HFAlertLevel as u, type SerializedCetusRoute as v, type SerializedCetusRoutePath as w, type SerializedRouterDataV3 as x, addSwapToTx as y, deserializeCetusRoute as z };
567
+ export { type AssetRates as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasReserve as G, type HealthFactorResult as H, serializeCetusRoute as I, verifyCetusRouteCoinMatch as J, type MaxBorrowResult as M, OVERLAY_FEE_RATE as O, type PayOptions as P, type RatesResult as R, type SaveResult as S, type TransactionLeg as T, type WithdrawResult as W, type BorrowResult as a, type MaxWithdrawResult as b, type OverlayFeeConfig as c, type PayResult as d, type PendingReward as e, type PositionEntry as f, type PositionsResult as g, type RepayResult as h, type SendResult as i, type SwapRouteResult as j, type TransactionRecord as k, buildSwapTx as l, findSwapRoute as m, type T2000Options as n, type SwapResult as o, type SwapQuoteResult as p, type PaymentRequest as q, type CompoundRewardsResult as r, type FinancialSummary as s, type HFAlertLevel as t, type SerializedCetusRoute as u, type SerializedCetusRoutePath as v, type SerializedRouterDataV3 as w, addSwapToTx as x, deserializeCetusRoute as y, isCetusRouteFresh as z };
@@ -1,6 +1,7 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- import { T as TransactionLeg, k as TransactionRecord } from './types-Bk7NncQ_.cjs';
3
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
4
+ import { T as TransactionLeg, k as TransactionRecord } from './types-HJGbXJ37.js';
4
5
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
6
 
6
7
  /**
@@ -67,7 +68,7 @@ declare class ZkLoginSigner implements TransactionSigner {
67
68
  isExpired(currentEpoch: number): boolean;
68
69
  }
69
70
 
70
- type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
71
+ type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'WALLET_CORRUPT' | 'INVALID_KEY' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
71
72
  interface T2000ErrorData {
72
73
  reason?: string;
73
74
  [key: string]: unknown;
@@ -161,21 +162,71 @@ declare const OPERATION_ASSETS: {
161
162
  readonly borrow: readonly ["USDC", "USDsui"];
162
163
  readonly withdraw: "*";
163
164
  readonly repay: "*";
164
- readonly send: "*";
165
+ readonly send: readonly ["USDC", "USDsui", "SUI"];
165
166
  readonly swap: "*";
166
167
  };
167
168
  type Operation = keyof typeof OPERATION_ASSETS;
168
169
  declare function isAllowedAsset(op: Operation, asset: string): boolean;
169
170
  /**
170
171
  * Throws if the asset is not permitted for the given operation.
171
- * Passing `undefined` (omitted) is always valid — defaults to USDC.
172
+ *
173
+ * [v4.0 Phase A Day 2] Pre-v4 this allowed `undefined` as a silent default
174
+ * to USDC. Removed because every write path now requires explicit asset
175
+ * (see `T2000.send` + `buildSendTx` + `composeTx.send_transfer`). Save /
176
+ * borrow / repay still call this with `params.asset` (which may be
177
+ * undefined when the caller relies on the per-method `?? 'USDC'` default
178
+ * before this assertion fires), so the `undefined → no-op` branch stays
179
+ * for back-compat; the `send_transfer` flow validates non-undefined.
172
180
  */
173
181
  declare function assertAllowedAsset(op: Operation, asset: string | undefined): void;
182
+ /**
183
+ * [v4.0 Phase A Day 2] Narrow type alias for assets sendable through the
184
+ * Agent Wallet. Matches `OPERATION_ASSETS.send` exactly. Exported so the
185
+ * CLI / SDK / composeTx can share one type without re-declaring it.
186
+ */
187
+ type SendableAsset = 'USDC' | 'USDsui' | 'SUI';
188
+ declare const SENDABLE_ASSETS: readonly SendableAsset[];
189
+ /**
190
+ * [v4.0 Phase A Day 2] Coin types for the two gasless-allowlisted stables.
191
+ * Used by `wallet/send.ts` + `composeTx.send_transfer` to construct the
192
+ * `0x2::balance::send_funds` Move call's `typeArguments`. SUI is excluded
193
+ * because SUI transfers are NOT gasless (gas-native, uses `tx.gas` split +
194
+ * `transferObjects` per the existing path).
195
+ */
196
+ declare const GASLESS_STABLE_TYPES: Record<'USDC' | 'USDsui', string>;
174
197
  declare const T2000_OVERLAY_FEE_WALLET: string;
175
198
  declare const DEFAULT_NETWORK: "mainnet";
199
+ declare const DEFAULT_GRPC_URL = "https://fullnode.mainnet.sui.io:443";
200
+ declare const GASLESS_MIN_STABLE_AMOUNT = 0.01;
176
201
  declare const CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
177
202
  declare const GAS_RESERVE_MIN = 0.05;
178
203
 
204
+ declare function getSuiClient(rpcUrl?: string): SuiJsonRpcClient;
205
+ declare function createSuiClient(network?: 'mainnet' | 'testnet'): SuiJsonRpcClient;
206
+ /**
207
+ * Cached `SuiGrpcClient` for gasless stablecoin transfer builds.
208
+ *
209
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
210
+ *
211
+ * Why this exists: Sui mainnet's protocol-level gasless stablecoin transfers
212
+ * (`0x2::balance::send_funds` on the USDC + USDsui allowlist) are detected
213
+ * ONLY when the transaction is built through a `SuiGrpcClient`. The gRPC
214
+ * client's build resolver inspects the PTB at `tx.build()` time and, if it
215
+ * matches the gasless pattern, sets `gasPrice=0` + `gasBudget=0` automatically.
216
+ * Building the SAME PTB through `SuiJsonRpcClient` produces the same bytes
217
+ * but with non-zero gas — the tx still works, but the user pays SUI gas.
218
+ *
219
+ * Execution stays on JSON-RPC (`SuiJsonRpcClient.executeTransactionBlock`)
220
+ * because (a) the rest of the SDK expects JSON-RPC and (b) Sui's docs
221
+ * explicitly support a "build via gRPC, execute via JSON-RPC" hybrid:
222
+ * https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers
223
+ *
224
+ * Override the endpoint with the `T2000_GRPC_URL` env var or the
225
+ * `grpcUrl` arg. Cache is keyed by URL so multiple endpoints can
226
+ * co-exist (e.g., the rare testnet smoke + production usage from the
227
+ * same process).
228
+ */
229
+ declare function getSuiGrpcClient(grpcUrl?: string): SuiGrpcClient;
179
230
  declare function validateAddress(address: string): string;
180
231
  declare function truncateAddress(address: string): string;
181
232
  /**
@@ -597,4 +648,4 @@ interface TxMetadata {
597
648
  declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
598
649
  declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
599
650
 
600
- 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, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, SAVEABLE_ASSETS as aA, type SaveableAsset as aB, assertAllowedAsset as aC, getCoinMeta as aD, isAllowedAsset as aE, isInRegistry as aF, normalizeAsset as aG, normalizeCoinType as aH, queryHistory as aI, queryTransaction as aJ, simulateTransaction as aK, throwIfSimulationFailed as aL, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, CETUS_USDC_SUI_POOL as ax, OPERATION_ASSETS as ay, type Operation 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 };
651
+ 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, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, GASLESS_MIN_STABLE_AMOUNT as aA, GASLESS_STABLE_TYPES as aB, OPERATION_ASSETS as aC, type Operation as aD, SAVEABLE_ASSETS as aE, SENDABLE_ASSETS as aF, type SaveableAsset as aG, assertAllowedAsset as aH, createSuiClient as aI, getCoinMeta as aJ, getSuiClient as aK, getSuiGrpcClient as aL, isAllowedAsset as aM, isInRegistry as aN, normalizeAsset as aO, normalizeCoinType as aP, queryHistory as aQ, queryTransaction as aR, simulateTransaction as aS, throwIfSimulationFailed as aT, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, type SendableAsset as ax, CETUS_USDC_SUI_POOL as ay, DEFAULT_GRPC_URL 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,7 +1,7 @@
1
1
  {
2
2
  "name": "@t2000/sdk",
3
- "version": "3.2.0",
4
- "description": "TypeScript SDK for Agentic Wallets on Sui — send, save, borrow, swap. NAVI lending + Cetus aggregator routing, sponsored gas, zkLogin compatible.",
3
+ "version": "4.0.0",
4
+ "description": "TypeScript SDK for Agent Wallets on Sui — gasless USDC + USDsui transfers, Cetus swap routing, NAVI lending (programmatic), MPP paid API access, zkLogin compatible.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -36,10 +36,13 @@
36
36
  "wallet",
37
37
  "ai",
38
38
  "agent",
39
- "defi",
40
39
  "sdk",
41
40
  "usdc",
42
- "navi"
41
+ "usdsui",
42
+ "gasless",
43
+ "cetus",
44
+ "navi",
45
+ "zklogin"
43
46
  ],
44
47
  "author": "t2000",
45
48
  "repository": {