@@ -77,12 +77,31 @@ def __getattr__(self, name):
7777 def set_core_pool_chains_data (self ):
7878 """
7979 iterate over each chain in `input_fees` and fetch that chain's core pool data
80+ only chains that have core pools are initialized, else the fees are redistributed to other chains
8081 """
8182 _chains = {}
83+ unallocated_fees = {}
84+
8285 for chain_name , fees in self .input_fees .items ():
8386 chain = CorePoolChain (self , chain_name , fees , self .w3_by_chain [chain_name ])
8487 chain .set_pool_fee_data ()
85- _chains [chain_name ] = chain
88+
89+ if chain .pool_fee_data :
90+ _chains [chain_name ] = chain
91+ else :
92+ print (f"no core pools for { chain_name } . allocating fees to other chains..." )
93+ unallocated_fees [chain_name ] = Decimal (fees )
94+
95+ # second pass; redistibute unallocated fees pro rata
96+ if unallocated_fees and _chains :
97+ total_earned_fees = sum (chain .total_earned_fees_usd_twap for chain in _chains .values ())
98+ total_unallocated = sum (unallocated_fees .values ())
99+
100+ for chain in _chains .values ():
101+ if total_earned_fees > 0 :
102+ chain_share = chain .total_earned_fees_usd_twap / total_earned_fees
103+ chain .fees_collected += total_unallocated * chain_share
104+ print (f"adding { total_unallocated * chain_share } fees to { chain .name } ({ chain_share :.2%} of unallocated fees)" )
86105
87106 self ._chains = _chains
88107
@@ -132,7 +151,7 @@ def total_to_incentives_usd(self) -> Decimal:
132151 @property
133152 @round (4 )
134153 def total_fees_collected_usd (self ) -> Decimal :
135- return sum ([ chain .fees_collected for chain in self .all_chains if len ( chain . core_pools ) > 0 ] )
154+ return sum (chain .fees_collected for chain in self .all_chains )
136155
137156
138157class CorePoolChain (AbstractCorePoolChain ):
@@ -203,6 +222,9 @@ def _fetch_and_process_pool_fee_data(self) -> list[PoolFeeData]:
203222 """
204223 fetches various chain data from subgraph and returns a list of `PoolFeeData` based on the core pool list
205224 """
225+ if not self .bal_pools_gauges .core_pools :
226+ return []
227+
206228 logger .info (f"getting snapshots for { self .name } " )
207229
208230 start_snaps = self .subgraph .get_balancer_pool_snapshots (
0 commit comments