balancer / balancer-v3-monorepo

GNU General Public License v3.0
24 stars 4 forks source link

Aggregate fee precision #729

Closed EndymionJkb closed 2 hours ago

EndymionJkb commented 1 week ago

Description

Fees are stored at full 18-decimal 64-bit precision at the ProtocolFeeController (and calculations are performed on full words), but the aggregate fees are stored with 24-bit precision at the Vault. This corresponds to 0.00001% resolution on fees (which seems like plenty, even for computed values).

As it was, setting fees with a precision greater than this would cause a discrepancy between the ProtocolFeeController's computations (e.g., when splitting fees), and the Vault. If you tried to set a fee of 1.000005%, it would be truncated to 1% in the Vault, so that if you set the fee and then immediately retrieved it, you would not get the same value.

This PR checks for this case at the ProtocolFeeController, and reverts if you try to set a fee with "too high" precision.

Type of change

Checklist:

Issue Resolution

Resolves #602