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

Use swapFeeManager as owner in mev hook #1305

Merged
merged 5 commits into from
Feb 19, 2025
Merged

Conversation

elshan-eth
Copy link
Contributor

Description

This PR changes the authorization logic for mev hook: if swapFeeManager is set, use it as owner instead of governance.

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

Closes #1300

@elshan-eth elshan-eth requested review from joaobrunoah, EndymionJkb and jubeira and removed request for joaobrunoah February 18, 2025 21:25
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; very clean!

This pattern is starting to get used everywhere, so it makes sense to put it in SingletonAuthentication.

@@ -16,6 +16,11 @@ import { Authentication } from "@balancer-labs/v3-solidity-utils/contracts/helpe
abstract contract SingletonAuthentication is Authentication {
IVault private immutable _vault;

modifier onlySwapFeeManagerOrAuthentication(address pool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe onlySwapFeeManagerOrAuthenticate / onlySwapFeeManagerXorAuthenticate sounds a bit better (xor is what we are actually doing, although the name doesn't sound great. Leaving that to @EndymionJkb :) )

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't want to use exclusiveRole terminology, and have to make it swap-manager specific, maybe onlySwapFeeManagerOrGovernance, or onlySwapFeeManagerIfDefined?

I'd still prefer to have the _ensureAuthenticatedByExclusiveRole function parameterized by the role, and then give the modifiers more specific names, and have them call the generic role authentication (identical to VaultAdmin). It would be most consistent across the whole codebase. Otherwise we're making up different patterns and naming conventions when there's already a suitable one there.

Copy link
Collaborator

@EndymionJkb EndymionJkb left a comment

Choose a reason for hiding this comment

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

Per comments on the other PR, I still suggest using a standard generic function _ensureAuthenticatedByExclusiveRole in the base contract (maybe SingletonAuthentication; wherever it makes sense), and then have either local modifiers, or if they're really all going to be swapFeeManager, the modifier could go up there, too, but separate from the generic authentication logic that just takes a "roleAddress" - in case we have something else that uses a different role later.

@@ -16,6 +16,11 @@ import { Authentication } from "@balancer-labs/v3-solidity-utils/contracts/helpe
abstract contract SingletonAuthentication is Authentication {
IVault private immutable _vault;

modifier onlySwapFeeManagerOrAuthentication(address pool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't want to use exclusiveRole terminology, and have to make it swap-manager specific, maybe onlySwapFeeManagerOrGovernance, or onlySwapFeeManagerIfDefined?

I'd still prefer to have the _ensureAuthenticatedByExclusiveRole function parameterized by the role, and then give the modifiers more specific names, and have them call the generic role authentication (identical to VaultAdmin). It would be most consistent across the whole codebase. Otherwise we're making up different patterns and naming conventions when there's already a suitable one there.

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!

@elshan-eth elshan-eth merged commit 01c1a9b into main Feb 19, 2025
16 checks passed
@elshan-eth elshan-eth deleted the change-mev-hook-permissions branch February 19, 2025 15:34
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.

Use swap fee manager as owner
4 participants