UNPKG

@multiversx/sdk-dapp-swap

Version:

A library to hold the main logic for swapping between tokens on the MultiversX blockchain

3 lines (2 loc) 654 B
import{f as o}from"./chunk-5W737WN4.js";o();import s from"bignumber.js";var w=({activeRoute:i})=>{var r,a;if(!i)return;let{pairs:p,smartSwap:e,maxPriceDeviationPercent:c,tokensPriceDeviationPercent:m}=i,P=!e&&p.length===1,t=new s((a=(r=e==null?void 0:e.tokensPriceDeviationPercent)!=null?r:m)!=null?a:0),n=new s(c),v=t.isGreaterThan(c),g=Boolean(P&&v),l=n.times(100).times(.33).dividedBy(100),I=n.times(100).times(.66).dividedBy(100);return{priceImpactLevel:t.isLessThan(l)?"normal":t.isLessThan(I)?"high":"veryHigh",canShowPriceImpactWarning:g,priceImpactPercentage:t.times(100).toString(10)}};export{w as a}; //# sourceMappingURL=chunk-NO6S3H3V.js.map