@openocean.finance/widget
Version:
Openocean Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
14 lines • 692 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 || !toTokenPrice) {
return 0;
}
console.log('fromTokenPrice', fromTokenPrice);
console.log('toTokenPrice', toTokenPrice);
console.log('fromTokenPrice / toTokenPrice', fromTokenPrice / toTokenPrice);
const priceImpact = toTokenPrice / fromTokenPrice - 1;
return priceImpact;
};
//# sourceMappingURL=getPriceImpact.js.map