Commit 6a4fa0c9 authored by Justin Domingue's avatar Justin Domingue Committed by GitHub

fix: division by 0 error when both reserves are 0 (#1632)

* set pair to invalid if both reserves are 0

* consider reserve0/1=0 as no liquidity
parent 7fc9a655
...@@ -83,7 +83,14 @@ export function useDerivedMintInfo( ...@@ -83,7 +83,14 @@ export function useDerivedMintInfo(
const totalSupply = useTotalSupply(pair?.liquidityToken) const totalSupply = useTotalSupply(pair?.liquidityToken)
const noLiquidity: boolean = const noLiquidity: boolean =
pairState === PairState.NOT_EXISTS || Boolean(totalSupply && JSBI.equal(totalSupply.quotient, ZERO)) pairState === PairState.NOT_EXISTS ||
Boolean(totalSupply && JSBI.equal(totalSupply.quotient, ZERO)) ||
Boolean(
pairState === PairState.EXISTS &&
pair &&
JSBI.equal(pair.reserve0.quotient, ZERO) &&
JSBI.equal(pair.reserve1.quotient, ZERO)
)
// balances // balances
const balances = useCurrencyBalances(account ?? undefined, [ const balances = useCurrencyBalances(account ?? undefined, [
......
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