@t2000/sdk 2.13.1 → 2.14.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.cjs +12 -29
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +13 -30
- package/dist/adapters/index.js.map +1 -1
- 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.map +1 -1
- package/dist/index.cjs +139 -237
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -80
- package/dist/index.d.ts +74 -80
- package/dist/index.js +140 -238
- package/dist/index.js.map +1 -1
- package/dist/{types-BY6ovQGK.d.cts → types-1WUNZK-9.d.cts} +1 -1
- package/dist/{types-epj9U13o.d.cts → types-CFJrgLm2.d.cts} +21 -13
- package/dist/{types-epj9U13o.d.ts → types-CFJrgLm2.d.ts} +21 -13
- package/dist/{types-WeZQDV54.d.ts → types-D65N3sBO.d.ts} +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-
|
|
5
|
-
export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aA as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aB as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aC as isAllowedAsset, aD as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aE as normalizeAsset, aF as normalizeCoinType, am as parseSuiRpcTx, aG as queryHistory, aH as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aI as simulateTransaction, as as stableToRaw, at as suiToMist, aJ as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-
|
|
4
|
+
import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-1WUNZK-9.cjs';
|
|
5
|
+
export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aA as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aB as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aC as isAllowedAsset, aD as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aE as normalizeAsset, aF as normalizeCoinType, am as parseSuiRpcTx, aG as queryHistory, aH as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aI as simulateTransaction, as as stableToRaw, at as suiToMist, aJ as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-1WUNZK-9.cjs';
|
|
6
6
|
import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DqIb4AnV.cjs';
|
|
7
7
|
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DqIb4AnV.cjs';
|
|
8
|
-
import { n as T2000Options, P as PayOptions, d as PayResult, o as StakeVSuiResult, U as UnstakeVSuiResult, p as SwapResult, q as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, r as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, s as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, t as FinancialSummary } from './types-
|
|
9
|
-
export { A as AssetRates, G as GasReserve, u as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, v as SerializedCetusRoute, w as SerializedCetusRoutePath, x as SerializedRouterDataV3, T as TransactionLeg, y as addSwapToTx, l as buildSwapTx, z as deserializeCetusRoute, m as findSwapRoute, I as isCetusRouteFresh, J as serializeCetusRoute, K as verifyCetusRouteCoinMatch } from './types-
|
|
8
|
+
import { n as T2000Options, P as PayOptions, d as PayResult, o as StakeVSuiResult, U as UnstakeVSuiResult, p as SwapResult, q as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, r as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, s as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, t as FinancialSummary } from './types-CFJrgLm2.cjs';
|
|
9
|
+
export { A as AssetRates, G as GasReserve, u as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, v as SerializedCetusRoute, w as SerializedCetusRoutePath, x as SerializedRouterDataV3, T as TransactionLeg, y as addSwapToTx, l as buildSwapTx, z as deserializeCetusRoute, m as findSwapRoute, I as isCetusRouteFresh, J as serializeCetusRoute, K as verifyCetusRouteCoinMatch } from './types-CFJrgLm2.cjs';
|
|
10
10
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
11
11
|
import { SuinsClient } from '@mysten/suins';
|
|
12
12
|
export { NaviAdapter, ProtocolRegistry } from './adapters/index.cjs';
|
|
@@ -179,9 +179,6 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
179
179
|
* matching the caller's existing "insufficient balance" error path.
|
|
180
180
|
*/
|
|
181
181
|
private _queryAssetBalance;
|
|
182
|
-
private _fetchCoins;
|
|
183
|
-
private _mergeCoinsInTx;
|
|
184
|
-
private _lastFundDigest;
|
|
185
182
|
private _autoFundFromSavings;
|
|
186
183
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
187
184
|
borrow(params: {
|
|
@@ -267,27 +264,32 @@ declare function buildSendTx({ client, address, to, amount, asset, }: {
|
|
|
267
264
|
declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, recipient: string): void;
|
|
268
265
|
|
|
269
266
|
/**
|
|
270
|
-
* Wallet-side coin selection helpers —
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* coin type
|
|
290
|
-
*
|
|
267
|
+
* Wallet-side coin selection helpers — single source of truth for the
|
|
268
|
+
* "produce a `Coin<T>` argument holding `amount` raw units of `coinType`,
|
|
269
|
+
* owned by `address`" pattern. Used by every wallet-mode appender that
|
|
270
|
+
* needs a coin input (save, send, swap, repay, stake, etc.).
|
|
271
|
+
*
|
|
272
|
+
* **2026-05-22 — address-balance migration.** Sui mainnet's address-balance
|
|
273
|
+
* feature ships funds account-style instead of as discrete `Coin<T>` objects.
|
|
274
|
+
* After a payment via `0x2::balance::send_funds`, the leftover lands in the
|
|
275
|
+
* sender's address balance with a synthetic "coin reservation" representing
|
|
276
|
+
* the deposit. `client.getCoins()` correctly filters those reservations out
|
|
277
|
+
* (they aren't real owned objects), so the old fetch+merge+split pattern
|
|
278
|
+
* threw `INSUFFICIENT_BALANCE` for users whose stables had drifted into
|
|
279
|
+
* address balance — even when `getBalance().totalBalance` showed plenty.
|
|
280
|
+
*
|
|
281
|
+
* The fix is structural: hand the work to `coinWithBalance({ type, balance })`
|
|
282
|
+
* from `@mysten/sui/transactions`. Its build-time resolver inspects coins +
|
|
283
|
+
* address balance together (`getBalance` + `listCoins`), then emits the
|
|
284
|
+
* right shape — direct `redeem_funds` from address balance when AB ≥
|
|
285
|
+
* required, or merge-and-split across coins + AB withdrawal when not. Multi
|
|
286
|
+
* intents per coin type get batched into a single merge in one PTB, so the
|
|
287
|
+
* old per-PTB merge cache is no longer needed.
|
|
288
|
+
*
|
|
289
|
+
* Pre-flight uses `client.getBalance().totalBalance` (sums coins + AB)
|
|
290
|
+
* instead of summing the paginated `getCoins` page. That's the OTHER half
|
|
291
|
+
* of the migration — the legacy path could see `0` from `getCoins` and
|
|
292
|
+
* mistakenly throw before `coinWithBalance` ever ran.
|
|
291
293
|
*/
|
|
292
294
|
|
|
293
295
|
interface CoinPage {
|
|
@@ -295,13 +297,16 @@ interface CoinPage {
|
|
|
295
297
|
totalBalance: bigint;
|
|
296
298
|
}
|
|
297
299
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
300
|
+
* Sum every coin of `coinType` owned by `owner`, INCLUDING address balance.
|
|
301
|
+
* Returns the IDs of any discrete coin objects that exist (callers
|
|
302
|
+
* occasionally need this for non-`coinWithBalance` paths, e.g. SUIns name
|
|
303
|
+
* registration which expects raw object IDs).
|
|
304
|
+
*
|
|
305
|
+
* Pre-2026-05-22 this function paginated `client.getCoins` and summed
|
|
306
|
+
* the page balances. That misses address-balance funds (the SDK filters
|
|
307
|
+
* them out of `getCoins` for back-compat). The new implementation calls
|
|
308
|
+
* `getBalance` for the canonical total and `getCoins` for the optional
|
|
309
|
+
* ID list — both round-trips, but they happen in parallel.
|
|
305
310
|
*/
|
|
306
311
|
declare function fetchAllCoins(client: SuiJsonRpcClient, owner: string, coinType: string): Promise<CoinPage>;
|
|
307
312
|
interface SelectAndSplitResult {
|
|
@@ -313,39 +318,30 @@ interface SelectAndSplitResult {
|
|
|
313
318
|
swapAll: boolean;
|
|
314
319
|
}
|
|
315
320
|
/**
|
|
316
|
-
* Wallet-mode coin selection prelude.
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
321
|
+
* Wallet-mode coin selection prelude. Pre-flights against
|
|
322
|
+
* `getBalance().totalBalance` (coins + address balance combined), then
|
|
323
|
+
* returns a `coinWithBalance({ type, balance })` argument that the
|
|
324
|
+
* `@mysten/sui` resolver fulfills at build time.
|
|
320
325
|
*
|
|
321
326
|
* Throws `T2000Error` (`INSUFFICIENT_BALANCE`) when:
|
|
322
|
-
* - No coins of `coinType` exist for `owner`
|
|
323
327
|
* - `amount` is bigger than the total balance AND the caller did NOT
|
|
324
|
-
* opt into `swapAll: true` clipping
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* @param
|
|
334
|
-
*
|
|
335
|
-
* @param coinType — fully-qualified Sui coin type
|
|
336
|
-
* (`"0x...::usdc::USDC"`).
|
|
337
|
-
* @param amount — raw amount to split out (in MIST / smallest unit).
|
|
338
|
-
* Pass `'all'` to consume the entire merged primary directly.
|
|
339
|
-
* @param options.allowSwapAll — if true (default), `amount` >=
|
|
340
|
-
* totalBalance auto-clips to total (matches audric host's swap
|
|
341
|
-
* branch). If false, throws `INSUFFICIENT_BALANCE` when over.
|
|
328
|
+
* opt into `swapAll: true` clipping.
|
|
329
|
+
* - `amount === 'all'` AND total balance is zero.
|
|
330
|
+
*
|
|
331
|
+
* @param tx — PTB to register the `coinWithBalance` intent against.
|
|
332
|
+
* @param client — Sui RPC client for the pre-flight `getBalance` lookup.
|
|
333
|
+
* @param owner — wallet address whose coins to source from.
|
|
334
|
+
* @param coinType — fully-qualified Sui coin type (e.g. `"0x...::usdc::USDC"`).
|
|
335
|
+
* @param amount — raw amount to source (in MIST / smallest unit). Pass
|
|
336
|
+
* `'all'` to consume the entire balance.
|
|
337
|
+
* @param options.allowSwapAll — if true (default), `amount` >= totalBalance
|
|
338
|
+
* auto-clips to total. If false, throws when the request would over-consume.
|
|
342
339
|
*
|
|
343
340
|
* @returns
|
|
344
|
-
* - `coin` — `TransactionObjectArgument` ready for downstream
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* - `swapAll` — true iff the entire merged primary was consumed.
|
|
341
|
+
* - `coin` — `TransactionObjectArgument` ready for downstream consumption.
|
|
342
|
+
* - `effectiveAmount` — the raw amount the returned coin holds (handles
|
|
343
|
+
* swapAll clipping).
|
|
344
|
+
* - `swapAll` — true iff the entire balance was consumed.
|
|
349
345
|
*/
|
|
350
346
|
declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, coinType: string, amount: bigint | 'all', options?: {
|
|
351
347
|
allowSwapAll?: boolean;
|
|
@@ -353,19 +349,15 @@ declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, o
|
|
|
353
349
|
/**
|
|
354
350
|
* SUI-specific coin selection. Branches on sponsorship context:
|
|
355
351
|
*
|
|
356
|
-
* - **Sponsored (`sponsoredContext: true`)** — fetches SUI coins via
|
|
357
|
-
* `getCoins` and merges/splits, because `tx.gas` belongs to the
|
|
358
|
-
* Enoki sponsor (NOT the user) under sponsored flows. Same shape as
|
|
359
|
-
* `selectAndSplitCoin` for any other coin type.
|
|
360
|
-
*
|
|
361
352
|
* - **Self-funded (`sponsoredContext: false`)** — splits from `tx.gas`
|
|
362
353
|
* directly (the user's gas coin IS their SUI). More efficient — no
|
|
363
|
-
*
|
|
354
|
+
* `getBalance` RTT.
|
|
364
355
|
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
356
|
+
* - **Sponsored (`sponsoredContext: true`)** — uses
|
|
357
|
+
* `coinWithBalance({ type: SUI, useGasCoin: false })`, because `tx.gas`
|
|
358
|
+
* belongs to the Enoki sponsor (NOT the user) under sponsored flows.
|
|
359
|
+
* The resolver sources from the user's SUI coins / address balance,
|
|
360
|
+
* not the sponsor's gas coin.
|
|
369
361
|
*/
|
|
370
362
|
declare function selectSuiCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, amountMist: bigint, sponsoredContext: boolean): Promise<SelectAndSplitResult>;
|
|
371
363
|
|
|
@@ -1153,15 +1145,16 @@ declare function buildUnstakeVSuiTx(client: SuiJsonRpcClient, address: string, a
|
|
|
1153
1145
|
/**
|
|
1154
1146
|
* SPEC 7 § "Layer 1" Volo stake appender. Two modes.
|
|
1155
1147
|
*
|
|
1156
|
-
* Wallet mode (`inputCoin` omitted):
|
|
1157
|
-
*
|
|
1148
|
+
* Wallet mode (`inputCoin` omitted): pre-flights via `getBalance` and
|
|
1149
|
+
* sources SUI through `coinWithBalance({ type: SUI, useGasCoin: false })`,
|
|
1150
|
+
* which resolves coin objects + address balance at build time. Mirrors
|
|
1158
1151
|
* the audric host's `transactions/prepare/route.ts:524-545` volo-stake
|
|
1159
1152
|
* branch — sponsored-flow safe (does NOT consume `tx.gas`, which
|
|
1160
1153
|
* belongs to the Enoki sponsor in sponsored flows).
|
|
1161
1154
|
*
|
|
1162
1155
|
* For non-sponsored flows where the caller owns `tx.gas`, prefer
|
|
1163
|
-
* `buildStakeVSuiTx` directly (it splits from gas, which
|
|
1164
|
-
*
|
|
1156
|
+
* `buildStakeVSuiTx` directly (it splits from gas, which avoids one
|
|
1157
|
+
* `getBalance` RTT).
|
|
1165
1158
|
*
|
|
1166
1159
|
* Chain mode (`inputCoin` provided): consumes the passed-in SUI coin
|
|
1167
1160
|
* ref entirely. Used for chained flows like "swap USDC → SUI → stake".
|
|
@@ -1185,9 +1178,10 @@ declare function addStakeVSuiToTx(tx: Transaction, client: SuiJsonRpcClient, add
|
|
|
1185
1178
|
/**
|
|
1186
1179
|
* SPEC 7 § "Layer 1" Volo unstake appender. Two modes.
|
|
1187
1180
|
*
|
|
1188
|
-
* Wallet mode (`inputCoin` omitted):
|
|
1189
|
-
*
|
|
1190
|
-
*
|
|
1181
|
+
* Wallet mode (`inputCoin` omitted): pre-flights via `getBalance` and
|
|
1182
|
+
* sources vSUI through `coinWithBalance({ type: VSUI, balance })`,
|
|
1183
|
+
* which resolves coin objects + address balance at build time. With
|
|
1184
|
+
* `'all'`, the entire balance is consumed.
|
|
1191
1185
|
*
|
|
1192
1186
|
* Chain mode (`inputCoin` provided): consumes the passed-in vSUI coin
|
|
1193
1187
|
* ref. With `amountMist = 'all'`, the entire input coin is unstaked.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-
|
|
5
|
-
export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aA as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aB as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aC as isAllowedAsset, aD as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aE as normalizeAsset, aF as normalizeCoinType, am as parseSuiRpcTx, aG as queryHistory, aH as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aI as simulateTransaction, as as stableToRaw, at as suiToMist, aJ as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-
|
|
4
|
+
import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-D65N3sBO.js';
|
|
5
|
+
export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aA as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aB as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aC as isAllowedAsset, aD as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aE as normalizeAsset, aF as normalizeCoinType, am as parseSuiRpcTx, aG as queryHistory, aH as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aI as simulateTransaction, as as stableToRaw, at as suiToMist, aJ as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-D65N3sBO.js';
|
|
6
6
|
import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DqIb4AnV.js';
|
|
7
7
|
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DqIb4AnV.js';
|
|
8
|
-
import { n as T2000Options, P as PayOptions, d as PayResult, o as StakeVSuiResult, U as UnstakeVSuiResult, p as SwapResult, q as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, r as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, s as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, t as FinancialSummary } from './types-
|
|
9
|
-
export { A as AssetRates, G as GasReserve, u as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, v as SerializedCetusRoute, w as SerializedCetusRoutePath, x as SerializedRouterDataV3, T as TransactionLeg, y as addSwapToTx, l as buildSwapTx, z as deserializeCetusRoute, m as findSwapRoute, I as isCetusRouteFresh, J as serializeCetusRoute, K as verifyCetusRouteCoinMatch } from './types-
|
|
8
|
+
import { n as T2000Options, P as PayOptions, d as PayResult, o as StakeVSuiResult, U as UnstakeVSuiResult, p as SwapResult, q as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, r as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, s as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, t as FinancialSummary } from './types-CFJrgLm2.js';
|
|
9
|
+
export { A as AssetRates, G as GasReserve, u as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, v as SerializedCetusRoute, w as SerializedCetusRoutePath, x as SerializedRouterDataV3, T as TransactionLeg, y as addSwapToTx, l as buildSwapTx, z as deserializeCetusRoute, m as findSwapRoute, I as isCetusRouteFresh, J as serializeCetusRoute, K as verifyCetusRouteCoinMatch } from './types-CFJrgLm2.js';
|
|
10
10
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
11
11
|
import { SuinsClient } from '@mysten/suins';
|
|
12
12
|
export { NaviAdapter, ProtocolRegistry } from './adapters/index.js';
|
|
@@ -179,9 +179,6 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
179
179
|
* matching the caller's existing "insufficient balance" error path.
|
|
180
180
|
*/
|
|
181
181
|
private _queryAssetBalance;
|
|
182
|
-
private _fetchCoins;
|
|
183
|
-
private _mergeCoinsInTx;
|
|
184
|
-
private _lastFundDigest;
|
|
185
182
|
private _autoFundFromSavings;
|
|
186
183
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
187
184
|
borrow(params: {
|
|
@@ -267,27 +264,32 @@ declare function buildSendTx({ client, address, to, amount, asset, }: {
|
|
|
267
264
|
declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, recipient: string): void;
|
|
268
265
|
|
|
269
266
|
/**
|
|
270
|
-
* Wallet-side coin selection helpers —
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* coin type
|
|
290
|
-
*
|
|
267
|
+
* Wallet-side coin selection helpers — single source of truth for the
|
|
268
|
+
* "produce a `Coin<T>` argument holding `amount` raw units of `coinType`,
|
|
269
|
+
* owned by `address`" pattern. Used by every wallet-mode appender that
|
|
270
|
+
* needs a coin input (save, send, swap, repay, stake, etc.).
|
|
271
|
+
*
|
|
272
|
+
* **2026-05-22 — address-balance migration.** Sui mainnet's address-balance
|
|
273
|
+
* feature ships funds account-style instead of as discrete `Coin<T>` objects.
|
|
274
|
+
* After a payment via `0x2::balance::send_funds`, the leftover lands in the
|
|
275
|
+
* sender's address balance with a synthetic "coin reservation" representing
|
|
276
|
+
* the deposit. `client.getCoins()` correctly filters those reservations out
|
|
277
|
+
* (they aren't real owned objects), so the old fetch+merge+split pattern
|
|
278
|
+
* threw `INSUFFICIENT_BALANCE` for users whose stables had drifted into
|
|
279
|
+
* address balance — even when `getBalance().totalBalance` showed plenty.
|
|
280
|
+
*
|
|
281
|
+
* The fix is structural: hand the work to `coinWithBalance({ type, balance })`
|
|
282
|
+
* from `@mysten/sui/transactions`. Its build-time resolver inspects coins +
|
|
283
|
+
* address balance together (`getBalance` + `listCoins`), then emits the
|
|
284
|
+
* right shape — direct `redeem_funds` from address balance when AB ≥
|
|
285
|
+
* required, or merge-and-split across coins + AB withdrawal when not. Multi
|
|
286
|
+
* intents per coin type get batched into a single merge in one PTB, so the
|
|
287
|
+
* old per-PTB merge cache is no longer needed.
|
|
288
|
+
*
|
|
289
|
+
* Pre-flight uses `client.getBalance().totalBalance` (sums coins + AB)
|
|
290
|
+
* instead of summing the paginated `getCoins` page. That's the OTHER half
|
|
291
|
+
* of the migration — the legacy path could see `0` from `getCoins` and
|
|
292
|
+
* mistakenly throw before `coinWithBalance` ever ran.
|
|
291
293
|
*/
|
|
292
294
|
|
|
293
295
|
interface CoinPage {
|
|
@@ -295,13 +297,16 @@ interface CoinPage {
|
|
|
295
297
|
totalBalance: bigint;
|
|
296
298
|
}
|
|
297
299
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
300
|
+
* Sum every coin of `coinType` owned by `owner`, INCLUDING address balance.
|
|
301
|
+
* Returns the IDs of any discrete coin objects that exist (callers
|
|
302
|
+
* occasionally need this for non-`coinWithBalance` paths, e.g. SUIns name
|
|
303
|
+
* registration which expects raw object IDs).
|
|
304
|
+
*
|
|
305
|
+
* Pre-2026-05-22 this function paginated `client.getCoins` and summed
|
|
306
|
+
* the page balances. That misses address-balance funds (the SDK filters
|
|
307
|
+
* them out of `getCoins` for back-compat). The new implementation calls
|
|
308
|
+
* `getBalance` for the canonical total and `getCoins` for the optional
|
|
309
|
+
* ID list — both round-trips, but they happen in parallel.
|
|
305
310
|
*/
|
|
306
311
|
declare function fetchAllCoins(client: SuiJsonRpcClient, owner: string, coinType: string): Promise<CoinPage>;
|
|
307
312
|
interface SelectAndSplitResult {
|
|
@@ -313,39 +318,30 @@ interface SelectAndSplitResult {
|
|
|
313
318
|
swapAll: boolean;
|
|
314
319
|
}
|
|
315
320
|
/**
|
|
316
|
-
* Wallet-mode coin selection prelude.
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
321
|
+
* Wallet-mode coin selection prelude. Pre-flights against
|
|
322
|
+
* `getBalance().totalBalance` (coins + address balance combined), then
|
|
323
|
+
* returns a `coinWithBalance({ type, balance })` argument that the
|
|
324
|
+
* `@mysten/sui` resolver fulfills at build time.
|
|
320
325
|
*
|
|
321
326
|
* Throws `T2000Error` (`INSUFFICIENT_BALANCE`) when:
|
|
322
|
-
* - No coins of `coinType` exist for `owner`
|
|
323
327
|
* - `amount` is bigger than the total balance AND the caller did NOT
|
|
324
|
-
* opt into `swapAll: true` clipping
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* @param
|
|
334
|
-
*
|
|
335
|
-
* @param coinType — fully-qualified Sui coin type
|
|
336
|
-
* (`"0x...::usdc::USDC"`).
|
|
337
|
-
* @param amount — raw amount to split out (in MIST / smallest unit).
|
|
338
|
-
* Pass `'all'` to consume the entire merged primary directly.
|
|
339
|
-
* @param options.allowSwapAll — if true (default), `amount` >=
|
|
340
|
-
* totalBalance auto-clips to total (matches audric host's swap
|
|
341
|
-
* branch). If false, throws `INSUFFICIENT_BALANCE` when over.
|
|
328
|
+
* opt into `swapAll: true` clipping.
|
|
329
|
+
* - `amount === 'all'` AND total balance is zero.
|
|
330
|
+
*
|
|
331
|
+
* @param tx — PTB to register the `coinWithBalance` intent against.
|
|
332
|
+
* @param client — Sui RPC client for the pre-flight `getBalance` lookup.
|
|
333
|
+
* @param owner — wallet address whose coins to source from.
|
|
334
|
+
* @param coinType — fully-qualified Sui coin type (e.g. `"0x...::usdc::USDC"`).
|
|
335
|
+
* @param amount — raw amount to source (in MIST / smallest unit). Pass
|
|
336
|
+
* `'all'` to consume the entire balance.
|
|
337
|
+
* @param options.allowSwapAll — if true (default), `amount` >= totalBalance
|
|
338
|
+
* auto-clips to total. If false, throws when the request would over-consume.
|
|
342
339
|
*
|
|
343
340
|
* @returns
|
|
344
|
-
* - `coin` — `TransactionObjectArgument` ready for downstream
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* - `swapAll` — true iff the entire merged primary was consumed.
|
|
341
|
+
* - `coin` — `TransactionObjectArgument` ready for downstream consumption.
|
|
342
|
+
* - `effectiveAmount` — the raw amount the returned coin holds (handles
|
|
343
|
+
* swapAll clipping).
|
|
344
|
+
* - `swapAll` — true iff the entire balance was consumed.
|
|
349
345
|
*/
|
|
350
346
|
declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, coinType: string, amount: bigint | 'all', options?: {
|
|
351
347
|
allowSwapAll?: boolean;
|
|
@@ -353,19 +349,15 @@ declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, o
|
|
|
353
349
|
/**
|
|
354
350
|
* SUI-specific coin selection. Branches on sponsorship context:
|
|
355
351
|
*
|
|
356
|
-
* - **Sponsored (`sponsoredContext: true`)** — fetches SUI coins via
|
|
357
|
-
* `getCoins` and merges/splits, because `tx.gas` belongs to the
|
|
358
|
-
* Enoki sponsor (NOT the user) under sponsored flows. Same shape as
|
|
359
|
-
* `selectAndSplitCoin` for any other coin type.
|
|
360
|
-
*
|
|
361
352
|
* - **Self-funded (`sponsoredContext: false`)** — splits from `tx.gas`
|
|
362
353
|
* directly (the user's gas coin IS their SUI). More efficient — no
|
|
363
|
-
*
|
|
354
|
+
* `getBalance` RTT.
|
|
364
355
|
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
356
|
+
* - **Sponsored (`sponsoredContext: true`)** — uses
|
|
357
|
+
* `coinWithBalance({ type: SUI, useGasCoin: false })`, because `tx.gas`
|
|
358
|
+
* belongs to the Enoki sponsor (NOT the user) under sponsored flows.
|
|
359
|
+
* The resolver sources from the user's SUI coins / address balance,
|
|
360
|
+
* not the sponsor's gas coin.
|
|
369
361
|
*/
|
|
370
362
|
declare function selectSuiCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, amountMist: bigint, sponsoredContext: boolean): Promise<SelectAndSplitResult>;
|
|
371
363
|
|
|
@@ -1153,15 +1145,16 @@ declare function buildUnstakeVSuiTx(client: SuiJsonRpcClient, address: string, a
|
|
|
1153
1145
|
/**
|
|
1154
1146
|
* SPEC 7 § "Layer 1" Volo stake appender. Two modes.
|
|
1155
1147
|
*
|
|
1156
|
-
* Wallet mode (`inputCoin` omitted):
|
|
1157
|
-
*
|
|
1148
|
+
* Wallet mode (`inputCoin` omitted): pre-flights via `getBalance` and
|
|
1149
|
+
* sources SUI through `coinWithBalance({ type: SUI, useGasCoin: false })`,
|
|
1150
|
+
* which resolves coin objects + address balance at build time. Mirrors
|
|
1158
1151
|
* the audric host's `transactions/prepare/route.ts:524-545` volo-stake
|
|
1159
1152
|
* branch — sponsored-flow safe (does NOT consume `tx.gas`, which
|
|
1160
1153
|
* belongs to the Enoki sponsor in sponsored flows).
|
|
1161
1154
|
*
|
|
1162
1155
|
* For non-sponsored flows where the caller owns `tx.gas`, prefer
|
|
1163
|
-
* `buildStakeVSuiTx` directly (it splits from gas, which
|
|
1164
|
-
*
|
|
1156
|
+
* `buildStakeVSuiTx` directly (it splits from gas, which avoids one
|
|
1157
|
+
* `getBalance` RTT).
|
|
1165
1158
|
*
|
|
1166
1159
|
* Chain mode (`inputCoin` provided): consumes the passed-in SUI coin
|
|
1167
1160
|
* ref entirely. Used for chained flows like "swap USDC → SUI → stake".
|
|
@@ -1185,9 +1178,10 @@ declare function addStakeVSuiToTx(tx: Transaction, client: SuiJsonRpcClient, add
|
|
|
1185
1178
|
/**
|
|
1186
1179
|
* SPEC 7 § "Layer 1" Volo unstake appender. Two modes.
|
|
1187
1180
|
*
|
|
1188
|
-
* Wallet mode (`inputCoin` omitted):
|
|
1189
|
-
*
|
|
1190
|
-
*
|
|
1181
|
+
* Wallet mode (`inputCoin` omitted): pre-flights via `getBalance` and
|
|
1182
|
+
* sources vSUI through `coinWithBalance({ type: VSUI, balance })`,
|
|
1183
|
+
* which resolves coin objects + address balance at build time. With
|
|
1184
|
+
* `'all'`, the entire balance is consumed.
|
|
1191
1185
|
*
|
|
1192
1186
|
* Chain mode (`inputCoin` provided): consumes the passed-in vSUI coin
|
|
1193
1187
|
* ref. With `amountMist = 'all'`, the entire input coin is unstaked.
|