In the _obtain_price_params
function, when params.last_profit_update + period < parameters_ts
, it indicates that the period has matured. In this case, both params.last_profit_update
and params.full_profit_unlock_date
are increased by number_of_periods * period
. However, in the _unlocked_shares
function, if full_profit_unlock_date > ts
, the calculated unlocked_shares
becomes ts
minus last_profit_update
(which includes the added periods), without including the already matured balance_of_self
. This causes unlocked_shares
to be underestimated, which subsequently affects the calculation of the raw price
.
Consider the following scenario:
In the _obtain_price_params
function, when last_profit_update + period < parameters_ts
(indicating the period has matured), the function updates the time parameters
Both updated last_profit_update
and full_profit_unlock_date
are increased by number_of_periods * period
In the _unlocked_shares
function, these updated time parameters are used to determine the unlocking state and calculate unlocked shares
If the updated full_profit_unlock_date > ts
, the function calculates partial unlocked shares instead of returning the already matured balance_of_self
. This leads to underestimation of unlocked shares.
Price calculation impact: When unlocked_shares
is underestimated, total_supply - unlocked_shares
is overestimated. This results in an underestimated calculated price:
price = total_assets/ (total_supply - unlocked_shares)
The issue arises from the interaction between these functions of _obtain_price_params
and _unlocked_shares
:
contracts/scrvusd/oracles/ScrvusdOracleV2.vy:_obtain_price_params#L279-L280
contracts/scrvusd/oracles/ScrvusdOracleV2.vy:_unlocked_shares#L205-L207
contracts/scrvusd/oracles/ScrvusdOracleV2.vy:_total_supply#L219
contracts/scrvusd/oracles/ScrvusdOracleV2.vy:_raw_price#L291
Price Underestimation:
price = total_assets/ (total_supply - unlocked_shares)
Underestimation of unlocked shares leads to understated price calculations
Inaccurate prices may lead to incorrect market decisions
Manual code review
It is recommended that when params.last_profit_update + period < parameters_ts
in the _obtain_price_params
function, it indicates that the period has matured. In this case, the _unlocked_shares
function should return shares that include balance_of_self
.
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.