1
- const SIZE_FACTORY = '0x330Dc31dB45672c1F565cf3EC91F9a01f8f3DF0b'
1
+ const config = {
2
+ base : '0x330Dc31dB45672c1F565cf3EC91F9a01f8f3DF0b' ,
3
+ ethereum : '0x3A9C05c3Da48E6E26f39928653258D7D4Eb594C1'
4
+ }
2
5
3
6
const abis = {
4
7
SizeFactory : {
@@ -13,7 +16,7 @@ const abis = {
13
16
}
14
17
15
18
async function tvl ( api ) {
16
- const markets = await api . call ( { abi : abis . SizeFactory . getMarkets , target : SIZE_FACTORY } )
19
+ const markets = await api . call ( { abi : abis . SizeFactory . getMarkets , target : config [ api . chain ] } )
17
20
const datas = await api . multiCall ( { abi : abis . Size . data , calls : markets } )
18
21
19
22
const borrowATokens = datas . map ( data => data . borrowAToken )
@@ -32,7 +35,7 @@ async function tvl(api) {
32
35
}
33
36
34
37
async function borrowed ( api ) {
35
- const markets = await api . call ( { abi : abis . SizeFactory . getMarkets , target : SIZE_FACTORY } )
38
+ const markets = await api . call ( { abi : abis . SizeFactory . getMarkets , target : config [ api . chain ] } )
36
39
const datas = await api . multiCall ( { abi : abis . Size . data , calls : markets } )
37
40
38
41
const debtTokens = datas . map ( data => data . debtToken )
@@ -43,9 +46,8 @@ async function borrowed(api) {
43
46
return api . add ( underlyingBorrowTokens , totalDebts )
44
47
}
45
48
46
- module . exports = {
47
- base : {
48
- tvl,
49
- borrowed
49
+ Object . keys ( config ) . forEach ( chain => {
50
+ module . exports [ chain ] = {
51
+ tvl, borrowed,
50
52
}
51
- }
53
+ } )
0 commit comments