fix: handle insufficient input amount error in v2 add liquidity (#1652)
* handle insufficient input amount error in mint/hooks * use error.isInsufficientInputAmountError * fixed typo
This commit is contained in:
parent
46911593e5
commit
307a995a50
@ -160,10 +160,16 @@ export function useDerivedMintInfo(
|
||||
wrappedCurrencyAmount(currencyBAmount, chainId),
|
||||
]
|
||||
if (pair && totalSupply && tokenAmountA && tokenAmountB) {
|
||||
return pair.getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB)
|
||||
} else {
|
||||
return undefined
|
||||
try {
|
||||
return pair.getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB)
|
||||
} 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,
|
||||
|
Loading…
Reference in New Issue
Block a user