Skip to content

Commit

Permalink
Use ChainId rather than constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jankjr committed Oct 23, 2023
1 parent 83900a3 commit a3001c4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/views/issuance/components/zap/state/zapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Web3Provider } from '@ethersproject/providers'
import {
Universe,
baseConfig,
createKyberswap,
createDefillama,
createKyberswap,
ethereumConfig,
setupBaseZapper,
setupEthereumZapper,
Expand All @@ -14,6 +14,7 @@ import { loadable } from 'jotai/utils'
import mixpanel from 'mixpanel-browser'
import { chainIdAtom, clientAtom } from 'state/atoms'
import { onlyNonNullAtom, simplifyLoadable } from 'utils/atoms/utils'
import { ChainId } from 'utils/chains'
import { PublicClient } from 'viem'

export function publicClientToProvider(publicClient: PublicClient) {
Expand Down Expand Up @@ -71,12 +72,15 @@ export const zapperState = loadable(
provider.on('error', () => {})

try {
const chainIdToConfig: Record<number, { config: any, setup: (uni: Universe<any>) => Promise<any> }> = {
1: {
const chainIdToConfig: Record<
number,
{ config: any; setup: (uni: Universe<any>) => Promise<any> }
> = {
[ChainId.Mainnet]: {
config: ethereumConfig,
setup: setupEthereumZapper,
},
8453: {
[ChainId.Base]: {
config: baseConfig,
setup: setupBaseZapper,
},
Expand All @@ -89,17 +93,17 @@ export const zapperState = loadable(
)

universe.dexAggregators.push(createKyberswap('KyberSwap', universe, 50))
if (provider.network.chainId === 1) {

if (provider.network.chainId === ChainId.Mainnet) {
universe.dexAggregators.push(
createDefillama('DefiLlama:0x', universe, 10, "Matcha/0x")
createDefillama('DefiLlama:0x', universe, 10, 'Matcha/0x')
)
universe.dexAggregators.push(
createDefillama('DefiLlama:HashFlow', universe, 10, "Hashflow")
createDefillama('DefiLlama:HashFlow', universe, 10, 'Hashflow')
)
} else if (provider.network.chainId === 8453) {
} else if (provider.network.chainId === ChainId.Base) {
universe.dexAggregators.push(
createDefillama('DefiLlama:0x', universe, 10, "Matcha/0x")
createDefillama('DefiLlama:0x', universe, 10, 'Matcha/0x')
)
}
return universe
Expand Down

0 comments on commit a3001c4

Please sign in to comment.