@t2000/sdk 0.46.1 → 0.46.3

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,5 +1,5 @@
1
- export { A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, 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, F as FeeOperation, G as GAS_RESERVE_MIN, g as GasExecutionResult, h as GasRequestType, i as GasSponsorResponse, j as GasStatusResponse, I as IKA_TYPE, K as KNOWN_TARGETS, k as KeypairSigner, L as LABEL_PATTERNS, l as LOFI_TYPE, M as MANIFEST_TYPE, m as MIST_PER_SUI, N as NAVX_TYPE, O as OUTBOUND_OPS, P as ProtocolFeeInfo, S as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, q as SafeguardConfig, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SupportedAsset, T as T2000Error, x as T2000ErrorCode, y as T2000ErrorData, z as TOKEN_MAP, H as TransactionSigner, J as TxMetadata, U as USDC_DECIMALS, Q as USDC_TYPE, R as USDE_TYPE, V as USDSUI_TYPE, W as USDT_TYPE, X as WAL_TYPE, Y as WBTC_TYPE, Z as ZkLoginProof, _ as ZkLoginSigner, $ as addCollectFeeToTx, a0 as calculateFee, a1 as classifyAction, a2 as classifyLabel, a3 as classifyTransaction, a4 as executeAutoTopUp, a5 as executeWithGas, a6 as fallbackLabel, a7 as formatAssetAmount, a8 as formatSui, a9 as formatUsd, aa as getDecimals, ab as getDecimalsForCoinType, ac as getGasStatus, ad as getTier, ae as isSupported, af as isTier1, ag as isTier2, ah as mapMoveAbortCode, ai as mapWalletError, aj as mistToSui, ak as rawToStable, al as rawToUsdc, am as refineLendingLabel, an as resolveSymbol, ao as resolveTokenType, ap as shouldAutoTopUp, aq as stableToRaw, ar as suiToMist, as as truncateAddress, at as usdcToRaw, au as validateAddress } from './token-registry-mycv_b90.cjs';
2
- export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasMethod, b as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, c as MaxWithdrawResult, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, T as TransactionRecord, W as WithdrawResult } from './types-DfwfwsAN.cjs';
1
+ export { A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, 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, h as GasExecutionResult, i as GasRequestType, j as GasSponsorResponse, k as GasStatusResponse, I as IKA_TYPE, K as KNOWN_TARGETS, l as KeypairSigner, L as LABEL_PATTERNS, m as LOFI_TYPE, M as MANIFEST_TYPE, n as MIST_PER_SUI, N as NAVX_TYPE, O as OUTBOUND_OPS, P as ProtocolFeeInfo, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, r as SafeguardConfig, s as SafeguardError, t as SafeguardErrorDetails, u as SafeguardRule, v as SimulationResult, w as StableAsset, x as SuiRpcTxBlock, y as SupportedAsset, T as T2000Error, z as T2000ErrorCode, H as T2000ErrorData, J as TOKEN_MAP, Q as TransactionSigner, R as TxDirection, U as TxMetadata, V as USDC_DECIMALS, W as USDC_TYPE, X as USDE_TYPE, Y as USDSUI_TYPE, Z as USDT_TYPE, _ as WAL_TYPE, $ as WBTC_TYPE, a0 as ZkLoginProof, a1 as ZkLoginSigner, a2 as addCollectFeeToTx, a3 as calculateFee, a4 as classifyAction, a5 as classifyLabel, a6 as classifyTransaction, a7 as executeAutoTopUp, a8 as executeWithGas, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as formatAssetAmount, ae as formatSui, af as formatUsd, ag as getDecimals, ah as getDecimalsForCoinType, ai as getGasStatus, aj as getTier, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aq as parseSuiRpcTx, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aw as shouldAutoTopUp, ax as stableToRaw, ay as suiToMist, az as truncateAddress, aA as usdcToRaw, aB as validateAddress } from './token-registry-_ehntRHs.cjs';
2
+ export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasMethod, b as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, c as MaxWithdrawResult, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, T as TransactionRecord, W as WithdrawResult } from './types-DIgyNKqV.cjs';
3
3
  import '@mysten/sui/keypairs/ed25519';
4
4
  import '@mysten/sui/jsonRpc';
5
5
  import '@mysten/sui/transactions';
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, 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, F as FeeOperation, G as GAS_RESERVE_MIN, g as GasExecutionResult, h as GasRequestType, i as GasSponsorResponse, j as GasStatusResponse, I as IKA_TYPE, K as KNOWN_TARGETS, k as KeypairSigner, L as LABEL_PATTERNS, l as LOFI_TYPE, M as MANIFEST_TYPE, m as MIST_PER_SUI, N as NAVX_TYPE, O as OUTBOUND_OPS, P as ProtocolFeeInfo, S as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, q as SafeguardConfig, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SupportedAsset, T as T2000Error, x as T2000ErrorCode, y as T2000ErrorData, z as TOKEN_MAP, H as TransactionSigner, J as TxMetadata, U as USDC_DECIMALS, Q as USDC_TYPE, R as USDE_TYPE, V as USDSUI_TYPE, W as USDT_TYPE, X as WAL_TYPE, Y as WBTC_TYPE, Z as ZkLoginProof, _ as ZkLoginSigner, $ as addCollectFeeToTx, a0 as calculateFee, a1 as classifyAction, a2 as classifyLabel, a3 as classifyTransaction, a4 as executeAutoTopUp, a5 as executeWithGas, a6 as fallbackLabel, a7 as formatAssetAmount, a8 as formatSui, a9 as formatUsd, aa as getDecimals, ab as getDecimalsForCoinType, ac as getGasStatus, ad as getTier, ae as isSupported, af as isTier1, ag as isTier2, ah as mapMoveAbortCode, ai as mapWalletError, aj as mistToSui, ak as rawToStable, al as rawToUsdc, am as refineLendingLabel, an as resolveSymbol, ao as resolveTokenType, ap as shouldAutoTopUp, aq as stableToRaw, ar as suiToMist, as as truncateAddress, at as usdcToRaw, au as validateAddress } from './token-registry-C1UN5EFV.js';
2
- export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasMethod, b as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, c as MaxWithdrawResult, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, T as TransactionRecord, W as WithdrawResult } from './types-DfwfwsAN.js';
1
+ export { A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, 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, h as GasExecutionResult, i as GasRequestType, j as GasSponsorResponse, k as GasStatusResponse, I as IKA_TYPE, K as KNOWN_TARGETS, l as KeypairSigner, L as LABEL_PATTERNS, m as LOFI_TYPE, M as MANIFEST_TYPE, n as MIST_PER_SUI, N as NAVX_TYPE, O as OUTBOUND_OPS, P as ProtocolFeeInfo, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, r as SafeguardConfig, s as SafeguardError, t as SafeguardErrorDetails, u as SafeguardRule, v as SimulationResult, w as StableAsset, x as SuiRpcTxBlock, y as SupportedAsset, T as T2000Error, z as T2000ErrorCode, H as T2000ErrorData, J as TOKEN_MAP, Q as TransactionSigner, R as TxDirection, U as TxMetadata, V as USDC_DECIMALS, W as USDC_TYPE, X as USDE_TYPE, Y as USDSUI_TYPE, Z as USDT_TYPE, _ as WAL_TYPE, $ as WBTC_TYPE, a0 as ZkLoginProof, a1 as ZkLoginSigner, a2 as addCollectFeeToTx, a3 as calculateFee, a4 as classifyAction, a5 as classifyLabel, a6 as classifyTransaction, a7 as executeAutoTopUp, a8 as executeWithGas, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as formatAssetAmount, ae as formatSui, af as formatUsd, ag as getDecimals, ah as getDecimalsForCoinType, ai as getGasStatus, aj as getTier, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aq as parseSuiRpcTx, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aw as shouldAutoTopUp, ax as stableToRaw, ay as suiToMist, az as truncateAddress, aA as usdcToRaw, aB as validateAddress } from './token-registry-B4FfUwvm.js';
2
+ export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasMethod, b as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, c as MaxWithdrawResult, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, T as TransactionRecord, W as WithdrawResult } from './types-DIgyNKqV.js';
3
3
  import '@mysten/sui/keypairs/ed25519';
