Skip to content

Commit

Permalink
Merge pull request #230 from lc-labs/feature/add-defillama-aggregator
Browse files Browse the repository at this point in the history
add support for defillama aggregator
  • Loading branch information
jankjr authored Oct 24, 2023
2 parents dcb51ca + a3001c4 commit a61b2d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@popperjs/core": "^2.11.5",
"@rainbow-me/rainbowkit": "1.0.11",
"@react-spring/web": "^9.7.1",
"@reserve-protocol/token-zapper": "2.6.11",
"@reserve-protocol/token-zapper": "2.7.0",
"@uiw/react-md-editor": "^3.20.5",
"@uniswap/permit2-sdk": "^1.2.0",
"@viem/anvil": "^0.0.6",
Expand Down
27 changes: 23 additions & 4 deletions src/views/issuance/components/zap/state/zapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Web3Provider } from '@ethersproject/providers'
import {
Universe,
baseConfig,
createDefillama,
createKyberswap,
ethereumConfig,
setupBaseZapper,
Expand All @@ -13,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 @@ -70,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 @@ -86,7 +91,21 @@ export const zapperState = loadable(
chainIdToConfig[provider.network.chainId].config,
chainIdToConfig[provider.network.chainId].setup
)
universe.dexAggregators.push(createKyberswap('KyberSwap', universe, 10))

universe.dexAggregators.push(createKyberswap('KyberSwap', universe, 50))

if (provider.network.chainId === ChainId.Mainnet) {
universe.dexAggregators.push(
createDefillama('DefiLlama:0x', universe, 10, 'Matcha/0x')
)
universe.dexAggregators.push(
createDefillama('DefiLlama:HashFlow', universe, 10, 'Hashflow')
)
} else if (provider.network.chainId === ChainId.Base) {
universe.dexAggregators.push(
createDefillama('DefiLlama:0x', universe, 10, 'Matcha/0x')
)
}
return universe
} catch (e) {
mixpanel.track('Failed zapper set up', {
Expand Down

0 comments on commit a61b2d5

Please sign in to comment.