Skip to content

Commit

Permalink
feat:Adapter,Infusion,Base (#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Mar 25, 2024
1 parent 785b2cc commit fac9b64
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
"hundred-finance",
"idle",
"illuvium",
"infusion",
"integral",
"interport-finance",
"inverse-finance",
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import houdiniSwap from '@adapters/houdini-swap'
import hundredFinance from '@adapters/hundred-finance'
import idle from '@adapters/idle'
import illuvium from '@adapters/illuvium'
import infusion from '@adapters/infusion'
import integral from '@adapters/integral'
import interportFinance from '@adapters/interport-finance'
import inverseFinance from '@adapters/inverse-finance'
Expand Down Expand Up @@ -567,6 +568,7 @@ export const adapters: Adapter[] = [
hundredFinance,
idle,
illuvium,
infusion,
integral,
interportFinance,
inverseFinance,
Expand Down
38 changes: 38 additions & 0 deletions src/adapters/infusion/base/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: '0x2d9a3a2bd6400ee28d770c7254ca840c82faf23f',
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: balances.map((balance) => ({ ...balance, category: 'farm' })) }],
}
}

export const config: AdapterConfig = {
startDate: 1710374400,
}
10 changes: 10 additions & 0 deletions src/adapters/infusion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Adapter } from '@lib/adapter'

import * as base from './base'

const adapter: Adapter = {
id: 'infusion',
base: base,
}

export default adapter

0 comments on commit fac9b64

Please sign in to comment.