@multiversx/sdk-dapp-swap
Version:
A library to hold the main logic for swapping between tokens on the MultiversX blockchain
3 lines (2 loc) • 908 B
JavaScript
import{a as r}from"./chunk-QHNNSNK5.js";import{a,b as e}from"./chunk-QXTSQDB3.js";import{f as T}from"./chunk-5W737WN4.js";T();var E=({activeRoute:n})=>{var i;let{smartSwap:u,tokenRoute:k,pairs:m}=n;if(u){let p=[];return u.routes.forEach(y=>{var d,l;let{intermediaryAmounts:s,tokenRoute:R,pairs:c}=y,o=r({pairs:c,tokenRoute:R}),g=e({input:(d=s[0])!=null?d:"0",decimals:o[0].decimals,showLastNonZeroDecimal:!0}),w=e({input:(l=s[s.length-1])!=null?l:"0",decimals:o[o.length-1].decimals,showLastNonZeroDecimal:!0});p.push({pairs:c,tokens:o,amountIn:g,amountOut:w})}),p}let t=r({pairs:m,tokenRoute:k}),f=e({input:n.amountIn,showLastNonZeroDecimal:!0,decimals:t.length>0?t[0].decimals:a}),h=e({input:n.amountOut,showLastNonZeroDecimal:!0,decimals:t.length>0?(i=t[t.length-1])==null?void 0:i.decimals:a});return[{pairs:m,tokens:t,amountIn:f,amountOut:h}]};export{E as a};
//# sourceMappingURL=chunk-OL6W5D2R.js.map