Commit 307a995a authored by Justin Domingue's avatar Justin Domingue Committed by GitHub

fix: handle insufficient input amount error in v2 add liquidity (#1652)

* handle insufficient input amount error in mint/hooks

* use error.isInsufficientInputAmountError

* fixed typo
parent 46911593
......@@ -160,10 +160,16 @@ export function useDerivedMintInfo(
wrappedCurrencyAmount(currencyBAmount, chainId),
]
if (pair && totalSupply && tokenAmountA && tokenAmountB) {
try {
return pair.getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB)
} else {
} catch (error) {
if (error.InsufficientInputAmountError) {
return CurrencyAmount.fromRawAmount(pair.liquidityToken, ZERO)
}
return undefined
}
}
return undefined
}, [parsedAmounts, chainId, pair, totalSupply])
const poolTokenPercentage = useMemo(() => {
......@@ -197,6 +203,10 @@ export function useDerivedMintInfo(
error = 'Insufficient ' + currencies[Field.CURRENCY_B]?.symbol + ' balance'
}
if (!liquidityMinted?.greaterThan(ZERO)) {
error = `Insufficient input amount`
}
return {
dependentField,
currencies,
......
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