Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for non-18 decimals chains #1997

Open
wants to merge 120 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
8c26fad
e2e custom fee token
brtkx Oct 3, 2024
d58b2e8
fix
brtkx Oct 3, 2024
591f930
fixes
brtkx Oct 3, 2024
b882660
fix
brtkx Oct 3, 2024
60a0f25
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 3, 2024
56ff3a2
bump nitro ref
brtkx Oct 3, 2024
803da84
use different deployer wallet
brtkx Oct 4, 2024
9ae9435
fix
brtkx Oct 4, 2024
a664e54
fix
brtkx Oct 4, 2024
6972d52
fixes
brtkx Oct 4, 2024
ed7b34d
fix
brtkx Oct 4, 2024
d2eca87
fix weth
brtkx Oct 4, 2024
3c84690
logs
brtkx Oct 4, 2024
d2e18e2
fix network
brtkx Oct 4, 2024
d313756
logs
brtkx Oct 4, 2024
12a2270
fix
brtkx Oct 4, 2024
8283fdd
fix
brtkx Oct 4, 2024
a4c18a5
try
brtkx Oct 4, 2024
65918a4
fix
brtkx Oct 4, 2024
4886113
fix
brtkx Oct 4, 2024
37a7ef1
fix
brtkx Oct 4, 2024
067b64c
fixes
brtkx Oct 7, 2024
bc2c217
fix
brtkx Oct 7, 2024
59575c8
fix
brtkx Oct 7, 2024
b4b650f
fixes
brtkx Oct 7, 2024
05f2bbd
fix
brtkx Oct 7, 2024
9b5ca65
try
brtkx Oct 7, 2024
9b7e665
fix
brtkx Oct 7, 2024
3125d8e
fix
brtkx Oct 7, 2024
f28912a
fix
brtkx Oct 7, 2024
52eb29e
fix
brtkx Oct 8, 2024
1053116
fix
brtkx Oct 8, 2024
ecd415d
fix
brtkx Oct 8, 2024
3f3b88d
fix
brtkx Oct 8, 2024
e7583be
fix
brtkx Oct 8, 2024
83d290a
fix
brtkx Oct 8, 2024
25dfa4c
fixes
brtkx Oct 8, 2024
f9f632c
logs
brtkx Oct 8, 2024
ebb974f
fixes
brtkx Oct 8, 2024
84f1d2e
fixes
brtkx Oct 8, 2024
d021e89
fixes
brtkx Oct 8, 2024
39dd637
clean up
brtkx Oct 8, 2024
b3a797d
clean up
brtkx Oct 8, 2024
bbf4134
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 8, 2024
b02242c
fix
brtkx Oct 8, 2024
30ee752
fix
brtkx Oct 8, 2024
a7eb5e9
logs
brtkx Oct 8, 2024
10a11ae
logs
brtkx Oct 8, 2024
5dba15f
fix
brtkx Oct 9, 2024
6a2962f
formatting
brtkx Oct 9, 2024
ae8ee3f
fixes
brtkx Oct 9, 2024
57b7063
fix
brtkx Oct 9, 2024
7e575ce
fix
brtkx Oct 9, 2024
ff9704c
whoops
brtkx Oct 9, 2024
f5d180f
fixes
brtkx Oct 9, 2024
23b4c73
fixes
brtkx Oct 9, 2024
07a25fc
fixes
brtkx Oct 9, 2024
d72ee4d
fix
brtkx Oct 9, 2024
4cdd228
bump nitro
brtkx Oct 9, 2024
ef46573
update rollup address, revert nitro ref
brtkx Oct 9, 2024
c67dcd5
fix
brtkx Oct 9, 2024
2caaf94
Merge branch 'master' into e2e-custom-fee-token
brtkx Oct 9, 2024
89004d1
fix
brtkx Oct 10, 2024
1376bbd
Merge branch 'e2e-custom-fee-token' of github.com:OffchainLabs/arbitr…
brtkx Oct 10, 2024
b9f89f7
clean up
brtkx Oct 10, 2024
3a83629
typo
brtkx Oct 10, 2024
01a7d8e
revert default timeout
brtkx Oct 10, 2024
3bb3308
revert
brtkx Oct 10, 2024
c5bd311
Merge branch 'master' into e2e-custom-fee-token
brtkx Oct 10, 2024
5de44b6
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 17, 2024
c1c1d4f
Merge branch 'master' into e2e-custom-fee-token
dewanshparashar Oct 17, 2024
88e4e90
non18 decimals e2e
brtkx Oct 17, 2024
a9825d4
logs
brtkx Oct 17, 2024
f760bc9
fixes
brtkx Oct 17, 2024
9200dbe
updates
brtkx Oct 17, 2024
d12583b
merge
brtkx Oct 17, 2024
f52f409
updates
brtkx Oct 17, 2024
cfe3aac
updates
brtkx Oct 17, 2024
0cede93
updates
brtkx Oct 17, 2024
14f446e
bump sdk
brtkx Oct 17, 2024
91c35b6
fix
brtkx Oct 18, 2024
e1e8c5a
Merge branch 'master' into e2e-custom-fee-token
dewanshparashar Oct 18, 2024
b4dc19b
fix
brtkx Oct 18, 2024
8010212
fix
brtkx Oct 18, 2024
7a0a6e9
Merge branch 'e2e-custom-fee-token' of github.com:OffchainLabs/arbitr…
brtkx Oct 18, 2024
c85a086
fix
brtkx Oct 18, 2024
a0d7974
fix
brtkx Oct 18, 2024
c3e86de
fix
brtkx Oct 18, 2024
18c66d2
fix
brtkx Oct 18, 2024
76987d6
Merge branch 'master' into e2e-custom-fee-token
brtkx Oct 21, 2024
816c3e0
try
brtkx Oct 22, 2024
eb14269
logs
brtkx Oct 22, 2024
702f391
fix
brtkx Oct 22, 2024
4f040ff
fix
brtkx Oct 22, 2024
a3ab216
fix
brtkx Oct 22, 2024
5837521
fix
brtkx Oct 22, 2024
05d02e4
clean up
brtkx Oct 22, 2024
50cf4f4
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 22, 2024
f08047e
Merge branch 'master' into e2e-custom-fee-token
brtkx Oct 22, 2024
2340fdb
Merge branch 'e2e-custom-fee-token' of github.com:OffchainLabs/arbitr…
brtkx Oct 22, 2024
ba25cb5
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 22, 2024
91ffc0a
fix
brtkx Oct 22, 2024
a14966e
logs
brtkx Oct 23, 2024
1337c1b
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 23, 2024
1d5a12f
bump nitro
brtkx Oct 23, 2024
69cba21
6 decimals
brtkx Oct 23, 2024
21f925b
fix approval gas scaling
brtkx Oct 23, 2024
171eea0
clean up
brtkx Oct 23, 2024
3ab56f0
update comments
brtkx Oct 24, 2024
93a3072
fix approvals
brtkx Oct 24, 2024
ef4bddf
Merge branch 'master' into non18-dec-e2e
brtkx Oct 24, 2024
c6ba658
logs
brtkx Oct 24, 2024
c22259a
Merge branch 'non18-dec-e2e' of github.com:OffchainLabs/arbitrum-toke…
brtkx Oct 24, 2024
1abd383
fixes
brtkx Oct 24, 2024
79061b9
clean up
brtkx Oct 24, 2024
ed7c224
clean up
brtkx Oct 24, 2024
d2dac0d
Merge branch 'master' into non18-dec-e2e
fionnachan Oct 28, 2024
29354aa
Merge branch 'master' into non18-dec-e2e
fionnachan Oct 28, 2024
1327837
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
brtkx Oct 31, 2024
607a251
bump sdk
brtkx Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
secrets: inherit

