UNPKG

@openocean.finance/widget-sdk

Version:

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

33 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertQuoteToRoute = void 0; const SDKError_js_1 = require("../errors/SDKError.js"); const errors_js_1 = require("../errors/errors.js"); const convertQuoteToRoute = (quote) => { if (!quote.estimate.fromAmountUSD) { throw new SDKError_js_1.SDKError(new errors_js_1.ValidationError("Missing 'fromAmountUSD' in step estimate.")); } if (!quote.estimate.toAmountUSD) { throw new SDKError_js_1.SDKError(new errors_js_1.ValidationError("Missing 'toAmountUSD' in step estimate.")); } const route = { id: quote.id, fromChainId: quote.action.fromToken.chainId, fromToken: quote.action.fromToken, fromAmount: quote.action.fromAmount, fromAmountUSD: quote.estimate.fromAmountUSD, fromAddress: quote.action.fromAddress, toChainId: quote.action.toToken.chainId, toToken: quote.action.toToken, toAmount: quote.estimate.toAmount, toAmountMin: quote.estimate.toAmountMin, toAmountUSD: quote.estimate.toAmountUSD, toAddress: quote.action.toAddress || quote.action.fromAddress, gasCostUSD: quote.estimate.gasCosts?.[0].amountUSD, steps: [quote], insurance: { state: 'NOT_INSURABLE', feeAmountUsd: '0' }, }; return route; }; exports.convertQuoteToRoute = convertQuoteToRoute; //# sourceMappingURL=convertQuoteToRoute.js.map