Skip to content

Commit

Permalink
Fix for COW balance button rounding issue (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
nenadV91 authored Apr 6, 2022
1 parent cb1af37 commit 2144d12
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/custom/components/CowBalanceButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCombinedBalance } from 'state/cowToken/hooks'
import { ChainId } from 'state/lists/actions/actionsMod'
import { formatMax, formatSmartLocaleAware } from 'utils/format'
import { AMOUNT_PRECISION } from 'constants/index'
import { COW } from 'constants/tokens'

export const Wrapper = styled.div`
${({ theme }) => theme.card.boxShadow};
Expand Down Expand Up @@ -44,11 +45,13 @@ interface CowBalanceButtonProps {
onClick?: () => void
}

const COW_DECIMALS = COW[ChainId.MAINNET].decimals

export default function CowBalanceButton({ onClick }: CowBalanceButtonProps) {
const combinedBalance = useCombinedBalance()

const formattedBalance = formatSmartLocaleAware(combinedBalance, AMOUNT_PRECISION)
const formattedMaxBalance = formatMax(combinedBalance, AMOUNT_PRECISION)
const formattedMaxBalance = formatMax(combinedBalance, COW_DECIMALS)

return (
<Wrapper onClick={onClick}>
Expand Down

0 comments on commit 2144d12

Please sign in to comment.