Commit 8e055df4 authored by Moody Salem's avatar Moody Salem

refactor: make the price computation in v2 add liquidity a little safer

parent 02ecd727
......@@ -141,13 +141,9 @@ export function useDerivedMintInfo(
const price = useMemo(() => {
if (noLiquidity) {
const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = parsedAmounts
if (currencyAAmount && currencyBAmount) {
return new Price(
currencyAAmount.currency,
currencyBAmount.currency,
currencyAAmount.quotient,
currencyBAmount.quotient
)
if (currencyAAmount?.greaterThan(0) && currencyBAmount?.greaterThan(0)) {
const value = currencyBAmount.divide(currencyAAmount)
return new Price(currencyAAmount.currency, currencyBAmount.currency, value.denominator, value.numerator)
}
return undefined
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment