DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: medium
Invalid

Fill Price Premium Discount Misaligned

Summary

Fill price premium/discount calculations incentivize large over small imbalances.

Vulnerability Detail

The fillPrice premium/discount is calculated by taking the average of the current skew and the skew. This calculation is then applied to the price, allowing the getMarkPrice function to return the fill price.

The issue with this approach is that users are more incentivized to create large imbalances in the skew which is undesirable.

Consider this example of changing the skew from 0 to 1000:

- skewScale = 1_000_000
- currentSkew = 0
- User goes long with size of 1000
- indexPrice = $100
priceImpactBeforeDelta = currentSkew / skewScale = 0
newSkew = 1000
priceImpactAfterDelta = 1000 / 1_000_000 = 0.001
priceBeforeDelta = $100 + $100 * priceImpactBeforeDelta = $100
priceAfterDelta = $100 + $100 * priceImpactAfterDelta = $100.1
markPrice = ($100 + $100.1) / 2 = $100.05

Then consider this example of changing the skew from 950 to 1000:

- skewScale = 1_000_000
- currentSkew = 950
- User goes long with size of 50
- indexPrice = $100
priceImpactBeforeDelta = currentSkew / skewScale = 0.00095
newSkew = 1000
priceImpactAfterDelta = 1000 / 1_000_000 = 0.001
priceBeforeDelta = $100 + $100 * priceImpactBeforeDelta = $100.095
priceAfterDelta = $100 + $100 * priceImpactAfterDelta = $100.1
markPrice = ($100.095 + $100.1) / 2 = $100.0975

Moving the skew by 50 tokens results in a worse price impact than moving the skew by 1000 tokens, while both result in the same skew.

Impact

Traders are incentivzed to create large imbalances in the skew which is undesirable for Perps market.

Code Snippet

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/leaves/PerpMarket.sol#L98

Tool used

Manual Review

Recommendation

Consider redesigning the fill price calculation so that incentives align with the actual impact a user's position would have on the skew.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!