@@ -10,6 +10,28 @@ const MORPHO_POOL_ADDRESSES = {
10
10
const SPARK_POOL_ADDRESSES = {
11
11
'USDC' : '0x3128a0F7f0ea68E7B7c9B00AFa7E41045828e858'
12
12
} ;
13
+ const COMPOUND_TOKEN_ADDRESS = '0xb125E6687d4313864e53df431d5425969c15Eb2F' ;
14
+
15
+ const MOONWELL_POOL_ADDRESSES = {
16
+ 'Moonwell Flagship USDC' : '0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca' ,
17
+ 'USDC' : '0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22'
18
+ } ;
19
+
20
+ async function compoundTvl ( api , owners ) {
21
+ const balanceCalls = owners . map ( owner => ( { target : COMPOUND_TOKEN_ADDRESS , params : [ owner ] } ) ) ;
22
+ const balances = await api . multiCall ( { abi : 'erc20:balanceOf' , calls : balanceCalls } ) ;
23
+ const total = balances . reduce ( ( sum , bal ) => sum + Number ( bal ) / 1e6 , 0 ) ;
24
+ api . add ( COMPOUND_TOKEN_ADDRESS , total ) ;
25
+ }
26
+
27
+ async function moonwellTvl ( api , owners ) {
28
+ const moonwellPools = Object . values ( MOONWELL_POOL_ADDRESSES ) ;
29
+ const balanceCalls = moonwellPools . flatMap ( pool => owners . map ( owner => ( { target : pool , params : [ owner ] } ) ) ) ;
30
+ const balances = await api . multiCall ( { abi : 'erc20:balanceOf' , calls : balanceCalls } ) ;
31
+ balances . forEach ( ( balance , i ) => {
32
+ api . add ( balanceCalls [ i ] . target , balance ) ;
33
+ } ) ;
34
+ }
13
35
14
36
async function aaveTvl ( api , owners ) {
15
37
const balanceCalls = owners . map ( owner => ( { target : AAVE_TOKEN_ADDRESS , params : [ owner ] } ) ) ;
@@ -49,5 +71,7 @@ module.exports = {
49
71
aaveTvl,
50
72
fluidTvl,
51
73
morphoTvl,
52
- sparkTvl
74
+ sparkTvl,
75
+ compoundTvl,
76
+ moonwellTvl
53
77
} ;
0 commit comments