@t2000/sdk 0.21.13 → 0.21.14

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.cjs CHANGED
@@ -113,6 +113,87 @@ var init_errors = __esm({
113
113
  }
114
114
  });
115
115
 
116
+ // src/token-registry.ts
117
+ function getDecimalsForCoinType(coinType) {
118
+ const direct = BY_TYPE.get(coinType);
119
+ if (direct) return direct.decimals;
120
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
121
+ if (suffix) {
122
+ for (const meta of BY_TYPE.values()) {
123
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
124
+ if (metaSuffix === suffix) return meta.decimals;
125
+ }
126
+ }
127
+ return 9;
128
+ }
129
+ function resolveSymbol(coinType) {
130
+ const direct = BY_TYPE.get(coinType);
131
+ if (direct) return direct.symbol;
132
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
133
+ if (suffix) {
134
+ for (const meta of BY_TYPE.values()) {
135
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
136
+ if (metaSuffix === suffix) return meta.symbol;
137
+ }
138
+ }
139
+ return coinType.split("::").pop() ?? coinType;
140
+ }
141
+ function resolveTokenType(nameOrType) {
142
+ if (nameOrType.includes("::")) return nameOrType;
143
+ return exports.TOKEN_MAP[nameOrType] ?? exports.TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
144
+ }
145
+ exports.COIN_REGISTRY = void 0; var BY_TYPE; exports.TOKEN_MAP = void 0; exports.SUI_TYPE = void 0; exports.USDC_TYPE = void 0; exports.USDT_TYPE = void 0; exports.USDSUI_TYPE = void 0; exports.USDE_TYPE = void 0; exports.ETH_TYPE = void 0; exports.WBTC_TYPE = void 0; exports.WAL_TYPE = void 0; exports.NAVX_TYPE = void 0;
146
+ var init_token_registry = __esm({
147
+ "src/token-registry.ts"() {
148
+ exports.COIN_REGISTRY = {
149
+ SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI" },
150
+ USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC" },
151
+ USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
152
+ USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
153
+ USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" },
154
+ WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL" },
155
+ ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH" },
156
+ wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC" },
157
+ NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX" },
158
+ CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS" },
159
+ DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP" },
160
+ NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS" },
161
+ GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 6, symbol: "GOLD" },
162
+ MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST" },
163
+ vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI" },
164
+ haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e136a8bc::hasui::HASUI", decimals: 9, symbol: "haSUI" },
165
+ afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI" },
166
+ FDUSD: { type: "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD", decimals: 6, symbol: "FDUSD" },
167
+ AUSD: { type: "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD", decimals: 6, symbol: "AUSD" },
168
+ BUCK: { type: "0xce7ff77a83ea0cb6fd39bd8748e2ec89a3f41e8efdc3f4eb123e0ca37b184db2::buck::BUCK", decimals: 9, symbol: "BUCK" },
169
+ BLUB: { type: "0xfa7ac3951fdca12c1b6d18eb19e1aa2fbc31e4d45773c8e45b4ded3ef8d83f8a::blub::BLUB", decimals: 9, symbol: "BLUB" },
170
+ SCA: { type: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA", decimals: 9, symbol: "SCA" },
171
+ TURBOS: { type: "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a::turbos::TURBOS", decimals: 9, symbol: "TURBOS" }
172
+ };
173
+ BY_TYPE = /* @__PURE__ */ new Map();
174
+ for (const meta of Object.values(exports.COIN_REGISTRY)) {
175
+ BY_TYPE.set(meta.type, meta);
176
+ }
177
+ exports.TOKEN_MAP = (() => {
178
+ const map = {};
179
+ for (const [name, meta] of Object.entries(exports.COIN_REGISTRY)) {
180
+ map[name] = meta.type;
181
+ map[name.toUpperCase()] = meta.type;
182
+ }
183
+ return map;
184
+ })();
185
+ exports.SUI_TYPE = exports.COIN_REGISTRY.SUI.type;
186
+ exports.USDC_TYPE = exports.COIN_REGISTRY.USDC.type;
187
+ exports.USDT_TYPE = exports.COIN_REGISTRY.USDT.type;
188
+ exports.USDSUI_TYPE = exports.COIN_REGISTRY.USDSUI.type;
189
+ exports.USDE_TYPE = exports.COIN_REGISTRY.USDe.type;
190
+ exports.ETH_TYPE = exports.COIN_REGISTRY.ETH.type;
191
+ exports.WBTC_TYPE = exports.COIN_REGISTRY.wBTC.type;
192
+ exports.WAL_TYPE = exports.COIN_REGISTRY.WAL.type;
193
+ exports.NAVX_TYPE = exports.COIN_REGISTRY.NAVX.type;
194
+ }
195
+ });
196
+
116
197
  // src/protocols/volo.ts
