Skip to content

Call redeem_sub_vaults_assets only if needed#717

Open
cyc60 wants to merge 3 commits into
v5-releasefrom
redeem-sub-vaults-fix
Open

Call redeem_sub_vaults_assets only if needed#717
cyc60 wants to merge 3 commits into
v5-releasefrom
redeem-sub-vaults-fix

Conversation

@cyc60
Copy link
Copy Markdown
Contributor

@cyc60 cyc60 commented Apr 28, 2026

No description provided.

Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to avoid unnecessary on-chain redeemSubVaultsAssets calls by skipping meta-vault redemption when the computed sub-vault redemption order is empty.

Changes:

  • Add an early return in _try_redeem_meta_vault() when the computed redemption order is empty (no sub-vault redemption needed).
  • Update _build_meta_vault_redeem_order() to return an empty order when calculateSubVaultsRedemptions() returns no redemptions, and extend tests for empty/nested scenarios.
  • Move exit-queue processing in process() to run only after a successful redemption transaction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/commands/internal/process_redeemer.py Skips meta-vault redemption on empty redeem order; adjusts when exit-queue processing is triggered.
src/commands/tests/test_internal/test_process_redeemer.py Adds/updates unit tests to cover empty redeem order and nested meta-vault redemption-order building.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/internal/process_redeemer.py Outdated
Comment thread src/commands/internal/process_redeemer.py Outdated
Comment thread src/commands/internal/process_redeemer.py Outdated
cyc60 added 2 commits April 30, 2026 15:14
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +177 to +191
"""Run one redemption iteration and always process the exit queue at the end.

The exit-queue call must happen on every iteration (including early-return
paths such as below-threshold queued assets, zero nonce, no positions, or
no eligible positions). Using ``try/finally`` ensures that any early
``return`` inside ``_redeem_os_token_positions`` still runs the exit-queue
step, while exceptions are propagated to the caller as before.
"""
try:
await _redeem_os_token_positions(min_queued_assets=min_queued_assets)
finally:
# Re-fetch block number after redemption processing
# to ensure we read the latest on-chain state.
block_number = await execution_client.eth.block_number
await _process_exit_queue(block_number)
Comment on lines +181 to +193
no eligible positions). Using ``try/finally`` ensures that any early
``return`` inside ``_redeem_os_token_positions`` still runs the exit-queue
step, while exceptions are propagated to the caller as before.
"""
try:
await _redeem_os_token_positions(min_queued_assets=min_queued_assets)
finally:
# Re-fetch block number after redemption processing
# to ensure we read the latest on-chain state.
block_number = await execution_client.eth.block_number
await _process_exit_queue(block_number)


Comment on lines +453 to +461
if not redeem_order:
# No sub-vault redemption is needed for this meta-vault: the on-chain
# calculator reported that withdrawable assets already cover the target.
logger.info(
'No sub-vault redemption needed for meta-vault %s. '
'Proceeding with current withdrawable assets.',
vault_address,
)
return current_withdrawable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants