@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.
19 lines (16 loc) • 457 B
text/typescript
import type { RouteExtended } from '@openocean.finance/widget-sdk'
import { getPriceImpact } from '../utils/getPriceImpact.js'
export const usePriceImpact = (route?: RouteExtended) => {
let priceImpact = 0
if (route) {
priceImpact = getPriceImpact({
fromAmount: BigInt(route?.fromAmount),
toAmount: BigInt(route?.toAmount),
fromToken: route?.fromToken,
toToken: route?.toToken,
})
}
return {
priceImpact,
}
}