Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round trip fee guardrail in Recovery Mode #1098

Merged
merged 6 commits into from
Nov 12, 2024
Merged

Conversation

EndymionJkb
Copy link
Collaborator

Description

Apply the same roundtrip fee guardrail on recovery mode that we do with regular proportional withdrawals. If there was a preceding add liquidity operation (which there wouldn't normally be in a recovery mode withdrawal), charge the pool's static swap fee.

To keep recovery mode as simple as possible, this fee is charged to the user (i.e., they receive fewer tokens for their BPT), but the tokens simply remain in the pool, accruing value to the other LPs.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

Resolves #1094

@EndymionJkb EndymionJkb changed the title Round trip recovery Round trip fee guardrail in Recovery Mode Nov 7, 2024
Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

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

LGTM!

This is super overkill, but I'm not against it. I'd love @danielmkm's thoughts on this one.

@@ -744,6 +744,14 @@ contract VaultExtension is IVaultExtension, VaultCommon, Proxy {
return _isPoolInRecoveryMode(pool);
}

// Needed to avoid stack-too-deep.apply
Copy link
Contributor

Choose a reason for hiding this comment

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

💀 dang

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried using a struct for the removeLiquidityRecovery function itself first, as we have elsewhere, but it wasn't enough.

vault.manualEnableRecoveryMode(pool);
// Set the fee, and flag to trigger collection of it.
vault.manualSetStaticSwapFeePercentage(pool, BASE_MAX_SWAP_FEE);
vault.manualSetAddLiquidityCalledFlag(pool, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this one actually. The whole test runs in the same tx.

Maybe just leave a comment, and / or assert that the flag is true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this, but it doesn't seem to be testing the content of the events properly. If that flag is set, it should be charging fees in the original test too, but the expected event doesn't have them, yet it passes. I manually clear the flag in the one that's not supposed to have the roundtrip fee, and that works too.

Testing the balances verifies that the two cases behave differently, but I wonder where else events aren't getting tested.

pkg/vault/test/foundry/RecoveryMode.t.sol Show resolved Hide resolved
pkg/vault/contracts/VaultExtension.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@joaobrunoah joaobrunoah left a comment

Choose a reason for hiding this comment

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

LGTM!

@EndymionJkb EndymionJkb merged commit 652d6a8 into main Nov 12, 2024
13 checks passed
@EndymionJkb EndymionJkb deleted the round-trip-recovery branch November 12, 2024 16:05
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.

Consider roundtrip fees in recovery mode
3 participants