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

fix: use correct source address for usdc on Orbit #2324

Merged
merged 9 commits into from
Mar 11, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isTokenArbitrumOneNativeUSDC,
isTokenArbitrumSepoliaNativeUSDC
} from '../util/TokenUtils'
import { isNetwork } from '../util/networks'

/**
* Balance of the child chain's native currency or ERC20 token
Expand All @@ -20,6 +21,9 @@ export function useBalanceOnSourceChain(
const { address: walletAddress } = useAccount()
const [networks] = useNetworks()
const { isDepositMode } = useNetworksRelationship(networks)
const { isOrbitChain: isSourceOrbitChain } = isNetwork(
networks.sourceChain.id
)

const {
erc20: [erc20SourceChainBalances]
Expand Down Expand Up @@ -47,7 +51,10 @@ export function useBalanceOnSourceChain(
isTokenArbitrumOneNativeUSDC(tokenAddressLowercased) ||
isTokenArbitrumSepoliaNativeUSDC(tokenAddressLowercased)
) {
return erc20SourceChainBalances[tokenAddressLowercased] ?? constants.Zero
// because we read parent chain address, make sure we don't read Orbit chain's address if it's the source chain
if (!isSourceOrbitChain) {
return erc20SourceChainBalances[tokenAddressLowercased] ?? constants.Zero
}
}

const tokenChildChainAddress = token.l2Address?.toLowerCase()
Expand Down
Loading