diff --git a/.vscode/launch.json b/.vscode/launch.json index a9bcdf93e..4d9c0c5e1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -322,6 +322,7 @@ "mummy-finance", "nasdex", "nemesis-dao", + "neopin-pool", "nexus-mutual", "nf3-ape", "nodedao", diff --git a/src/adapters/index.ts b/src/adapters/index.ts index d01b38bb9..1b8e1a1c7 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -231,6 +231,7 @@ import multichain from '@adapters/multichain' import mummyFinance from '@adapters/mummy-finance' import nasdex from '@adapters/nasdex' import nemesisDao from '@adapters/nemesis-dao' +import neopinPool from '@adapters/neopin-pool' import nexusMutual from '@adapters/nexus-mutual' import nf3Ape from '@adapters/nf3-ape' import nodedao from '@adapters/nodedao' @@ -649,6 +650,7 @@ export const adapters: Adapter[] = [ mummyFinance, nasdex, nemesisDao, + neopinPool, nexusMutual, nf3Ape, nodedao, diff --git a/src/adapters/neopin-pool/ethereum/index.ts b/src/adapters/neopin-pool/ethereum/index.ts new file mode 100644 index 000000000..f979ac5df --- /dev/null +++ b/src/adapters/neopin-pool/ethereum/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: '0x2d723f60ad8da76286b2ac120498a5ea6babc792', + 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 }], + } +} + +export const config: AdapterConfig = { + startDate: 1683849600, +} diff --git a/src/adapters/neopin-pool/index.ts b/src/adapters/neopin-pool/index.ts new file mode 100644 index 000000000..5b73c680a --- /dev/null +++ b/src/adapters/neopin-pool/index.ts @@ -0,0 +1,12 @@ +import type { Adapter } from '@lib/adapter' + +import * as ethereum from './ethereum' +import * as polygon from './polygon' + +const adapter: Adapter = { + id: 'neopin-pool', + ethereum: ethereum, + polygon: polygon, +} + +export default adapter diff --git a/src/adapters/neopin-pool/polygon/index.ts b/src/adapters/neopin-pool/polygon/index.ts new file mode 100644 index 000000000..942d240c5 --- /dev/null +++ b/src/adapters/neopin-pool/polygon/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: '0x1289ae78422b94414c1f827c534a1fe8e31e71aa', + 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 }], + } +} + +export const config: AdapterConfig = { + startDate: 1678406400, +}