@t2000/sdk 0.46.12 → 0.46.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.js CHANGED
@@ -752,7 +752,7 @@ async function findSwapRoute(params) {
752
752
  amountIn: routerData.amountIn.toString(),
753
753
  amountOut: routerData.amountOut.toString(),
754
754
  byAmountIn: params.byAmountIn,
755
- priceImpact: routerData.deviationRatio,
755
+ priceImpact: normalizePriceImpact(routerData.deviationRatio),
756
756
  insufficientLiquidity: true
757
757
  };
758
758
  }
@@ -765,10 +765,14 @@ async function findSwapRoute(params) {
765
765
  amountIn: routerData.amountIn.toString(),
766
766
  amountOut: routerData.amountOut.toString(),
767
767
  byAmountIn: params.byAmountIn,
768
- priceImpact: routerData.deviationRatio,
768
+ priceImpact: normalizePriceImpact(routerData.deviationRatio),
769
769
  insufficientLiquidity: false
770
770
  };
771
771
  }
772
+ function normalizePriceImpact(value) {
773
+ const n = typeof value === "number" ? value : Number(value);
774
+ return Number.isFinite(n) ? n : 0;
775
+ }
772
776
  async function buildSwapTx(params) {
773
777
  const client = getClient(params.walletAddress);
774
778
  const clampedSlippage = Math.max(1e-3, Math.min(params.slippage, 0.05));