The constructor calculates the initial emission rate using the formula:
Because Solidity uses integer division, any fractional part is truncated, potentially leading to a loss of precision in the per-block emission rate.
The use of integer division truncates any decimals. For example, if INITIAL_RATE is 1000e18 and BLOCKS_PER_DAY is 7200, the computed emissionRate will lose the fractional remainder.
example :
Using the provided numbers:
INITIAL_RATE = 1000 * 1e18
BLOCKS_PER_DAY = 7200
The intended per-block emission rate would be approximately 138.888888888888888...e15 tokens. However, integer division will result in a truncated value (e.g., 138888888888888888), missing the fractional component. Over 7200 blocks, the cumulative error could amount to several tokens per day, which may be significant over time.
Over time, small errors in the per-block rate can compound, resulting in a total emission that is lower than intended. This may cause the protocol to distribute fewer tokens than planned, affecting reward expectations for stakeholders.
To mitigate precision loss, consider using a higher-precision arithmetic library or scaling factors. For example, multiply INITIAL_RATE by a precision factor before dividing and then divide out the precision factor later. Alternatively, if acceptable, document the precision loss and adjust INITIAL_RATE accordingly so that the effective emission rate meets the protocol’s requirements.
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.