4
4
  import '@mysten/sui/jsonRpc';
5
5
  import '@mysten/sui/transactions';
package/dist/browser.js CHANGED
@@ -610,8 +610,23 @@ var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
610
610
  var KNOWN_TARGETS = [
611
611
  [/::suilend|::obligation/, "lending"],
612
612
  [/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
613
- [/::cetus|::pool/, "swap"],
614
- [/::deepbook/, "swap"],
613
+ /**
614
+ * DEX modules — both direct calls and aggregator legs. The Cetus
615
+ * aggregator dispatches through a per-DEX module (e.g.
616
+ * `cetus::swap`, `flowx_amm::swap`, `aftermath::swap`, …) plus
617
+ * router glue functions. We list every DEX module the aggregator
618
+ * supports today so a single-DEX call still classifies cleanly.
619
+ */
620
+ [/::cetus(?:_dlmm)?::|::pool::|::deepbook|::flowx_(?:amm|clmm)::|::kriya_(?:amm|clmm)::|::turbos::|::aftermath::|::afsui::|::bluefin::|::bluemove::|::ferra_(?:clmm|dlmm)::|::haedal_hmm::|::hasui::|::hawal::|::magma::|::momentum::|::obric::|::springsui::|::steamm_cpmm::|::fullsail::|::alphafi::|::volo_swap::/, "swap"],
621
+ /**
622
+ * Cetus aggregator router glue. These are the swap-context and
623
+ * balance-handling helpers the aggregator emits around per-DEX
624
+ * legs. Without this entry a tx that ONLY had router calls
625
+ * (theoretically possible for setup/cleanup) would slip through;
626
+ * in practice these always coexist with a DEX leg, but the entry
627
+ * is cheap insurance.
628
+ */
629
+ [/::router::(?:new_swap_context(?:_v)?|confirm_swap|transfer_balance|take_balance|transfer_or_destroy_coin)/, "swap"],
615
630
  [/::transfer::public_transfer/, "send"]
616
631
  ];
617
632
  var LABEL_PATTERNS = [
@@ -654,6 +669,8 @@ function classifyLabel(targets, commandTypes) {
654
669
  }
655
670
  }
656
671
  if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
672
+ const action = classifyAction(targets, commandTypes);
673
+ if (action !== "transaction") return action;
657
674
  return fallbackLabel(targets);
658
675
  }
