@t2000/sdk 1.24.6 → 1.24.8

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
@@ -8194,13 +8194,24 @@ function parseMoveAbort(errorStr) {
8194
8194
  }
8195
8195
 
8196
8196
  // src/swap-quote.ts
8197
+ init_errors();
8197
8198
  init_token_registry();
8198
8199
  async function getSwapQuote(params) {
8199
8200
  const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
8200
8201
  const fromType = resolveTokenType2(params.from);
8201
8202
  const toType = resolveTokenType2(params.to);
8202
- if (!fromType) throw new Error(`Unknown token: ${params.from}. Provide the full coin type.`);
8203
- if (!toType) throw new Error(`Unknown token: ${params.to}. Provide the full coin type.`);
8203
+ if (!fromType) {
8204
+ throw new exports.T2000Error(
8205
+ "ASSET_NOT_SUPPORTED",
8206
+ `Unknown token: ${params.from}. Provide the symbol (USDC, SUI, ...) or full coin type.`
8207
+ );
8208
+ }
8209
+ if (!toType) {
8210
+ throw new exports.T2000Error(
8211
+ "ASSET_NOT_SUPPORTED",
8212
+ `Unknown token: ${params.to}. Provide the symbol (USDC, SUI, ...) or full coin type.`
8213
+ );
8214
+ }
8204
8215
  const byAmountIn = params.byAmountIn ?? true;
8205
8216
  const fromDecimals = getDecimalsForCoinType(fromType);
8206
8217
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
@@ -8211,8 +8222,10 @@ async function getSwapQuote(params) {
8211
8222
  amount: rawAmount,
8212
8223
  byAmountIn
8213
8224
  });
8214
- if (!route) throw new Error(`No swap route found for ${params.from} -> ${params.to}.`);
8215
- if (route.insufficientLiquidity) throw new Error(`Insufficient liquidity for ${params.from} -> ${params.to}.`);
8225
+ if (!route) throw new exports.T2000Error("SWAP_FAILED", `No swap route found for ${params.from} -> ${params.to}.`);
8226
+ if (route.insufficientLiquidity) {
8227
+ throw new exports.T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
8228
+ }
8216
8229
  const toDecimals = getDecimalsForCoinType(toType);
8217
8230
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
8218
8231
  const toAmount = Number(route.amountOut) / 10 ** toDecimals;