refactor: make the price computation in v2 add liquidity a little safer
This commit is contained in:
parent
02ecd727eb
commit
8e055df447
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user