The _raw_price
function calculates the raw price of scrvUSD at a specific timestamp (ts
) based on parameters obtained at another timestamp (parameters_ts
). The function assumes that ts >= parameters_ts
, but this assumption is neither enforced nor documented. If ts < parameters_ts
, the function may produce invalid results or revert.
Timestamp Relationship:
parameters_ts
: The timestamp used to fetch the PriceParams
struct via _obtain_price_params
.
ts
: The timestamp for which the raw price is calculated.
The function assumes ts >= parameters_ts
but does not enforce this condition.
Potential Issues:
If ts < parameters_ts
, the function attempts to calculate a price using future parameters, which violates causality.
This could lead to underflows, division by zero, or nonsensical results in downstream calculations (e.g., _total_supply
).
Example Scenario:
Assume parameters_ts = 1000
and ts = 900
.
The function fetches parameters at parameters_ts = 1000
but attempts to calculate the price at ts = 900
.
This is invalid because the state at parameters_ts
cannot represent the state at an earlier time (ts
).
Incorrect Results: The function may return invalid prices if ts < parameters_ts
.
Reverts: Downstream calculations (e.g., _total_supply
) may fail due to invalid timestamps.
Protocol Instability: Invalid inputs could lead to mispriced assets, arbitrage opportunities, or failed transactions.
Add Input Validation:
Add an assertion to ensure ts >= parameters_ts
:
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.