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
This commit is contained in:
Justin Domingue 2021-05-18 12:50:28 -07:00 committed by GitHub
parent 7fc9a655fc
commit 6a4fa0c9bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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, [