The Pump Science protocol implements a dynamic fee structure with three phases, where Phase 2 (slots 150-250) uses a linear decrease formula. The fee calculation is implemented in the calculate_fee() function:
The issue lies in the integer division by 100_000 which happens before the fee calculation. This order of operations can lead to precision loss due to integer division rounding. For example:
This means users could be charged slightly incorrect fees during Phase 2, though the impact is minimal due to the small rounding differences.
Users may be charged slightly incorrect fees during Phase 2 due to precision loss in integer division.
Consider reordering the operations to minimize precision loss:
