Vulnerability report #699 has not been fixed in current code base.
Vulnerability details and root cause are well explained in https://codehawks.cyfrin.io/c/2024-07-zaros/s/699
For dust PnLs, orderFees and settlementFees are not delivered to corresponding recipients
As the root cause is already described in the original report, let's focus how dust PnL is likely to happen:
First, how small is dust?
Dust should be small enough to rounded down to zero when divided by collateralPriceX18:
Considering BTC price is 100k these days, we can assume marginCollateralPriceUsdX18 = 1e23
So if amountUsd < 1e5
, requiredMarginInCollateralX18
will be rounded down to zero.
Second, where do we get this tiny difference?
PnL is calculated as follows:
Price shift is calculated as currentMarkPrice - lastMarkPrice
and markPrice is calculated as follows:
And division by skewScale
is where we can get decimal fractions which will be lower than 1e5
This is definitely possible for markets with decimal skew scale. For example, DOGE_USD_SKEW_SCALE = 2_415_071_153_532e18
Manual checking
Use divUp
instead of div
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.