Using basis points (bips) instead of integers for fee calculations provides greater precision, standardization, and clarity. Here are some key reasons and use cases for using bips instead of integers for fees:
Precision and Avoidance of Floating Point Errors:
Basis points are a standardized unit, where 1 bip = 0.01%. This avoids the need for fractional or floating-point calculations, which can introduce rounding errors. Representing fees in bips (e.g., 150 bips for 1.5%) ensures accuracy in fee calculations, especially for very small percentages.
Compatibility with Financial Systems:
Bips are widely used in traditional finance, so using them for fee calculations makes it easier to align with external systems or integrate with APIs that expect fee inputs in bips.
Clearer Code Readability:
Code that uses bips makes it easier to understand the fee being applied without needing additional comments or calculations.
https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/swan/SwanManager.sol#L80-L81
https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/swan/Swan.sol#L258-L261
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.