@t2000/sdk 4.2.1 → 4.3.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/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, v as SupportedAsset, _ as ZkLoginProof, ax as SendableAsset } from './types-8CNP74n6.cjs';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ay as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, az as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aA as GASLESS_MIN_STABLE_AMOUNT, aB as GASLESS_STABLE_TYPES, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, aD as Operation, P as ProtocolFeeInfo, aE as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aF as SENDABLE_ASSETS, 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, aG as SaveableAsset, 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, aH as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aI as createSuiClient, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aJ as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, aK as getSuiClient, aL as getSuiGrpcClient, af as getTier, aM as isAllowedAsset, aN as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aO as normalizeAsset, aP as normalizeCoinType, am as parseSuiRpcTx, aQ as queryHistory, aR as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aS as simulateTransaction, as as stableToRaw, at as suiToMist, aT as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-8CNP74n6.cjs';
4
+ import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, v as SupportedAsset, _ as ZkLoginProof, az as SendableAsset } from './types-CFV4VcJJ.cjs';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, aB as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aC as GASLESS_MIN_STABLE_AMOUNT, aD as GASLESS_STABLE_TYPES, 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, aE as OPERATION_ASSETS, O as OUTBOUND_OPS, aF as Operation, P as ProtocolFeeInfo, aG as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aH as SENDABLE_ASSETS, 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, aI as SaveableAsset, 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, aJ as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aK as createSuiClient, a5 as executeTx, a6 as extractAllUserLegs, a7 as extractTransferDetails, a8 as extractTxCommands, a9 as extractTxSender, aa as fallbackLabel, ab as formatAssetAmount, ac as formatSui, ad as formatUsd, aL as getCoinMeta, ae as getDecimals, af as getDecimalsForCoinType, aM as getSuiClient, aN as getSuiGrpcClient, ag as getTier, aO as isAllowedAsset, aP as isInRegistry, ah as isSupported, ai as isTier1, aj as isTier2, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, aQ as normalizeAsset, aR as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, aS as queryHistory, aT as queryTransaction, ap as rawToStable, aq as rawToUsdc, ar as refineLendingLabel, as as resolveSymbol, at as resolveTokenType, aU as simulateTransaction, au as stableToRaw, av as suiToMist, aV as throwIfSimulationFailed, aw as truncateAddress, ax as usdcToRaw, ay as validateAddress } from './types-CFV4VcJJ.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 SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q 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, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, s as SponsoredCoinMergeCache, j as SwapRouteResult, t as FinancialSummary } from './types-DUmk5ivZ.cjs';
9
- export { A as AssetRates, u as CoinPage, G as GasReserve, v as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, w as SelectAndSplitResult, x as SerializedCetusRoute, y as SerializedCetusRoutePath, z as SerializedRouterDataV3, T as TransactionLeg, I as addSwapToTx, l as buildSwapTx, J as deserializeCetusRoute, K as fetchAllCoins, m as findSwapRoute, L as isCetusRouteFresh, N as selectAndSplitCoin, Q as selectSuiCoin, U as serializeCetusRoute, V as verifyCetusRouteCoinMatch } from './types-DUmk5ivZ.cjs';
8
+ import { n as T2000Options, P as PayOptions, d as PayResult, o as SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q 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, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, s as SponsoredCoinMergeCache, j as SwapRouteResult, t as FinancialSummary } from './types-Ch0zVUpC.cjs';
9
+ export { A as AssetRates, u as CoinPage, G as GasReserve, v as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, w as SelectAndSplitResult, x as SerializedCetusRoute, y as SerializedCetusRoutePath, z as SerializedRouterDataV3, T as TransactionLeg, I as addSwapToTx, l as buildSwapTx, J as deserializeCetusRoute, K as fetchAllCoins, m as findSwapRoute, L as isCetusRouteFresh, N as selectAndSplitCoin, Q as selectSuiCoin, U as serializeCetusRoute, V as verifyCetusRouteCoinMatch } from './types-Ch0zVUpC.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';
@@ -874,14 +874,15 @@ interface AppenderContext {
874
874
  */
875
875
  isOutputConsumed?: boolean;
876
876
  /**
877
- * Per-PTB merge cache for sponsored SUI sourcing, shared across every
878
- * appender in a single `composeTx` run. Lets multiple SUI-source swap
879
- * legs in one bundle reuse a single merged primary coin instead of each
880
- * re-fetching + re-merging the same coin objects (the second merge of
881
- * which references already-consumed coins Enoki dry-run
882
- * `ArgumentWithoutValue`). See `SponsoredCoinMergeCache` JSDoc.
877
+ * Per-PTB merge cache for sponsored coin-object sourcing, shared across
878
+ * every appender in a single `composeTx` run. Lets multiple legs that
879
+ * source the same coin type (two SUI swaps, swap USDC + save USDC, etc.)
880
+ * reuse a single merged primary coin instead of each re-fetching +
881
+ * re-merging the same coin objects (the second merge of which references
882
+ * already-consumed coins → Enoki dry-run `ArgumentWithoutValue`). Applies
883
+ * to ALL coin types, not just SUI. See `SponsoredCoinMergeCache` JSDoc.
883
884
  */
884
- suiMergeCache?: SponsoredCoinMergeCache;
885
+ coinMergeCache?: SponsoredCoinMergeCache;
885
886
  }
886
887
  /**
887
888
  * [SPEC 13 Phase 1] Appender return shape. Producers populate
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, v as SupportedAsset, _ as ZkLoginProof, ax as SendableAsset } from './types-BTbqE8AE.js';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ay as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, az as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aA as GASLESS_MIN_STABLE_AMOUNT, aB as GASLESS_STABLE_TYPES, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, aD as Operation, P as ProtocolFeeInfo, aE as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aF as SENDABLE_ASSETS, 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, aG as SaveableAsset, 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, aH as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aI as createSuiClient, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aJ as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, aK as getSuiClient, aL as getSuiGrpcClient, af as getTier, aM as isAllowedAsset, aN as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aO as normalizeAsset, aP as normalizeCoinType, am as parseSuiRpcTx, aQ as queryHistory, aR as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aS as simulateTransaction, as as stableToRaw, at as suiToMist, aT as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-BTbqE8AE.js';
4
+ import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, v as SupportedAsset, _ as ZkLoginProof, az as SendableAsset } from './types-DqRLGfOC.js';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, aB as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aC as GASLESS_MIN_STABLE_AMOUNT, aD as GASLESS_STABLE_TYPES, 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, aE as OPERATION_ASSETS, O as OUTBOUND_OPS, aF as Operation, P as ProtocolFeeInfo, aG as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aH as SENDABLE_ASSETS, 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, aI as SaveableAsset, 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, aJ as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aK as createSuiClient, a5 as executeTx, a6 as extractAllUserLegs, a7 as extractTransferDetails, a8 as extractTxCommands, a9 as extractTxSender, aa as fallbackLabel, ab as formatAssetAmount, ac as formatSui, ad as formatUsd, aL as getCoinMeta, ae as getDecimals, af as getDecimalsForCoinType, aM as getSuiClient, aN as getSuiGrpcClient, ag as getTier, aO as isAllowedAsset, aP as isInRegistry, ah as isSupported, ai as isTier1, aj as isTier2, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, aQ as normalizeAsset, aR as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, aS as queryHistory, aT as queryTransaction, ap as rawToStable, aq as rawToUsdc, ar as refineLendingLabel, as as resolveSymbol, at as resolveTokenType, aU as simulateTransaction, au as stableToRaw, av as suiToMist, aV as throwIfSimulationFailed, aw as truncateAddress, ax as usdcToRaw, ay as validateAddress } from './types-DqRLGfOC.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 SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q 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, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, s as SponsoredCoinMergeCache, j as SwapRouteResult, t as FinancialSummary } from './types-DUmk5ivZ.js';
9
- export { A as AssetRates, u as CoinPage, G as GasReserve, v as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, w as SelectAndSplitResult, x as SerializedCetusRoute, y as SerializedCetusRoutePath, z as SerializedRouterDataV3, T as TransactionLeg, I as addSwapToTx, l as buildSwapTx, J as deserializeCetusRoute, K as fetchAllCoins, m as findSwapRoute, L as isCetusRouteFresh, N as selectAndSplitCoin, Q as selectSuiCoin, U as serializeCetusRoute, V as verifyCetusRouteCoinMatch } from './types-DUmk5ivZ.js';
8
+ import { n as T2000Options, P as PayOptions, d as PayResult, o as SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q 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, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, s as SponsoredCoinMergeCache, j as SwapRouteResult, t as FinancialSummary } from './types-Ch0zVUpC.js';
9
+ export { A as AssetRates, u as CoinPage, G as GasReserve, v as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, w as SelectAndSplitResult, x as SerializedCetusRoute, y as SerializedCetusRoutePath, z as SerializedRouterDataV3, T as TransactionLeg, I as addSwapToTx, l as buildSwapTx, J as deserializeCetusRoute, K as fetchAllCoins, m as findSwapRoute, L as isCetusRouteFresh, N as selectAndSplitCoin, Q as selectSuiCoin, U as serializeCetusRoute, V as verifyCetusRouteCoinMatch } from './types-Ch0zVUpC.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';
@@ -874,14 +874,15 @@ interface AppenderContext {
874
874
  */
