fix: respond to updated amounts immediately (#3289)
This commit is contained in:
parent
8404c6076c
commit
636abe3b7b
@ -40,10 +40,6 @@ export default function Toolbar({ disabled }: { disabled?: boolean }) {
|
||||
return <Caption.UnsupportedNetwork />
|
||||
}
|
||||
|
||||
if (balance && trade?.inputAmount.greaterThan(balance)) {
|
||||
return <Caption.InsufficientBalance currency={trade.inputAmount.currency} />
|
||||
}
|
||||
|
||||
if (inputCurrency && outputCurrency && isAmountPopulated) {
|
||||
if (!trade || routeIsLoading) {
|
||||
return <Caption.LoadingTrade />
|
||||
@ -51,6 +47,9 @@ export default function Toolbar({ disabled }: { disabled?: boolean }) {
|
||||
if (!routeFound) {
|
||||
return <Caption.InsufficientLiquidity />
|
||||
}
|
||||
if (balance && trade?.inputAmount.greaterThan(balance)) {
|
||||
return <Caption.InsufficientBalance currency={trade.inputAmount.currency} />
|
||||
}
|
||||
if (trade.inputAmount && trade.outputAmount) {
|
||||
return <Caption.Trade trade={trade} />
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ function useComputeSwapInfo(): SwapInfo {
|
||||
() => tryParseCurrencyAmount(amount, (isExactIn ? inputCurrency : outputCurrency) ?? undefined),
|
||||
[inputCurrency, isExactIn, outputCurrency, amount]
|
||||
)
|
||||
const parsedAmountIn = isExactIn ? parsedAmount : undefined
|
||||
const parsedAmountOut = isExactIn ? undefined : parsedAmount
|
||||
|
||||
//@TODO(ianlapham): this would eventually be replaced with routing api logic.
|
||||
const trade = useBestTrade(
|
||||
@ -83,10 +85,10 @@ function useComputeSwapInfo(): SwapInfo {
|
||||
|
||||
const currencyAmounts = useMemo(
|
||||
() => ({
|
||||
[Field.INPUT]: trade.trade?.inputAmount,
|
||||
[Field.OUTPUT]: trade.trade?.outputAmount,
|
||||
[Field.INPUT]: parsedAmountIn || trade.trade?.inputAmount,
|
||||
[Field.OUTPUT]: parsedAmountOut || trade.trade?.outputAmount,
|
||||
}),
|
||||
[trade.trade?.inputAmount, trade.trade?.outputAmount]
|
||||
[parsedAmountIn, parsedAmountOut, trade.trade?.inputAmount, trade.trade?.outputAmount]
|
||||
)
|
||||
|
||||
const allowedSlippage = useAllowedSlippage(trade.trade)
|
||||
|
Loading…
Reference in New Issue
Block a user