@t2000/sdk 10.27.1 → 10.27.2

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.js CHANGED
@@ -2936,11 +2936,21 @@ var T2000 = class _T2000 extends EventEmitter {
2936
2936
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
2937
2937
  let route;
2938
2938
  if (params.serializedRoute) {
2939
- const s = params.serializedRoute;
2939
+ let s = params.serializedRoute;
2940
+ const nested = s.serializedRoute;
2941
+ if (nested && typeof nested === "object" && typeof nested.fromCoinType === "string" && nested.routerData) {
2942
+ s = nested;
2943
+ }
2944
+ if (typeof s.fromCoinType !== "string" || typeof s.toCoinType !== "string") {
2945
+ throw new T2000Error(
2946
+ "SWAP_ROUTE_MISMATCH",
2947
+ "serializedRoute is not the object t2000 quoted \u2014 it is missing fromCoinType/toCoinType. Pass quote.serializedRoute exactly as the quote returned it (not the whole quote response), or omit serializedRoute to discover a fresh route."
2948
+ );
2949
+ }
2940
2950
  if (!verifyCetusRouteCoinMatch2(s, { fromCoinType: fromType, toCoinType: toType })) {
2941
2951
  throw new T2000Error(
2942
2952
  "SWAP_ROUTE_MISMATCH",
2943
- `The quoted route is for ${s.fromCoinType} -> ${s.toCoinType}, not ${params.from} -> ${params.to}. Re-quote and pass the new serializedRoute.`
2953
+ `The quoted route is for ${s.fromCoinType} -> ${s.toCoinType}, not ${fromType} -> ${toType}. Re-quote and pass the new serializedRoute.`
2944
2954
  );
2945
2955
  }
2946
2956
  if (s.byAmountIn !== byAmountIn || BigInt(s.amountIn) !== rawAmount) {