Skip to content

Commit

Permalink
dfx: include v1 tvl
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Nov 17, 2023
1 parent 180f0b9 commit f61471d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions projects/dfx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ module.exports = {
};

const config = {
arbitrum: { factory: "0x9544995B5312B26acDf09e66E699c34310b7c856", fromBlock: 65832059 },
ethereum: { factory: "0x9adeac3b6d29d9d5e543b8579e803a7cce72c9cd", fromBlock: 16607851 },
polygon: { factory: "0x3591040cE5dF8828b3Ed4Ec39D030F832d43fD53", fromBlock: 39183403 },
arbitrum: [{ factory: "0x9544995B5312B26acDf09e66E699c34310b7c856", fromBlock: 65832059 }],
ethereum: [{ factory: "0x9adeac3b6d29d9d5e543b8579e803a7cce72c9cd", fromBlock: 16607851 }, { factory: "0xd3C1bF5582b5f3029b15bE04a49C65d3226dFB0C", fromBlock: 12459107 }],
polygon: [{ factory: "0x3591040cE5dF8828b3Ed4Ec39D030F832d43fD53", fromBlock: 39183403 }],
}

Object.keys(config).forEach(chain => {
const { factory, fromBlock } = config[chain]
const configs = config[chain]
module.exports[chain] = {
tvl: async (_, _b, _cb, { api, }) => {
const logs = await getLogs({
api,
target: factory,
topics: ['0xe7a19de9e8788cc07c144818f2945144acd6234f790b541aa1010371c8b2a73b'],
eventAbi: 'event NewCurve (address indexed caller, bytes32 indexed id, address indexed curve)',
onlyArgs: true,
fromBlock,
})
let pools = logs.map(log => log.curve)
const logs = []
for (const { factory, fromBlock } of configs) {
logs.push(await getLogs({
api,
target: factory,
topics: ['0xe7a19de9e8788cc07c144818f2945144acd6234f790b541aa1010371c8b2a73b'],
eventAbi: 'event NewCurve (address indexed caller, bytes32 indexed id, address indexed curve)',
onlyArgs: true,
fromBlock,
}))
}
let pools = logs.flat().map(log => log.curve)
if (chain === 'arbitrum') pools = pools.slice(1)
const calls = pools.map(pool => [{ target: pool, params: 0 }, { target: pool, params: 1 }]).flat()
const tokens = await api.multiCall({ abi: 'function numeraires(uint256) view returns (address)', calls })
Expand Down

0 comments on commit f61471d

Please sign in to comment.