Generalized swap fee helper #2624
Merged
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
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
Checklist:
master
, or there's a description of how to mergeIssue Resolution
Resolves #2620