Skip to content

Conversation

EndymionJkb
Copy link
Collaborator

Description

This parallels PR 1537 in v3, generalizing the swap fee helper to support multiple partners in a single contract. It works generally the same; the main difference is that pools have control of swap fees in v2, while in v3 it's all centralized in the Vault. While in v3 we just need to grant a single permission for the contract to call a function on the Vault, in v2 governance must grant the contract permission to call the function on each pool type (the actionId is the same for all pools from a given factory).

This upgrades the OZ infrastructure to support the new functionality for parity with v3. In keeping with the rest of v2, the OZ files are not imported, but copied into the relevant library.

Since we don't have custom errors in v2, this adds new errors to BalancerErrors. In order to reuse the tests from v3, equivalent test infrastructure had to be added as well.

It also uses bytes32 poolIds instead of pool addresses, as that is how v2 identifies pools. In order to test the "unregistered pool" functionality, the MockVault now needed to implement registration and poolId handling.

Otherwise, the interface is the same as v3.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests are included for all code paths
  • The base branch is either master, or there's a description of how to merge

Issue Resolution

Resolves #2620

@EndymionJkb EndymionJkb requested a review from jubeira September 16, 2025 01:55
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.

Awesome job @EndymionJkb, this was very clean!

I had a few comments that I had to delete upon a closer look, so this seems good to go.

The only thing (outside the diff) is that standalone-utils doesn't run forge tests in CI. Can we add that before merging? (check test-pool-weighted for reference if needed).

Thanks for pushing this!

@EndymionJkb EndymionJkb merged commit 46a0969 into master Sep 17, 2025
16 checks passed
@EndymionJkb EndymionJkb deleted the generalized-helper branch September 17, 2025 20:36
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.

Swap fee helper for weighted pools
2 participants