659
676
  function refineLendingLabel(currentAction, currentLabel, moveCallTargets, changes, address) {
@@ -678,6 +695,104 @@ function classifyTransaction(moveCallTargets, commandTypes, balanceChanges, addr
678
695
  const label = refineLendingLabel(action, baseLabel, moveCallTargets, balanceChanges, address);
679
696
  return { action, label };
680
697
  }
698
+ function extractTransferDetails(changes, sender) {
699
+ if (!changes || changes.length === 0) return {};
700
+ const userChanges = changes.filter((c) => resolveOwner(c.owner) === sender);
701
+ if (userChanges.length === 0) return {};
702
+ const userNonSui = userChanges.filter((c) => c.coinType !== SUI_TYPE);
703
+ const pool = userNonSui.length > 0 ? userNonSui : userChanges;
704
+ let primary = pool[0];
705
+ let primaryAbs = bigintAbs(BigInt(primary.amount));
706
+ for (let i = 1; i < pool.length; i++) {
707
+ const abs = bigintAbs(BigInt(pool[i].amount));
708
+ if (abs > primaryAbs) {
709
+ primary = pool[i];
710
+ primaryAbs = abs;
711
+ }
712
+ }
713
+ const raw = BigInt(primary.amount);
714
+ if (raw === 0n) return {};
715
+ const decimals = getDecimalsForCoinType(primary.coinType);
716
+ const amount = Number(primaryAbs) / 10 ** decimals;
717
+ const asset = resolveSymbol(primary.coinType);
718
+ const direction = raw < 0n ? "out" : "in";
719
+ let recipient;
720
+ if (direction === "out") {
721
+ const recipientChange = changes.find(
722
+ (c) => resolveOwner(c.owner) !== sender && c.coinType === primary.coinType && BigInt(c.amount) > 0n
723
+ );
724
+ recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
725
+ }
726
+ return { amount, asset, recipient, direction };
727
+ }
728
+ function bigintAbs(n) {
729
+ return n < 0n ? -n : n;
730
+ }
731
+
732
+ // src/wallet/history.ts
733
+ function parseSuiRpcTx(tx, address) {
734
+ return parseTxRecord(tx, address);
735
+ }
736
+ function extractTxSender(txBlock) {
737
+ try {
738
+ if (!txBlock || typeof txBlock !== "object") return null;
739
+ const data = "data" in txBlock ? txBlock.data : void 0;
740
+ if (!data || typeof data !== "object") return null;
741
+ return data.sender ?? null;
742
+ } catch {
743
+ return null;
744
+ }
745
+ }
746
+ function extractTxCommands(txBlock) {
747
+ return extractCommands(txBlock);
748
+ }
749
+ function parseTxRecord(tx, address) {
750
+ const gasUsed = tx.effects?.gasUsed;
751
+ const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
752
+ const { moveCallTargets, commandTypes } = extractCommands(tx.transaction);
753
+ const balanceChanges = tx.balanceChanges ?? [];
754
+ const { amount, asset, recipient, direction } = extractTransferDetails(balanceChanges, address);
755
+ const { action, label } = classifyTransaction(
756
+ moveCallTargets,
757
+ commandTypes,
758
+ balanceChanges,
759
+ address
760
+ );
761
+ return {
762
+ digest: tx.digest,
763
+ action,
764
+ label,
765
+ amount,
766
+ asset,
767
+ recipient,
768
+ direction,
769
+ timestamp: Number(tx.timestampMs ?? 0),
770
+ gasCost
771
+ };
772
+ }
773
+ function extractCommands(txBlock) {
774
+ const result = { moveCallTargets: [], commandTypes: [] };
775
+ try {
776
+ if (!txBlock || typeof txBlock !== "object") return result;
777
+ const data = "data" in txBlock ? txBlock.data : void 0;
778
+ if (!data || typeof data !== "object") return result;
779
+ const inner = "transaction" in data ? data.transaction : void 0;
780
+ if (!inner || typeof inner !== "object") return result;
781
+ const commands = "commands" in inner ? inner.commands : "transactions" in inner ? inner.transactions : void 0;
782
+ if (!Array.isArray(commands)) return result;
783
+ for (const cmd of commands) {
784
+ if (cmd.MoveCall) {
785
+ const mc = cmd.MoveCall;
786
+ result.moveCallTargets.push(`${mc.package}::${mc.module}::${mc.function}`);
787
+ result.commandTypes.push("MoveCall");
788
+ } else if (cmd.TransferObjects) {
789
+ result.commandTypes.push("TransferObjects");
790
+ }
791
+ }
792
+ } catch {
793
+ }
794
+ return result;
795
+ }
681
796
 
682
797
  // src/utils/format.ts
683
798
  function mistToSui(mist) {
@@ -801,6 +916,6 @@ var DEFAULT_SAFEGUARD_CONFIG = {
801
916
  dailyResetDate: ""
802
917
  };
803
918
 
804
- export { ALL_NAVI_ASSETS, BPS_DENOMINATOR, CLOCK_ID, COIN_REGISTRY, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OUTBOUND_OPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, executeAutoTopUp, executeWithGas, fallbackLabel, formatAssetAmount, formatSui, formatUsd, fromBase64, getDecimals, getDecimalsForCoinType, getGasStatus, getTier, isSupported, isTier1, isTier2, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, shouldAutoTopUp, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
919
+ export { ALL_NAVI_ASSETS, BPS_DENOMINATOR, CLOCK_ID, COIN_REGISTRY, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OUTBOUND_OPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, executeAutoTopUp, executeWithGas, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, formatAssetAmount, formatSui, formatUsd, fromBase64, getDecimals, getDecimalsForCoinType, getGasStatus, getTier, isSupported, isTier1, isTier2, mapMoveAbortCode, mapWalletError, mistToSui, parseSuiRpcTx, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, shouldAutoTopUp, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
805
920
  //# sourceMappingURL=browser.js.map
806
921
  //# sourceMappingURL=browser.js.map