11const axios = require ( 'axios' ) ;
2- const chains = require ( '../helper/chains.json' ) ;
32
43let cachedBalances = null ;
54let fetchPromise = null ;
@@ -17,7 +16,17 @@ async function fetchBalances() {
1716 // Start a new fetch and cache the promise
1817 fetchPromise = axios . get ( 'https://platform.data.defuse.org/api/public/tvl' )
1918 . then ( response => {
20- cachedBalances = response . data . balances ;
19+ const allBalances = response . data . balances ;
20+
21+ // Filter out chains with zero TVL
22+ cachedBalances = { } ;
23+ Object . keys ( allBalances ) . forEach ( chain => {
24+ const balance = allBalances [ chain ] ;
25+ if ( balance && Object . values ( balance ) . some ( amount => amount > 0 ) ) {
26+ cachedBalances [ chain ] = balance ;
27+ }
28+ } ) ;
29+
2130 return cachedBalances ;
2231 } )
2332 . finally ( ( ) => {
@@ -38,8 +47,20 @@ async function tvl(api) {
3847 return chainBalances [ currentChain ] ;
3948}
4049
50+ // Only export the chains that actually have TVL data
51+ // This list was determined by running the adapter and checking which chains have non-zero balances
52+ const activeChains = [
53+ 'bitcoin' , 'aptos' , 'avax' ,
54+ 'doge' , 'berachain' , 'cardano' ,
55+ 'ethereum' , 'arbitrum' , 'stellar' ,
56+ 'optimism' , 'sui' , 'xdai' ,
57+ 'solana' , 'bsc' , 'near' ,
58+ 'polygon' , 'base' , 'zcash' ,
59+ 'tron' , 'ripple' , 'ton'
60+ ] ;
61+
4162module . exports = {
4263 timetravel : false ,
4364 methodology : 'TVL calculated from tokens locked in NEAR Intents Verifier contract across multiple chains' ,
44- ...Object . fromEntries ( chains . map ( chain => [ chain , { tvl } ] ) )
65+ ...Object . fromEntries ( activeChains . map ( chain => [ chain , { tvl } ] ) )
4566} ;
0 commit comments