875
875
  isOutputConsumed?: boolean;
876
876
  /**
877
- * Per-PTB merge cache for sponsored SUI sourcing, shared across every
878
- * appender in a single `composeTx` run. Lets multiple SUI-source swap
879
- * legs in one bundle reuse a single merged primary coin instead of each
880
- * re-fetching + re-merging the same coin objects (the second merge of
881
- * which references already-consumed coins Enoki dry-run
882
- * `ArgumentWithoutValue`). See `SponsoredCoinMergeCache` JSDoc.
877
+ * Per-PTB merge cache for sponsored coin-object sourcing, shared across
878
+ * every appender in a single `composeTx` run. Lets multiple legs that
879
+ * source the same coin type (two SUI swaps, swap USDC + save USDC, etc.)
880
+ * reuse a single merged primary coin instead of each re-fetching +
881
+ * re-merging the same coin objects (the second merge of which references
882
+ * already-consumed coins → Enoki dry-run `ArgumentWithoutValue`). Applies
883
+ * to ALL coin types, not just SUI. See `SponsoredCoinMergeCache` JSDoc.
883
884
  */
884
- suiMergeCache?: SponsoredCoinMergeCache;
885
+ coinMergeCache?: SponsoredCoinMergeCache;
885
886
  }
886
887
  /**
887
888
  * [SPEC 13 Phase 1] Appender return shape. Producers populate
package/dist/index.js CHANGED
@@ -672,7 +672,15 @@ async function fetchAllCoins(client, owner, coinType) {
672
672
  }
673
673
  async function selectAndSplitCoin(tx, client, owner, coinType, amount, options = {}) {
674
674
  if (options.sponsoredContext) {
675
- return selectCoinObjectsOnly(tx, client, owner, coinType, amount, options.allowSwapAll ?? true);
675
+ return selectCoinObjectsOnly(
676
+ tx,
677
+ client,
678
+ owner,
679
+ coinType,
680
+ amount,
681
+ options.allowSwapAll ?? true,
682
+ options.mergeCache
683
+ );
676
684
  }
677
685
  const balanceResp = await client.getBalance({ owner, coinType });
678
686
  const totalBalance = BigInt(balanceResp.totalBalance);
@@ -979,14 +987,15 @@ async function addSwapToTx(tx, client, address, input) {
979
987
  address,
980
988
  requestedRaw,
981
989
  input.sponsoredContext ?? false,
982
- input.suiMergeCache
990
+ input.coinMergeCache
983
991
  );
984
992
  inputCoin = result.coin;
985
993
  effectiveRaw = result.effectiveAmount;
986
994
  } else {
987
995
  const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
988
996
  const result = await selectAndSplitCoin2(tx, client, address, fromType, requestedRaw, {
989
- sponsoredContext: input.sponsoredContext ?? false
997
+ sponsoredContext: input.sponsoredContext ?? false,
998
+ mergeCache: input.coinMergeCache
990
999
  });
991
1000
  inputCoin = result.coin;
992
1001
  effectiveRaw = result.effectiveAmount;
@@ -1387,6 +1396,27 @@ var KeypairSigner = class {
1387
1396
  }
1388
1397
  };
1389
1398
 
1399
+ // src/wallet/executeTx.ts
1400
+ async function executeTx(client, signer, buildTx, options = {}) {
1401
+ const tx = await buildTx();
1402
+ tx.setSender(signer.getAddress());
1403
+ const txBytes = await tx.build({ client: options.buildClient ?? client });
1404
+ const { signature } = await signer.signTransaction(txBytes);
1405
+ const result = await client.executeTransactionBlock({
1406
+ transactionBlock: txBytes,
1407
+ signature,
1408
+ options: { showEffects: true }
1409
+ });
1410
+ await client.waitForTransaction({ digest: result.digest });
1411
+ const gasUsed = result.effects?.gasUsed;
1412
+ let gasCostSui = 0;
1413
+ if (gasUsed) {
1414
+ const total = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
1415
+ gasCostSui = Number(total) / 1e9;
1416
+ }
1417
+ return { digest: result.digest, gasCostSui, effects: result.effects ?? void 0 };
1418
+ }
1419
+
1390
1420
  // src/mpp-cost.ts
1391
1421
  function parseChallengeAmount(challenge) {
1392
1422
  const raw = challenge?.request?.amount;
@@ -1394,6 +1424,66 @@ function parseChallengeAmount(challenge) {
1394
1424
  return Number.isFinite(n) ? n : void 0;
1395
1425
  }
1396
1426
 
1427
+ // src/wallet/pay.ts
1428
+ async function payWithMpp(args) {
1429
+ const { signer, client, options } = args;
1430
+ const { Mppx } = await import('mppx/client');
1431
+ const { sui, USDC } = await import('@suimpp/mpp/client');
1432
+ const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
1433
+ const signerAddress = signer.getAddress();
1434
+ let paymentDigest;
1435
+ let gasCostSui = 0;
1436
+ let chargedAmount;
1437
+ const network = client.network === "testnet" ? "testnet" : "mainnet";
1438
+ const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
1439
+ const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
1440
+ const mppx = Mppx.create({
1441
+ polyfill: false,
1442
+ onChallenge: async (challenge) => {
1443
+ const parsed = parseChallengeAmount(challenge);
1444
+ if (parsed !== void 0) chargedAmount = parsed;
1445
+ return void 0;
1446
+ },
1447
+ methods: [sui({
1448
+ client,
1449
+ currency: USDC,
1450
+ signer: {
1451
+ toSuiAddress: () => signerAddress,
1452
+ signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
1453
+ },
1454
+ execute: async (tx) => {
1455
+ const result = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1456
+ paymentDigest = result.digest;
1457
+ gasCostSui = result.gasCostSui;
1458
+ return { digest: result.digest };
1459
+ }
1460
+ })]
1461
+ });
1462
+ const method = (options.method ?? "GET").toUpperCase();
1463
+ const canHaveBody = method !== "GET" && method !== "HEAD";
1464
+ const response = await mppx.fetch(options.url, {
1465
+ method,
1466
+ headers: options.headers,
1467
+ body: canHaveBody ? options.body : void 0
1468
+ });
1469
+ const contentType = response.headers.get("content-type") ?? "";
1470
+ let body;
1471
+ try {
1472
+ body = contentType.includes("application/json") ? await response.json() : await response.text();
1473
+ } catch {
1474
+ body = null;
1475
+ }
1476
+ const paid = !!paymentDigest;
1477
+ return {
1478
+ status: response.status,
1479
+ body,
1480
+ paid,
1481
+ cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
1482
+ gasCostSui: paid ? gasCostSui : void 0,
1483
+ receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
1484
+ };
1485
+ }
1486
+
1397
1487
  // src/wallet/zkLoginSigner.ts
1398
1488
  var ZkLoginSigner = class {
1399
1489
  constructor(ephemeralKeypair, zkProof, userAddress, maxEpoch) {
@@ -1416,8 +1506,17 @@ var ZkLoginSigner = class {
1416
1506
  })
1417
1507
  };
1418
1508
  }
1419
- async signPersonalMessage(_messageBytes) {
1420
- throw new Error("ZkLoginSigner.signPersonalMessage is not yet implemented. Use KeypairSigner for sdk.pay() until grief-protection signing is wired for zkLogin.");
1509
+ async signPersonalMessage(messageBytes) {
1510
+ const { getZkLoginSignature } = await import('@mysten/zklogin');
1511
+ const { signature: ephSig, bytes } = await this.ephemeralKeypair.signPersonalMessage(messageBytes);
1512
+ return {
1513
+ signature: getZkLoginSignature({
1514
+ inputs: this.zkProof,
1515
+ maxEpoch: this.maxEpoch,
1516
+ userSignature: ephSig
1517
+ }),
1518
+ bytes
1519
+ };
1421
1520
  }
1422
1521
  isExpired(currentEpoch) {
1423
1522
  return currentEpoch >= this.maxEpoch;
@@ -6506,25 +6605,6 @@ var ContactManager = class {
6506
6605
  }
6507
6606
  };
6508
6607
  var DEFAULT_CONFIG_DIR = join$1(homedir(), ".t2000");
6509
- async function executeTx(client, signer, buildTx, options = {}) {
6510
- const tx = await buildTx();
6511
- tx.setSender(signer.getAddress());
6512
- const txBytes = await tx.build({ client: options.buildClient ?? client });
6513
- const { signature } = await signer.signTransaction(txBytes);
6514
- const result = await client.executeTransactionBlock({
6515
- transactionBlock: txBytes,
6516
- signature,
6517
- options: { showEffects: true }
6518
- });
6519
- await client.waitForTransaction({ digest: result.digest });
6520
- const gasUsed = result.effects?.gasUsed;
6521
- let gasCostSui = 0;
6522
- if (gasUsed) {
6523
- const total = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
6524
- gasCostSui = Number(total) / 1e9;
6525
- }
6526
- return { digest: result.digest, gasCostSui, effects: result.effects ?? void 0 };
6527
- }
6528
6608
  var T2000 = class _T2000 extends EventEmitter {
6529
6609
  _signer;
6530
6610
  _keypair;
@@ -6604,66 +6684,11 @@ var T2000 = class _T2000 extends EventEmitter {
6604
6684
  async pay(options) {
6605
6685
  this.enforcer.assertNotLocked();
6606
6686
  this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
6607
- const { Mppx } = await import('mppx/client');
6608
- const { sui, USDC } = await import('@suimpp/mpp/client');
6609
- const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
6610
- const client = this.client;
6611
- const signer = this._signer;
6612
- const signerAddress = signer.getAddress();
6613
- let paymentDigest;
6614
- let gasCostSui = 0;
6615
- let chargedAmount;
6616
- const network = client.network === "testnet" ? "testnet" : "mainnet";
6617
- const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
6618
- const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
6619
- const mppx = Mppx.create({
6620
- polyfill: false,
6621
- onChallenge: async (challenge) => {
6622
- const parsed = parseChallengeAmount(challenge);
6623
- if (parsed !== void 0) chargedAmount = parsed;
6624
- return void 0;
6625
- },
6626
- methods: [sui({
6627
- client,
6628
- currency: USDC,
6629
- signer: {
6630
- toSuiAddress: () => signerAddress,
6631
- signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
6632
- },
6633
- execute: async (tx) => {
6634
- const result = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
6635
- paymentDigest = result.digest;
6636
- gasCostSui = result.gasCostSui;
6637
- return { digest: result.digest };
6638
- }
6639
- })]
6640
- });
6641
- const method = (options.method ?? "GET").toUpperCase();
6642
- const canHaveBody = method !== "GET" && method !== "HEAD";
6643
- const response = await mppx.fetch(options.url, {
6644
- method,
6645
- headers: options.headers,
6646
- body: canHaveBody ? options.body : void 0
6647
- });
6648
- const contentType = response.headers.get("content-type") ?? "";
6649
- let body;
6650
- try {
6651
- body = contentType.includes("application/json") ? await response.json() : await response.text();
6652
- } catch {
6653
- body = null;
6687
+ const result = await payWithMpp({ signer: this._signer, client: this.client, options });
6688
+ if (result.paid) {
6689
+ this.enforcer.recordUsage(result.cost ?? options.maxPrice ?? 1);
6654
6690
  }
6655
- const paid = !!paymentDigest;
6656
- if (paid) {
6657
- this.enforcer.recordUsage(chargedAmount ?? options.maxPrice ?? 1);
6658
- }
6659
- return {
6660
- status: response.status,
6661
- body,
6662
- paid,
6663
- cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
6664
- gasCostSui: paid ? gasCostSui : void 0,
6665
- receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
6666
- };
6691
+ return result;
6667
6692
  }
6668
6693
  // [S.323 / 2026-05-25] VOLO vSUI staking surfaces removed (full cut).
6669
6694
  // Engine cut Volo in S.277; SDK + CLI + MCP followed in S.323 because the
@@ -7967,7 +7992,8 @@ var WRITE_APPENDER_REGISTRY = {
7967
7992
  effectiveAmount = rawAmount;
7968
7993
  } else {
7969
7994
  const r = await selectAndSplitCoin(tx, ctx.client, ctx.sender, assetInfo.type, rawAmount, {
7970
- sponsoredContext: ctx.sponsoredContext
7995
+ sponsoredContext: ctx.sponsoredContext,
7996
+ mergeCache: ctx.coinMergeCache
7971
7997
  });
7972
7998
  coin = r.coin;
7973
7999
  effectiveAmount = r.effectiveAmount;
@@ -8041,7 +8067,8 @@ var WRITE_APPENDER_REGISTRY = {
8041
8067
  effectiveAmount = rawAmount;
8042
8068
  } else {
8043
8069
  const r = await selectAndSplitCoin(tx, ctx.client, ctx.sender, assetInfo.type, rawAmount, {
8044
- sponsoredContext: ctx.sponsoredContext
8070
+ sponsoredContext: ctx.sponsoredContext,
8071
+ mergeCache: ctx.coinMergeCache
8045
8072
  });
8046
8073
  coin = r.coin;
8047
8074
  effectiveAmount = r.effectiveAmount;
@@ -8085,7 +8112,14 @@ var WRITE_APPENDER_REGISTRY = {
8085
8112
  };
8086
8113
  }
8087
8114
  if (asset === "SUI") {
8088
- const result = await selectSuiCoin(tx, ctx.client, ctx.sender, rawAmount, ctx.sponsoredContext);
8115
+ const result = await selectSuiCoin(
8116
+ tx,
8117
+ ctx.client,
8118
+ ctx.sender,
8119
+ rawAmount,
8120
+ ctx.sponsoredContext,
8121
+ ctx.coinMergeCache
8122
+ );
8089
8123
  addSendToTx(tx, result.coin, recipient);
8090
8124
  return {
8091
8125
  preview: {
@@ -8148,7 +8182,7 @@ var WRITE_APPENDER_REGISTRY = {
8148
8182
  inputCoin: ctx.chainedCoin,
8149
8183
  precomputedRoute: input.precomputedRoute,
8150
8184
  sponsoredContext: ctx.sponsoredContext,
8151
- suiMergeCache: ctx.suiMergeCache
8185
+ coinMergeCache: ctx.coinMergeCache
8152
8186
  });
8153
8187
  if (!ctx.isOutputConsumed) {
8154
8188
  tx.transferObjects([result.coin], ctx.sender);
@@ -8252,10 +8286,10 @@ async function composeTx(opts) {
8252
8286
  sponsoredContext: opts.sponsoredContext ?? false,
8253
8287
  overlayFee: opts.overlayFee,
8254
8288
  feeHooks: opts.feeHooks,
8255
- // One cache per compose run — shared across all legs so multi-leg
8256
- // sponsored bundles that source the same coin (e.g. two SUI swaps)
8257
- // merge that coin's objects exactly once.
8258
- suiMergeCache: /* @__PURE__ */ new Map()
8289
+ // One cache per compose run — shared across all legs (any coin type)
8290
+ // so multi-leg sponsored bundles that source the same coin (two SUI
8291
+ // swaps, swap USDC + save USDC, ...) merge that coin's objects once.
8292
+ coinMergeCache: /* @__PURE__ */ new Map()
8259
8293
  };
8260
8294
  const consumedSteps = /* @__PURE__ */ new Set();
8261
8295
  for (let i = 0; i < opts.steps.length; i++) {
@@ -8560,6 +8594,6 @@ function displayHandle(label) {
8560
8594
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
8561
8595
  */
8562
8596
 
8563
- export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_GRPC_URL, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVEABLE_ASSETS, SAVE_FEE_BPS, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addClaimRewardsToTx, addFeeTransfer, addSendToTx, addSwapToTx, aggregateClaimableRewards, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, createSuiClient, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, getTier, isAllowedAsset, isCetusRouteFresh, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists };
8597
+ export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_GRPC_URL, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVEABLE_ASSETS, SAVE_FEE_BPS, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addClaimRewardsToTx, addFeeTransfer, addSendToTx, addSwapToTx, aggregateClaimableRewards, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, createSuiClient, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, getTier, isAllowedAsset, isCetusRouteFresh, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists };
8564
8598
  //# sourceMappingURL=index.js.map
8565
8599
  //# sourceMappingURL=index.js.map