The function _obtain_price_params
suffers from potential precision loss due to integer division when calculating the number of elapsed periods. This issue can result in delayed updates to price parameters, affecting accuracy in reward distribution.
The issue arises in this section:
Since Solidity/Vyper uses integer division, if parameters_ts - params.last_profit_update
is slightly less than period
, the division results in 0.
Example:
Realistic Scenario:
Assume params.last_profit_update = 1,000,000
Assume parameters_ts = 1,000,599
Assume period = 7 * 86400 = 604800
(one week)
Even though nearly a full week has passed, it is ignored, causing a delay in updating parameters.
This means almost a full period may pass before an update occurs, leading to lag in updating parameters.
Delayed Unlocking of Profits: The vault’s profit distribution could be postponed unnecessarily, reducing yield efficiency.
Inconsistent Parameter Updates: The contract assumes regular updates, but this issue creates gaps in update intervals.
Potential Underestimation of Rewards: Fewer periods counted means less asset growth, impacting user returns.
Modify the calculation to ensure fractional periods contribute appropriately:
Use Ceiling Division.
Instead of integer division, use a ceiling function to account for partial periods
All values will be scaled to a combined of 36 decimals before division (be it price-related values or totalSupply). Considering the 18 decimals of all values, no realistic values were presented in any duplicates to proof a substantial impact on precision loss.
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.