The protocol's core functionality is broken maxSkew
is more than skewScale
in MarketConfiguration
of perp market. skew
can range from -maxSkew
to maxSkew
in most of scenarios(unless owner
changes maxSkew
variable when abs(skew) > maxSkew
), which can lead to incorrect calculations of priceImpactBeforeDelta
and priceImpactAfterDelta
and even revert of getMarkPrice
function. Looking at tentative deployment script by the protocol, it is possibility that maxSkew
can be more than skewScale
. Also, the sponsor confirmed that there can be possibility of this(but if you think there's a potential vector when max_skew > skew_scale please try to explore it)
The function getMarkPrice
in PerpMarket
is as follows. Now, let's analyze about what if maxSkew
is more than skewScale
. maxSkew
and skewScale
are positive uint256
variable. skew
can range between -maxSkew
to maxSkew
. For the sake of simplicity, let's assume skew
and newSkew
are negative and their absolute value lies between skewScale
and maxSkew
. i.e. skewScale< abs(skew)< maxSkew
and skewScale< abs(newSkew)< maxSkew
.So, in following function, priceImpactBeforeDelta
will be less than -1
and priceImpactAfterDelta
will also be less than -1
. Due to this, cachedIndexPriceX18.add(cachedIndexPriceX18.mul(priceImpactBeforeDelta)).intoUD60x18();
will revert because cachedIndexPriceX18.add(cachedIndexPriceX18.mul(priceImpactBeforeDelta))
is negative and can't be converted to UD60x18
. The error reverted is CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x)
.
Due to revert in getMarkPrice
function, all the functions using it will revert. Due to this, no market orders can be created, no orders(onchain and offchain) can be settled and no accounts can be liquidated
1) Creation of order in OrderBranch
2) fillMarketOrder and fillOffChainOrders in SettlementBranch
3) liquidateAccounts in LiquidationBranch
Manual review
Ensure that skewScale
is always more than maximum value the skew
can reach. Otherwise, priceImpactBeforeDelta
and priceImpactAfterDelta
can be bounded to [-1,1]
as done in getCurrentFundingVelocity
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.