test-e2e:
name: "${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}"
name: "Test E2E - ${{ matrix.test.name }} ${{ matrix.test.typeName }}"
needs: [build, load-e2e-files]
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -99,16 +99,25 @@ jobs:
nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431
l3-node: ${{ matrix.test.type != 'regular' }}
no-l3-token-bridge: ${{ matrix.test.type == 'regular' }}
args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }}
args: >-
${{
(matrix.test.type == 'orbit-eth') && '--l3node --l3-token-bridge' ||
(matrix.test.type == 'orbit-custom-6dec' && '--l3-fee-token --l3-fee-token-decimals 6') ||
(matrix.test.type == 'orbit-custom-18dec' && '--l3-fee-token') ||
(matrix.test.type == 'orbit-custom-20dec' && '--l3-fee-token --l3-fee-token-decimals 20') ||
''
}}

- name: Run e2e tests via cypress-io/github-action
uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # [email protected]
with:
start: yarn start
command: >-
${{
${{
(matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' ||
(matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') ||
(matrix.test.type == 'orbit-custom-6dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') ||
(matrix.test.type == 'orbit-custom-18dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') ||
(matrix.test.type == 'orbit-custom-20dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') ||
(matrix.test.type == 'cctp' && 'yarn test:e2e:cctp --browser chrome') ||
'yarn test:e2e --browser chrome'
}}
Expand All @@ -133,7 +142,7 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ (matrix.test.type == 'cctp' && 'cctp') || (matrix.test.type == 'orbit-eth' && 'l3') || (matrix.test.type == 'orbit-custom' && 'custom-fee-token') || 'regular'}}
name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ matrix.test.type }}
path: |
./packages/arb-token-bridge-ui/cypress/videos
./packages/arb-token-bridge-ui/cypress/screenshots
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/formatSpecfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ switch (testType) {
tests.push({
...spec,
type: "regular",
typeName: "",
});
tests.push({
...spec,
type: "orbit-eth",
typeName: "with L3 (ETH)",
});
tests.push({
...spec,
type: "orbit-custom",
type: "orbit-custom-6dec",
typeName: "with L3 (6 decimals custom)",
});
tests.push({
...spec,
type: "orbit-custom-18dec",
typeName: "with L3 (18 decimals custom)",
});
tests.push({
...spec,
type: "orbit-custom-20dec",
typeName: "with L3 (20 decimals custom)",
});
});
break;
Expand All @@ -27,6 +40,7 @@ switch (testType) {
// Running CCTP tests in parallel cause nonce issues, we're running the two tests sequentially
tests.push({
name: "cctp",
typeName: "",
file: "tests/e2e/specs/**/*Cctp.cy.{js,jsx,ts,tsx}",
recordVideo: false,
type: "cctp",
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"dependencies": {
"@apollo/client": "^3.7.11",
"@arbitrum/sdk": "^4.0.1",
"@arbitrum/sdk": "^4.0.2-beta.1",
"@ethersproject/providers": "^5.7.0",
"@headlessui/react": "^1.7.8",
"@headlessui/tailwindcss": "^0.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { useNetworks } from '../../hooks/useNetworks'
import { useNetworksRelationship } from '../../hooks/useNetworksRelationship'
import { TokenLogoFallback } from './TokenInfo'
import { useBalanceOnSourceChain } from '../../hooks/useBalanceOnSourceChain'
import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain'

function tokenListIdsToNames(ids: number[]): string {
return ids
Expand Down Expand Up @@ -244,6 +245,8 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) {
} = useAppState()
const { isLoading: isLoadingAccountType } = useAccountType()
const { balance, symbol } = useTokenInfo(token)
const nativeCurrencyDecimalsOnSourceChain =
useNativeCurrencyDecimalsOnSourceChain()

const isArbitrumNativeUSDC =
isTokenArbitrumOneNativeUSDC(token?.address) ||
Expand All @@ -266,6 +269,13 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) {
return typeof bridgeTokens[token.address] !== 'undefined'
}, [bridgeTokens, isArbitrumNativeUSDC, token])

const decimals = useMemo(() => {
if (token) {
return token.decimals
}
return nativeCurrencyDecimalsOnSourceChain
}, [nativeCurrencyDecimalsOnSourceChain, token])
fionnachan marked this conversation as resolved.
Show resolved Hide resolved

if (!tokenIsAddedToTheBridge) {
return <span className="arb-hover text-sm">Import</span>
}
Expand All @@ -279,7 +289,7 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) {
<span className="flex items-center whitespace-nowrap text-sm text-white/70">
{balance ? (
formatAmount(balance, {
decimals: token?.decimals,
decimals,
symbol
})
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useLatest } from 'react-use'
import { useAccount, useNetwork, useSigner } from 'wagmi'
import { TransactionResponse } from '@ethersproject/providers'
import { twMerge } from 'tailwind-merge'
import { scaleFrom18DecimalsToNativeTokenDecimals } from '@arbitrum/sdk'

import { useAppState } from '../../state'
import { getNetworkName, isNetwork } from '../../util/networks'
Expand Down Expand Up @@ -77,6 +78,7 @@ import { useIsTransferAllowed } from './hooks/useIsTransferAllowed'
import { MoveFundsButton } from './MoveFundsButton'
import { ProjectsListing } from '../common/ProjectsListing'
import { useAmountBigNumber } from './hooks/useAmountBigNumber'
import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain'

const signerUndefinedError = 'Signer is undefined'
const transferNotAllowedError = 'Transfer not allowed'
Expand Down Expand Up @@ -131,6 +133,8 @@ export function TransferPanel() {
}
} = useLatest(useNetworksRelationship(latestNetworks.current))
const isBatchTransferSupported = useIsBatchTransferSupported()
const nativeCurrencyDecimalsOnSourceChain =
useNativeCurrencyDecimalsOnSourceChain()

const nativeCurrency = useNativeCurrency({ provider: childChainProvider })

Expand Down Expand Up @@ -616,7 +620,7 @@ export function TransferPanel() {
amount: amountBigNumber,
options: {
approvalAmountIncrease: isCustomNativeTokenAmount2
? utils.parseUnits(amount2, nativeCurrency.decimals)
? utils.parseUnits(amount2, nativeCurrencyDecimalsOnSourceChain)
: undefined
}
})
Expand All @@ -631,7 +635,7 @@ export function TransferPanel() {
amount: amountBigNumber,
options: {
approvalAmountIncrease: isCustomNativeTokenAmount2
? utils.parseUnits(amount2, nativeCurrency.decimals)
? utils.parseUnits(amount2, nativeCurrencyDecimalsOnSourceChain)
: undefined
}
})
Expand Down Expand Up @@ -744,6 +748,7 @@ export function TransferPanel() {
}

