@@ -2,7 +2,7 @@ const sdk = require("@defillama/sdk");
2
2
const abi = require ( "./abi.json" ) ;
3
3
const { stakings } = require ( "../helper/staking" ) ;
4
4
const { pool2s } = require ( "../helper/pool2" ) ;
5
- const { unwrapUniswapLPs } = require ( "../helper/unwrapLPs" ) ;
5
+ const { unwrapUniswapLPs, sumTokens2 , } = require ( "../helper/unwrapLPs" ) ;
6
6
const {
7
7
getChainTransform,
8
8
} = require ( "../helper/portedTokens" ) ;
@@ -120,14 +120,7 @@ const pool2StratsOkex = [
120
120
"0xfa065195657A07f9c9F0A0a5e16DcD0Dff4AF11a" ,
121
121
] ;
122
122
123
- const calcTvl = async (
124
- balances ,
125
- chain ,
126
- block ,
127
- masterchef ,
128
- transformAddress ,
129
- excludePool2
130
- ) => {
123
+ const calcTvl = async ( balances , chain , block , masterchef , transformAddress , excludePool2 ) => {
131
124
const poolLength = (
132
125
await sdk . api . abi . call ( {
133
126
abi : abi . poolLength ,
@@ -137,66 +130,21 @@ const calcTvl = async (
137
130
} )
138
131
) . output ;
139
132
140
- const lpPositions = [ ] ;
133
+ const toa = [ ] ;
134
+ const calls = [ ] ;
141
135
142
- for ( let index = 0 ; index < poolLength ; index ++ ) {
143
- const strat = (
144
- await sdk . api . abi . call ( {
145
- abi : abi . poolInfo ,
146
- target : masterchef ,
147
- params : index ,
148
- chain,
149
- block,
150
- } )
151
- ) . output . strat ;
152
-
153
- const want = (
154
- await sdk . api . abi . call ( {
155
- abi : abi . poolInfo ,
156
- target : masterchef ,
157
- params : index ,
158
- chain,
159
- block,
160
- } )
161
- ) . output . want ;
162
-
163
- const strat_bal = (
164
- await sdk . api . abi . call ( {
165
- abi : 'erc20:balanceOf' ,
166
- target : want ,
167
- params : strat ,
168
- chain,
169
- block,
170
- } )
171
- ) . output ;
172
-
173
- const symbol = (
174
- await sdk . api . abi . call ( {
175
- abi : abi . symbol ,
176
- target : want ,
177
- chain,
178
- block,
179
- } )
180
- ) . output ;
181
-
182
- if (
183
- excludePool2 . some ( ( addr ) => addr . toLowerCase ( ) === want . toLowerCase ( ) ) ||
184
- symbol . includes ( "HC" ) ||
185
- symbol . includes ( "GC" ) ||
186
- symbol . includes ( "HERO" ) ||
187
- symbol . includes ( "HONOR" )
188
- ) {
189
- } else if ( symbol . includes ( "LP" ) || symbol . includes ( "UNI-V2" ) ) {
190
- lpPositions . push ( {
191
- token : want ,
192
- balance : strat_bal ,
193
- } ) ;
194
- } else {
195
- sdk . util . sumSingleBalance ( balances , `${ chain } :${ want } ` , strat_bal ) ;
196
- }
197
- }
136
+ for ( let index = 0 ; index < poolLength ; index ++ ) calls . push ( { params : index } )
198
137
199
- await unwrapUniswapLPs ( balances , lpPositions , block , chain , transformAddress ) ;
138
+ const { output : data } = await sdk . api . abi . multiCall ( {
139
+ target : masterchef ,
140
+ abi : abi . poolInfo ,
141
+ calls,
142
+ chain, block,
143
+ } )
144
+
145
+ data . forEach ( i => toa . push ( [ i . output . want , i . output . strat ] ) )
146
+
147
+ return sumTokens2 ( { balances, chain, block, tokensAndOwners : toa , resolveLP : true , blacklistedTokens : excludePool2 } )
200
148
} ;
201
149
202
150
const bscTvl = async ( chainBlocks ) => {
0 commit comments