Assign redemption budget lazily in redeem loop - #821
Open
cyc60 wants to merge 5 commits into
Open
Conversation
This was referenced Aug 18, 2026
… into fix/redeem-loop-lazy-budget # Conflicts: # src/redemptions/commands/process_redeemer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replaces the fixed-prefix budget pre-assignment in
process-redeemerwith lazy assignment inside the redeem loop, so skipped positions free their budget for later file entries.Previously
assign_shares_to_redeempre-selected a prefix of file entries summing toqueuedShares, andredeem_positionsworked through that fixed prefix. Every skip inside the loop — meta vault, unharvested vault, LTV > 1, dead position, zero withdrawable, failed simulation or submission — simplycontinued, dropping its budget on the floor: entries after the prefix were never tried, and every subsequent cycle recomputed the exact same prefix, so the shortfall persisted with no escalation.This is aggravated by the positions file being sorted LTV-descending: the most skip-prone positions (closest to liquidation, most likely to be repaid/liquidated) sit exactly at the head of the prefix by construction.
Example. Queue = 300 osETH; file entries: A (200 osETH, LTV > 1 → skipped), B (100 osETH, unharvested vault → skipped), C (150 osETH, healthy), D (200 osETH, healthy).
remaining_shares = 300; A and B are skipped without consuming budget, C redeems 150, D redeems the remaining 150. Redeemed: 300.Implementation:
redeem_positionstakestotal_redemption_sharesand decrementsremaining_sharesonly after a successful submission; each entry contributesmin(unprocessed_shares, live_shares, remaining_shares). The vault withdrawable-assets lookup is factored into_get_vault_withdrawable(cached per vault, unchanged behavior).assign_shares_to_redeemis no longer used by the redeemer daemon (it still drives the aggregation path).Second PR of the redeem-loop stack — based on #820's branch (merge that first), followed by #822.