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( ...@@ -141,13 +141,9 @@ export function useDerivedMintInfo(
const price = useMemo(() => { const price = useMemo(() => {
if (noLiquidity) { if (noLiquidity) {
const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = parsedAmounts const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = parsedAmounts
if (currencyAAmount && currencyBAmount) { if (currencyAAmount?.greaterThan(0) && currencyBAmount?.greaterThan(0)) {
return new Price( const value = currencyBAmount.divide(currencyAAmount)
currencyAAmount.currency, return new Price(currencyAAmount.currency, currencyBAmount.currency, value.denominator, value.numerator)
currencyBAmount.currency,
currencyAAmount.quotient,
currencyBAmount.quotient
)
} }
return undefined return undefined
} else { } 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