Commit 88712b50 authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

fix: adjust max button for native currencies (#3279)

* adjust max button for native currencies

* update var naming
parent 1af34ae0
...@@ -10,6 +10,7 @@ import styled, { ThemedText } from 'lib/theme' ...@@ -10,6 +10,7 @@ import styled, { ThemedText } from 'lib/theme'
import { useMemo } from 'react' import { useMemo } from 'react'
import { TradeState } from 'state/routing/types' import { TradeState } from 'state/routing/types'
import { formatCurrencyAmount } from 'utils/formatCurrencyAmount' import { formatCurrencyAmount } from 'utils/formatCurrencyAmount'
import { maxAmountSpend } from 'utils/maxAmountSpend'
import Column from '../Column' import Column from '../Column'
import Row from '../Row' import Row from '../Row'
...@@ -59,12 +60,15 @@ export default function Input({ disabled }: InputProps) { ...@@ -59,12 +60,15 @@ export default function Input({ disabled }: InputProps) {
//TODO(ianlapham): mimic logic from app swap page //TODO(ianlapham): mimic logic from app swap page
const mockApproved = true const mockApproved = true
// account for gas needed if using max on native token
const maxAmount = useMemo(() => maxAmountSpend(balance), [balance])
const onMax = useMemo(() => { const onMax = useMemo(() => {
if (balance?.greaterThan(0)) { if (maxAmount?.greaterThan(0)) {
return () => updateSwapInputAmount(balance.toExact()) return () => updateSwapInputAmount(maxAmount.toExact())
} }
return return
}, [balance, updateSwapInputAmount]) }, [maxAmount, updateSwapInputAmount])
return ( return (
<InputColumn gap={0.5} approved={mockApproved}> <InputColumn gap={0.5} approved={mockApproved}>
......
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