@lifi/widget
Version:
LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
11 lines • 496 B
JavaScript
import { formatTokenPrice } from './format.js';
export const getPriceImpact = ({ fromToken, toToken, fromAmount, toAmount, }) => {
const fromTokenPrice = formatTokenPrice(fromAmount, fromToken.priceUSD, fromToken.decimals);
const toTokenPrice = formatTokenPrice(toAmount, toToken.priceUSD, toToken.decimals);
if (!fromTokenPrice) {
return 0;
}
const priceImpact = toTokenPrice / fromTokenPrice - 1;
return priceImpact;
};
//# sourceMappingURL=getPriceImpact.js.map