1- const sdk = require ( '@defillama/sdk' )
21const { sumTokensExport } = require ( '../helper/sumTokens' )
32const ADDRESSES = require ( '../helper/coreAssets.json' )
43const { defaultTokens } = require ( '../helper/cex' )
54const { getConfig } = require ( '../helper/cache.js' )
6- const { getStakedSol } = require ( '../helper/solana' )
75
86const API_URL = 'https://api.backpack.exchange/api/v1/wallets'
97
@@ -66,31 +64,18 @@ CHAINS.forEach((chain) => {
6664 }
6765
6866 const options = { ...entry , owners, tokens, chain, blacklistedTokens }
69- if ( chain === 'solana' || chain === 'eclipse' ) options . solOwners = owners
70- if ( chain === 'ton' ) options . onlyWhitelistedTokens = true
71- if ( chain === 'aptos' && Array . isArray ( fungibleAssets ) ) options . fungibleAssets = fungibleAssets
7267
73- if ( chain === 'solana' ) {
74- const balances = await sumTokensExport ( options ) ( )
75-
76- if ( Array . isArray ( owners ) && owners . length ) {
77- const uniqOwners = [ ...new Set ( owners ) ]
78- const BATCH = 50
79- let totalStaked = 0
80- for ( let i = 0 ; i < uniqOwners . length ; i += BATCH ) {
81- const chunk = uniqOwners . slice ( i , i + BATCH )
82- const parts = await Promise . all ( chunk . map ( addr => getStakedSol ( addr ) ) )
83- totalStaked += parts . reduce ( ( a , b ) => a + b , 0 )
84- }
85- sdk . util . sumSingleBalance ( balances , `solana:${ ADDRESSES . solana . SOL } ` , totalStaked )
86- }
87-
88- return balances
68+ switch ( chain ) {
69+ case 'solana' : options . includeStakedSol = true
70+ case 'eclipse' : options . solOwners = owners ; break
71+ case 'ton' : options . onlyWhitelistedTokens = true ; break
72+ case 'aptos' :
73+ if ( Array . isArray ( fungibleAssets ) ) options . fungibleAssets = fungibleAssets
74+ break
8975 }
90-
9176 return sumTokensExport ( options ) ( )
9277 }
9378 }
9479} )
9580
96- module . exports = exportObj
81+ module . exports = exportObj
0 commit comments