@@ -87,13 +87,11 @@ def redistribute_fees(self):
8787 5. Calls _filter_dusty_bal_incentives to handle dust amounts and final redistribution
8888 """
8989 min_amount = self .run_config .fee_config .min_vote_incentive_amount
90-
9190 for chain in self .run_config .all_chains :
9291 pools_to_redistribute = [p for p in chain .core_pools if p .total_to_incentives_usd < min_amount ]
9392 pools_to_receive = [p for p in chain .core_pools if p .total_to_incentives_usd >= min_amount ]
9493
9594 if not pools_to_receive :
96- # no qualifying pools for chain, send to dao/vebal
9795 for pool in pools_to_redistribute :
9896 amount = pool .total_to_incentives_usd
9997 pool .to_dao_usd += amount * self .run_config .fee_config .noncore_dao_share_pct
@@ -160,11 +158,9 @@ def _handle_aura_min(self, buffer=0):
160158 """
161159 Ensures all pools meet the minimum AURA incentive threshold.
162160
163- 1. Identifies pools below the minimum AURA threshold (or with BAL-only overrides)
164- 2. Moves their AURA amounts to BAL, creating a "debt" to be redistributed
165- 3. Redistributes this debt from other pools' BAL to AURA proportionally
166- 4. Ensures donor pools maintain the minimum threshold after transfers
167- 5. Repeats until all pools meet the threshold or no more transfers are possible
161+ 1. Consolidate under-min pools by moving their AURA to BAL
162+ 2. Redistribute that debt to pools above min by moving their BAL to AURA
163+ 3. Rebalance to maintain target Aura/Balancer ratio
168164 """
169165 min_aura_incentive = Decimal (self .run_config .fee_config .min_aura_incentive * (1 - buffer ))
170166 for chain in self .run_config .all_chains :
@@ -173,9 +169,7 @@ def _handle_aura_min(self, buffer=0):
173169 pools_below_min : List [PoolFee ] = []
174170
175171 for pool in chain .core_pools :
176- if pool .to_aura_incentives_usd < min_aura_incentive or (
177- pool .voting_pool_override == "bal"
178- ):
172+ if pool .to_aura_incentives_usd < min_aura_incentive or pool .voting_pool_override == "bal" :
179173 debt_to_aura += pool .to_aura_incentives_usd
180174 pools_below_min .append (pool )
181175
@@ -187,8 +181,7 @@ def _handle_aura_min(self, buffer=0):
187181 pool .to_aura_incentives_usd = Decimal (0 )
188182
189183 pools_over_min = [
190- p
191- for p in chain .core_pools
184+ p for p in chain .core_pools
192185 if p .to_aura_incentives_usd >= min_aura_incentive and p .to_bal_incentives_usd > 0
193186 ]
194187
@@ -198,20 +191,19 @@ def _handle_aura_min(self, buffer=0):
198191 pools_over_min .sort (key = lambda p : p .to_bal_incentives_usd , reverse = True )
199192 debt_remaining = debt_to_aura
200193 total_available_bal = sum (p .to_bal_incentives_usd for p in pools_over_min )
201-
194+
202195 if total_available_bal == 0 :
203196 break
204-
197+
205198 transfers_made = False
206199 for pool in pools_over_min :
207200 if debt_remaining <= 0 :
208201 break
209-
202+
210203 pool_share = pool .to_bal_incentives_usd / total_available_bal
211204 amount_to_transfer = min (
212205 debt_remaining * pool_share ,
213206 pool .to_bal_incentives_usd ,
214- # ensure pool stays above minimum after transfer
215207 max (Decimal (0 ), pool .to_aura_incentives_usd + pool .to_bal_incentives_usd - min_aura_incentive )
216208 )
217209
@@ -222,9 +214,32 @@ def _handle_aura_min(self, buffer=0):
222214 transfers_made = True
223215
224216 if not transfers_made :
225- logger .warning (f"Warning: Could not redistribute AURA debt on { chain .name } . Remaining: { debt_to_aura } " )
226217 break
227218
219+ self ._rebalance_aura_bal_split (chain , min_aura_incentive )
220+
221+ def _rebalance_aura_bal_split (self , chain , min_aura : Decimal ):
222+ pools = [p for p in chain .core_pools if not p .is_alliance_core_pool and not p .partner and p .total_to_incentives_usd > 0 ]
223+ total = sum (p .to_aura_incentives_usd + p .to_bal_incentives_usd for p in pools )
224+ if not total :
225+ return
226+
227+ to_move = total * self .run_config .aura_vebal_share - sum (p .to_aura_incentives_usd for p in pools )
228+
229+ for pool in sorted (pools , key = lambda p : p .to_bal_incentives_usd if to_move > 0 else p .to_aura_incentives_usd , reverse = True ):
230+ if to_move > 0 and pool .to_bal_incentives_usd > 0 and pool .to_aura_incentives_usd >= min_aura :
231+ move = min (pool .to_bal_incentives_usd , to_move )
232+ pool .to_aura_incentives_usd += move
233+ pool .to_bal_incentives_usd -= move
234+ to_move -= move
235+ elif to_move < 0 :
236+ available = pool .to_aura_incentives_usd - min_aura
237+ if available > 0 :
238+ move = min (available , abs (to_move ))
239+ pool .to_bal_incentives_usd += move
240+ pool .to_aura_incentives_usd -= move
241+ to_move += move
242+
228243 def _filter_dusty_bal_incentives (self ):
229244 """
230245 Handles dust BAL amounts (<$75). Only moves to AURA if it results in meaningful AURA.
@@ -266,13 +281,11 @@ def _filter_dusty_bal_incentives(self):
266281 pool .to_bal_incentives_usd = Decimal (0 )
267282 pool .total_to_incentives_usd = Decimal (0 )
268283
269- # Redistribute to viable pools
270284 for pool in pools_to_receive :
271285 weight = pool .total_earned_fees_usd_twap / total_weight
272286 amount = total_to_redistribute * weight
273287 pool .total_to_incentives_usd += amount
274288 pool .redirected_incentives_usd += amount
275-
276289 if pool .to_aura_incentives_usd >= pool .to_bal_incentives_usd :
277290 pool .to_aura_incentives_usd += amount
278291 else :
0 commit comments