Skip to content

Commit

Permalink
feat:Adapter,Neopin-Pool (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Apr 2, 2024
1 parent 244314e commit 07eff70
Show file tree
Hide file tree
Showing 5 changed files with 91 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 @@ -322,6 +322,7 @@
"mummy-finance",
"nasdex",
"nemesis-dao",
"neopin-pool",
"nexus-mutual",
"nf3-ape",
"nodedao",
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -649,6 +650,7 @@ export const adapters: Adapter[] = [
mummyFinance,
nasdex,
nemesisDao,
neopinPool,
nexusMutual,
nf3Ape,
nodedao,
Expand Down
38 changes: 38 additions & 0 deletions src/adapters/neopin-pool/ethereum/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: '0x2d723f60ad8da76286b2ac120498a5ea6babc792',
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: 1683849600,
}
12 changes: 12 additions & 0 deletions src/adapters/neopin-pool/index.ts
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions src/adapters/neopin-pool/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: '0x1289ae78422b94414c1f827c534a1fe8e31e71aa',
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: 1678406400,
}

0 comments on commit 07eff70

Please sign in to comment.