Skip to content

Commit

Permalink
feat:Adapter,VulcanDex (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Apr 2, 2024
1 parent ade6014 commit 8643db0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/adapters/vulcandex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Adapter } from '@lib/adapter'

import * as polygon from './polygon'

const adapter: Adapter = {
id: 'vulcandex',
polygon: polygon,
}

export default adapter
38 changes: 38 additions & 0 deletions src/adapters/vulcandex/polygon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { AdapterConfig, BaseContext, GetBalancesHandler } from '@lib/adapter'
import { resolveBalances } from '@lib/balance'
import { getPairsContracts } from '@lib/uniswap/v2/factory'
import { getPairsBalances } from '@lib/uniswap/v2/pair'

export const getContracts = async (ctx: BaseContext, props: any) => {
const offset = props.pairOffset || 0
const limit = 100

const { pairs, allPairsLength } = await getPairsContracts({
ctx,
factoryAddress: '0x293f45b6f9751316672da58ae87447d712af85d7',
offset,
limit,
})

return {
contracts: { pairs },
revalidate: 60 * 60,
revalidateProps: {
pairOffset: Math.min(offset + limit, allPairsLength),
},
}
}

export const getBalances: GetBalancesHandler<typeof getContracts> = async (ctx, contracts) => {
const balances = await resolveBalances<typeof getContracts>(ctx, contracts, {
pairs: getPairsBalances,
})

return {
groups: [{ balances }],
}
}

export const config: AdapterConfig = {
startDate: 1710806400,
}

0 comments on commit 8643db0

Please sign in to comment.