UNPKG

@openocean.finance/widget-sdk

Version:

OpenOcean Any-to-Any Cross-Chain-Swap SDK

18 lines 798 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkStepSlippageThreshold = checkStepSlippageThreshold; const standardThreshold = 0.005; function checkStepSlippageThreshold(oldStep, newStep) { const setSlippage = oldStep.action.slippage || standardThreshold; const oldEstimatedToAmount = BigInt(oldStep.estimate.toAmountMin); const newEstimatedToAmount = BigInt(newStep.estimate.toAmountMin); const amountDifference = oldEstimatedToAmount - newEstimatedToAmount; let actualSlippage = 0; if (oldEstimatedToAmount > 0) { actualSlippage = Number((amountDifference * 1000000000n) / oldEstimatedToAmount) / 1_000_000_000; } return actualSlippage <= setSlippage; } //# sourceMappingURL=utils.js.map