Skip to content

Commit

Permalink
Assorted refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro committed Mar 4, 2022
1 parent b923ee0 commit 16a8d10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ export default function useIsAnySwapAffectedUser() {
{ blocksPerFetch: BLOCKS_PER_FETCH }
)

const isAffected = useMemo(() => {
return useMemo(() => {
// The error affects Mainnet
if (chainId !== ChainId.MAINNET) {
return false
}

// Check if any of the tokens has allowance in the router contract
const hasAllowance = result.some(({ result, loading, error, valid }) => {
return result.some(({ result, loading, error, valid }) => {
const allowance = valid && !loading && !error && result ? (result[0] as BigNumber) : undefined
return allowance ? !allowance.isZero() : false
})

return hasAllowance
}, [chainId, result])

return isAffected
}
6 changes: 1 addition & 5 deletions src/custom/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { GpEther as ETHER, WETH9_EXTENDED as WETH } from 'constants/tokens'
import { NATIVE_CURRENCY_BUY_ADDRESS } from '../constants'

export function isNativeAddress(tokenAddress: string, chainId: ChainId) {
if (tokenAddress === 'ETH' || tokenAddress === ETHER.onChain(chainId).symbol) {
return true
}

return false
return tokenAddress === 'ETH' || tokenAddress === ETHER.onChain(chainId).symbol
}

export function toErc20Address(tokenAddress: string, chainId: ChainId): string {
Expand Down

0 comments on commit 16a8d10

Please sign in to comment.