overrides.maxSubmissionCost = utils
// we are not scaling these to native decimals because arbitrum-sdk does it for us
.parseEther(amount2)
.add(gasEstimates.estimatedChildChainSubmissionCost)
overrides.excessFeeRefundAddress = destinationAddress
Expand Down Expand Up @@ -798,6 +803,20 @@ export function TransferPanel() {

const timestampCreated = String(normalizeTimestamp(Date.now()))

const { isOrbitChain: isSourceOrbitChain } = isNetwork(
latestNetworks.current.sourceChain.id
)

const scaledAmount =
// only scale for native tokens, and
// only scale if sent from Orbit, because it's always 18 decimals there but the UI needs scaled amount
selectedToken || !isSourceOrbitChain
? amountBigNumber
: scaleFrom18DecimalsToNativeTokenDecimals({
amount: amountBigNumber,
decimals: nativeCurrency.decimals
})

const txHistoryCompatibleObject = convertBridgeSdkToMergedTransaction({
bridgeTransfer,
parentChainId: parentChain.id,
Expand All @@ -806,7 +825,7 @@ export function TransferPanel() {
walletAddress,
destinationAddress,
nativeCurrency,
amount: amountBigNumber,
amount: scaledAmount,
amount2: isBatchTransfer ? utils.parseEther(amount2) : undefined,
timestampCreated
})
Expand All @@ -825,7 +844,7 @@ export function TransferPanel() {
walletAddress,
destinationAddress,
nativeCurrency,
amount: amountBigNumber,
amount: scaledAmount,
amount2: isBatchTransfer ? utils.parseEther(amount2) : undefined,
timestampCreated
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Button } from '../../common/Button'
import { useSelectedTokenDecimals } from '../../../hooks/TransferPanel/useSelectedTokenDecimals'
import { useNativeCurrencyBalances } from './useNativeCurrencyBalances'
import { useIsCctpTransfer } from '../hooks/useIsCctpTransfer'
import { useNativeCurrencyDecimalsOnSourceChain } from '../../../hooks/useNativeCurrencyDecimalsOnSourceChain'

function Amount2ToggleButton({
onClick
Expand Down Expand Up @@ -92,6 +93,8 @@ export function SourceNetworkBox() {
const decimals = useSelectedTokenDecimals()
const { errorMessages } = useTransferReadiness()
const nativeCurrencyBalances = useNativeCurrencyBalances()
const nativeCurrencyDecimalsOnSourceChain =
useNativeCurrencyDecimalsOnSourceChain()

const isCctpTransfer = useIsCctpTransfer()

Expand Down Expand Up @@ -145,10 +148,19 @@ export function SourceNetworkBox() {
symbol: nativeCurrency.symbol,
disabled: true,
balance: nativeCurrencyBalances.sourceBalance
? Number(utils.formatEther(nativeCurrencyBalances.sourceBalance))
? Number(
utils.formatUnits(
nativeCurrencyBalances.sourceBalance,
nativeCurrencyDecimalsOnSourceChain
)
)
: undefined
}),
[nativeCurrencyBalances, nativeCurrency.symbol]
[
nativeCurrencyBalances,
nativeCurrency.symbol,
nativeCurrencyDecimalsOnSourceChain
]
)

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { useMemo } from 'react'
import { BigNumber } from 'ethers'

import { ERC20BridgeToken } from '../../../hooks/arbTokenBridge.types'
import { NativeCurrencyErc20 } from '../../../hooks/useNativeCurrency'
import {
NativeCurrencyErc20,
useNativeCurrency
} from '../../../hooks/useNativeCurrency'
import { Loader } from '../../common/atoms/Loader'
import { TokenSymbolWithExplorerLink } from '../../common/TokenSymbolWithExplorerLink'
import { formatAmount } from '../../../util/NumberUtils'

import { NetworkType } from './utils'
import { useNetworks } from '../../../hooks/useNetworks'
import { useNetworksRelationship } from '../../../hooks/useNetworksRelationship'

export function TokenBalance({
forToken,
Expand All @@ -22,6 +28,23 @@ export function TokenBalance({
tokenSymbolOverride?: string
}) {
const isParentChain = on === NetworkType.parentChain
const [networks] = useNetworks()
const { childChainProvider } = useNetworksRelationship(networks)
const nativeCurrency = useNativeCurrency({
provider: childChainProvider
})

const isCustomNativeCurrency =
nativeCurrency.isCustom &&
forToken?.address.toLowerCase() === nativeCurrency.address.toLowerCase()

const decimals = useMemo(() => {
if (!isParentChain && isCustomNativeCurrency) {
// Native currency on Orbit chain, always 18 decimals
return 18
}
return forToken?.decimals
}, [forToken?.decimals, isCustomNativeCurrency, isParentChain])

if (!forToken) {
return null
Expand All @@ -43,7 +66,7 @@ export function TokenBalance({
<span className="font-light">{prefix}</span>
<span aria-label={`${tokenSymbol} balance amount on ${on}`}>
{formatAmount(balance, {
decimals: forToken.decimals
decimals
})}
</span>{' '}
<TokenSymbolWithExplorerLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { defaultErc20Decimals } from '../../../defaults'
import { useGasSummary } from '../../../hooks/TransferPanel/useGasSummary'
import { useNativeCurrency } from '../../../hooks/useNativeCurrency'
import { useNativeCurrencyBalances } from './useNativeCurrencyBalances'
import { useNativeCurrencyDecimalsOnSourceChain } from '../../../hooks/useNativeCurrencyDecimalsOnSourceChain'

export function useMaxAmount() {
const {
Expand All @@ -19,6 +20,8 @@ export function useMaxAmount() {
const { childChainProvider, isDepositMode } =
useNetworksRelationship(networks)
const nativeCurrency = useNativeCurrency({ provider: childChainProvider })
const nativeCurrencyDecimalsOnSourceChain =
useNativeCurrencyDecimalsOnSourceChain()

const { estimatedParentChainGasFees, estimatedChildChainGasFees } =
useGasSummary()
Expand All @@ -36,14 +39,14 @@ export function useMaxAmount() {
if (nativeCurrency.isCustom && isDepositMode) {
return utils.formatUnits(
nativeCurrencySourceBalance,
nativeCurrency.decimals
nativeCurrencyDecimalsOnSourceChain
fionnachan marked this conversation as resolved.
Show resolved Hide resolved
)
}

// ETH deposits and ETH/custom fee token withdrawals
const nativeCurrencyBalanceFormatted = utils.formatUnits(
nativeCurrencySourceBalance,
nativeCurrency.decimals
nativeCurrencyDecimalsOnSourceChain
)

if (
Expand All @@ -70,9 +73,9 @@ export function useMaxAmount() {
estimatedChildChainGasFees,
estimatedParentChainGasFees,
isDepositMode,
nativeCurrency.decimals,
nativeCurrency.isCustom,
nativeCurrencyBalances.sourceBalance
nativeCurrencyBalances.sourceBalance,
nativeCurrencyDecimalsOnSourceChain
])

const maxAmount = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Loader } from '../common/atoms/Loader'
import { sanitizeAmountQueryParam } from '../../hooks/useArbQueryParams'
import { truncateExtraDecimals } from '../../util/NumberUtils'
import { useNativeCurrencyBalances } from './TransferPanelMain/useNativeCurrencyBalances'
import { useSelectedTokenDecimals } from '../../hooks/TransferPanel/useSelectedTokenDecimals'

function MaxButton({
className = '',
Expand Down Expand Up @@ -86,6 +87,7 @@ function SourceChainTokenBalance({
const [networks] = useNetworks()
const { isDepositMode, childChainProvider } =
useNetworksRelationship(networks)
const selectedTokenDecimals = useSelectedTokenDecimals()

const nativeCurrencyBalances = useNativeCurrencyBalances()
const selectedTokenBalances = useSelectedTokenBalances()
fionnachan marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -103,7 +105,7 @@ function SourceChainTokenBalance({
const formattedBalance =
balance !== null
? formatAmount(balance, {
decimals: selectedToken?.decimals ?? nativeCurrency.decimals
decimals: selectedTokenDecimals
})
: null

Expand Down
Loading
Loading