balancer / balancer-v3-monorepo

GNU General Public License v3.0
30 stars 7 forks source link

Re-arrange `setSwapFeePercentage`, improve registration coverage #690

Closed jubeira closed 1 month ago

jubeira commented 1 month ago

Description

Looking into #463 and trying to squeeze some bytes out of the main Vault, I realized that we had very little tests for vault registration in general.

We have coverage for hook / pool flags, pause / swap manager, etc, but the basics were not there. In the process I also found a small bug: you could register a pool with fees outside the boundaries that the pool should be enforcing, and you could even set percentages slightly larger than FP(1) which makes no sense at all.

On the other hand, the library was enforcing that percentages fit in 24 bits. While that's fine in terms of storage, it doesn't make sense to store percentages larger than FP(1), which given the right constants to encode should fit in 24 bits or less. To enforce this, I made a small test that checks that the constants are OK, and I made the percentage setters at the library more strict (instead of checking whether the encoded value fits, check the input directly).

EDIT: after some back and forth I've decided to keep _setSwapFeePercentage in VaultCommon to keep the library consistent. In any case the library shall not be used elsewhere in production code. Testing was improved to cover edge cases around registration.

Type of change

Checklist:

Issue Resolution

Closes #463