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