117
198
  var volo_exports = {};
118
199
  __export(volo_exports, {
@@ -288,38 +369,11 @@ async function simulateSwap(params) {
288
369
  return { success: false, error: err instanceof Error ? err.message : String(err) };
289
370
  }
290
371
  }
291
- function resolveTokenType(nameOrType) {
292
- if (nameOrType.includes("::")) return nameOrType;
293
- return exports.TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
294
- }
295
- var clientInstance; exports.TOKEN_MAP = void 0;
372
+ var clientInstance;
296
373
  var init_cetus_swap = __esm({
297
374
  "src/protocols/cetus-swap.ts"() {
375
+ init_token_registry();
298
376
  clientInstance = null;
299
- exports.TOKEN_MAP = {
300
- SUI: "0x2::sui::SUI",
301
- USDC: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
302
- USDT: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
303
- CETUS: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS",
304
- DEEP: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",
305
- NAVX: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
306
- vSUI: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT",
307
- haSUI: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e136a8bc::hasui::HASUI",
308
- afSUI: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI",
309
- WAL: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL",
310
- ETH: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH",
311
- wBTC: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC",
312
- FDUSD: "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD",
313
- AUSD: "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD",
314
- BUCK: "0xce7ff77a83ea0cb6fd39bd8748e2ec89a3f41e8efdc3f4eb123e0ca37b184db2::buck::BUCK",
315
- USDe: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE",
316
- USDSUI: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI",
317
- MANIFEST: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST",
318
- NS: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS",
319
- BLUB: "0xfa7ac3951fdca12c1b6d18eb19e1aa2fbc31e4d45773c8e45b4ded3ef8d83f8a::blub::BLUB",
320
- SCA: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA",
321
- TURBOS: "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a::turbos::TURBOS"
322
- };
323
377
  }
324
378
  });
325
379
 
@@ -722,7 +776,7 @@ async function queryBalance(client, address) {
722
776
  }
723
777
 
724
778
  // src/wallet/history.ts
725
- var SUI_TYPE = "0x2::sui::SUI";
779
+ init_token_registry();
726
780
  var KNOWN_TARGETS = [
727
781
  [/::suilend|::obligation/, "lending"],
728
782
  [/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
@@ -775,12 +829,12 @@ function extractTransferDetails(changes, sender) {
775
829
  if (!changes || changes.length === 0) return {};
776
830
  const outflows = changes.filter((c) => resolveOwner(c.owner) === sender && BigInt(c.amount) < 0n);
777
831
  const inflows = changes.filter((c) => resolveOwner(c.owner) !== sender && BigInt(c.amount) > 0n);
778
- const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE).sort((a, b) => Number(BigInt(a.amount) - BigInt(b.amount)))[0] ?? outflows[0];
832
+ const primaryOutflow = outflows.filter((c) => c.coinType !== exports.SUI_TYPE).sort((a, b) => Number(BigInt(a.amount) - BigInt(b.amount)))[0] ?? outflows[0];
779
833
  if (!primaryOutflow) return {};
780
834
  const coinType = primaryOutflow.coinType;
781
- const decimals = coinType.includes("::usdc::") ? 6 : 9;
835
+ const decimals = getDecimalsForCoinType(coinType);
782
836
  const amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
783
- const asset = coinType === SUI_TYPE ? "SUI" : coinType.includes("::usdc::") ? "USDC" : coinType.split("::").pop() ?? "unknown";
837
+ const asset = resolveSymbol(coinType);
784
838
  const recipientChange = inflows.find((c) => c.coinType === coinType);
785
839
  const recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
786
840
  return { amount, asset, recipient };
@@ -821,6 +875,9 @@ function classifyAction(targets, commandTypes) {
821
875
  return "transaction";
822
876
  }
823
877
 
878
+ // src/t2000.ts
879
+ init_token_registry();
880
+
824
881
  // src/protocols/protocolFee.ts
825
882
  var FEE_RATES = {
826
883
  save: SAVE_FEE_BPS,
@@ -2312,8 +2369,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2312
2369
  if (!toType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.to}. Provide the full coin type.`);
2313
2370
  const byAmountIn = params.byAmountIn ?? true;
2314
2371
  const slippage = Math.min(params.slippage ?? 0.01, 0.05);
2315
- const fromEntry = Object.values(TOKEN_MAP2).includes(fromType) ? Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === fromType) : null;
2316
- const fromDecimals = fromEntry ? fromEntry[1].decimals : fromType === "0x2::sui::SUI" ? 9 : 6;
2372
+ const fromDecimals = getDecimalsForCoinType(fromType);
2317
2373
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
2318
2374
  const route = await findSwapRoute2({
2319
2375
  walletAddress: this._address,
@@ -2327,8 +2383,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2327
2383
  if (route.priceImpact > 0.05) {
2328
2384
  console.warn(`[swap] High price impact: ${(route.priceImpact * 100).toFixed(2)}%`);
2329
2385
  }
2330
- const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
2331
- const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
2386
+ const toDecimals = getDecimalsForCoinType(toType);
2332
2387
  let preBalRaw = 0n;
2333
2388
  try {
2334
2389
  const preBal = await this.client.getBalance({ owner: this._address, coinType: toType });
@@ -2368,10 +2423,6 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2368
2423
  pollInterval: 400
2369
2424
  });
2370
2425
  const changes = fullTx.balanceChanges ?? [];
2371
- console.error(`[swap] balanceChanges count=${changes.length}, toType=${toType}, suffix=${toTypeSuffix}`);
2372
- for (const c of changes) {
2373
- console.error(`[swap] coinType=${c.coinType} amount=${c.amount} owner=${JSON.stringify(c.owner)}`);
2374
- }
2375
2426
  const received = changes.find((c) => {
2376
2427
  if (BigInt(c.amount) <= 0n) return false;
2377
2428
  const ownerAddr = c.owner?.AddressOwner;
@@ -2382,32 +2433,22 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2382
2433
  if (received) {
2383
2434
  const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
2384
2435
  if (actual > 0) toAmount = actual;
2385
- console.error(`[swap] Primary: toAmount=${toAmount}`);
2386
- } else {
2387
- console.error(`[swap] Primary: no matching balance change found`);
2388
2436
  }
2389
- } catch (err) {
2390
- console.error(`[swap] Primary failed:`, err);
2437
+ } catch {
2391
2438
  }
2392
2439
  const cetusEstimate = Number(route.amountOut) / 10 ** toDecimals;
2393
2440
  if (Math.abs(toAmount - cetusEstimate) < 1e-3) {
2394
- console.error(`[swap] toAmount still equals Cetus estimate (${cetusEstimate}), trying balance diff`);
2395
2441
  try {
2396
2442
  await new Promise((r) => setTimeout(r, 2e3));
2397
2443
  const postBal = await this.client.getBalance({ owner: this._address, coinType: toType });
2398
2444
  const postRaw = BigInt(postBal.totalBalance);
2399
2445
  const delta = Number(postRaw - preBalRaw) / 10 ** toDecimals;
2400
- console.error(`[swap] Fallback: pre=${preBalRaw} post=${postRaw} delta=${delta}`);
2401
- if (delta > 0) {
2402
- toAmount = delta;
2403
- console.error(`[swap] Fallback: using balance diff: ${toAmount}`);
2404
- }
2405
- } catch (err) {
2406
- console.error(`[swap] Fallback failed:`, err);
2446
+ if (delta > 0) toAmount = delta;
2447
+ } catch {
2407
2448
  }
2408
2449
  }
2409
- const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
2410
- const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
2450
+ const fromName = resolveSymbol(fromType);
2451
+ const toName = resolveSymbol(toType);
2411
2452
  const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
2412
2453
  return {
2413
2454
  success: true,
@@ -2429,8 +2470,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2429
2470
  if (!fromType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.from}. Provide the full coin type.`);
2430
2471
  if (!toType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.to}. Provide the full coin type.`);
2431
2472
  const byAmountIn = params.byAmountIn ?? true;
2432
- const fromEntry = Object.values(TOKEN_MAP2).includes(fromType) ? Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === fromType) : null;
2433
- const fromDecimals = fromEntry ? fromEntry[1].decimals : fromType === "0x2::sui::SUI" ? 9 : 6;
2473
+ const fromDecimals = getDecimalsForCoinType(fromType);
2434
2474
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
2435
2475
  const route = await findSwapRoute2({
2436
2476
  walletAddress: this._address,
@@ -2441,8 +2481,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2441
2481
  });
2442
2482
  if (!route) throw new exports.T2000Error("SWAP_NO_ROUTE", `No swap route found for ${params.from} -> ${params.to}.`);
2443
2483
  if (route.insufficientLiquidity) throw new exports.T2000Error("SWAP_NO_ROUTE", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
2444
- const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
2445
- const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
2484
+ const toDecimals = getDecimalsForCoinType(toType);
2446
2485
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
2447
2486
  const toAmount = Number(route.amountOut) / 10 ** toDecimals;
2448
2487
  const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
@@ -2818,12 +2857,6 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2818
2857
  }
2819
2858
  return all;
2820
2859
  }
2821
- _resolveTokenName(coinType, fallback) {
2822
- const entry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === coinType);
2823
- if (entry) return entry[0];
2824
- const suffix = coinType.split("::").pop();
2825
- return suffix && suffix !== coinType ? suffix : fallback;
2826
- }
2827
2860
  _mergeCoinsInTx(tx, coins) {
2828
2861
  if (coins.length === 0) throw new exports.T2000Error("INSUFFICIENT_BALANCE", "No coins to merge");
2829
2862
  const primary = tx.object(coins[0].coinObjectId);
@@ -3279,6 +3312,7 @@ function parseMoveAbort(errorStr) {
3279
3312
  }
3280
3313
 
3281
3314
  // src/swap-quote.ts
3315
+ init_token_registry();
3282
3316
  async function getSwapQuote(params) {
3283
3317
  const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2, TOKEN_MAP: TOKEN_MAP2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
3284
3318
  const fromType = resolveTokenType2(params.from);
@@ -3286,8 +3320,7 @@ async function getSwapQuote(params) {
3286
3320
  if (!fromType) throw new Error(`Unknown token: ${params.from}. Provide the full coin type.`);
3287
3321
  if (!toType) throw new Error(`Unknown token: ${params.to}. Provide the full coin type.`);
3288
3322
  const byAmountIn = params.byAmountIn ?? true;
3289
- const fromEntry = Object.values(TOKEN_MAP2).includes(fromType) ? Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === fromType) : null;
3290
- const fromDecimals = fromEntry ? fromEntry[1].decimals : fromType === "0x2::sui::SUI" ? 9 : 6;
3323
+ const fromDecimals = getDecimalsForCoinType(fromType);
3291
3324
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
3292
3325
  const route = await findSwapRoute2({
3293
3326
  walletAddress: params.walletAddress,
@@ -3298,8 +3331,7 @@ async function getSwapQuote(params) {
3298
3331
  });
3299
3332
  if (!route) throw new Error(`No swap route found for ${params.from} -> ${params.to}.`);
3300
3333
  if (route.insufficientLiquidity) throw new Error(`Insufficient liquidity for ${params.from} -> ${params.to}.`);
3301
- const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
3302
- const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
3334
+ const toDecimals = getDecimalsForCoinType(toType);
3303
3335
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
3304
3336
  const toAmount = Number(route.amountOut) / 10 ** toDecimals;
3305
3337
  const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
@@ -3315,6 +3347,7 @@ async function getSwapQuote(params) {
3315
3347
 
3316
3348
  // src/index.ts
3317
3349
  init_cetus_swap();
3350
+ init_token_registry();
3318
3351
  init_volo();
3319
3352
 
3320
3353
  exports.ALL_NAVI_ASSETS = ALL_NAVI_ASSETS;
@@ -3354,6 +3387,7 @@ exports.formatUsd = formatUsd;
3354
3387
  exports.generateKeypair = generateKeypair;
3355
3388
  exports.getAddress = getAddress;
3356
3389
  exports.getDecimals = getDecimals;
3390
+ exports.getDecimalsForCoinType = getDecimalsForCoinType;
3357
3391
  exports.getGasStatus = getGasStatus;
3358
3392
  exports.getRates = getRates;
3359
3393
  exports.getSwapQuote = getSwapQuote;
@@ -3366,6 +3400,7 @@ exports.mistToSui = mistToSui;
3366
3400
  exports.naviDescriptor = naviDescriptor;
3367
3401
  exports.rawToStable = rawToStable;
3368
3402
  exports.rawToUsdc = rawToUsdc;
3403
+ exports.resolveSymbol = resolveSymbol;
3369
3404
  exports.resolveTokenType = resolveTokenType;
3370
3405
  exports.saveKey = saveKey;
3371
3406
  exports.shouldAutoTopUp = shouldAutoTopUp;