Skip to content

Commit a914c79

Browse files
amedrontadoraamedrontadora
andauthored
Zuit: add Zuit TVL (DefiLlama#12422)
Co-authored-by: amedrontadora <[email protected]>
1 parent 1f8e0ef commit a914c79

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

projects/zuit/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { sumTokens2 } = require('../helper/unwrapLPs')
2+
const { getLogs2 } = require('../helper/cache/getLogs')
3+
4+
async function tvl(api) {
5+
const { fromBlock, baseFactorys, stableFactorys, oasisFactorys = [] } = config[api.chain]
6+
7+
let logs = await Promise.all([baseFactorys, stableFactorys, oasisFactorys].flat().map(getFactoryLogs))
8+
logs = logs.flat()
9+
10+
const ownerTokens = logs.map(({ token0, token1, pool }) => [[token0, token1], pool])
11+
return sumTokens2({ api, ownerTokens})
12+
13+
async function getFactoryLogs(target) {
14+
return getLogs2({
15+
api,
16+
target,
17+
fromBlock,
18+
eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, address pool)',
19+
})
20+
}
21+
}
22+
23+
const config = {
24+
zircuit: {
25+
fromBlock: 1374699,
26+
baseFactorys: ['0xE4CF807E351b56720B17A59094179e7Ed9dD3727'],
27+
stableFactorys: ['0x40d660504eB163708d8AC8109fc8F2c063ddAE4b'],
28+
oasisFactorys: ['0xE14f6575F4721F404FFB79DA76e4790AD67B960A']
29+
}
30+
}
31+
32+
Object.keys(config).forEach(chain => { module.exports[chain] = { tvl } })

0 commit comments

Comments
 (0)