diff --git a/.vscode/launch.json b/.vscode/launch.json index bb1738349..89fa0dabd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -250,6 +250,7 @@ "hundred-finance", "idle", "illuvium", + "infusion", "integral", "interport-finance", "inverse-finance", diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 46de38b04..51ccb325f 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -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' @@ -567,6 +568,7 @@ export const adapters: Adapter[] = [ hundredFinance, idle, illuvium, + infusion, integral, interportFinance, inverseFinance, diff --git a/src/adapters/infusion/base/index.ts b/src/adapters/infusion/base/index.ts new file mode 100644 index 000000000..a28b13609 --- /dev/null +++ b/src/adapters/infusion/base/index.ts @@ -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 = async (ctx, contracts) => { + const balances = await resolveBalances(ctx, contracts, { + pairs: getPairsBalances, + }) + + return { + groups: [{ balances: balances.map((balance) => ({ ...balance, category: 'farm' })) }], + } +} + +export const config: AdapterConfig = { + startDate: 1710374400, +} diff --git a/src/adapters/infusion/index.ts b/src/adapters/infusion/index.ts new file mode 100644 index 000000000..f5a4d121e --- /dev/null +++ b/src/adapters/infusion/index.ts @@ -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