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

Price Impact Incentives Are Misaligned

Summary

The getMarkPrice function wrongly moves the price based on how much the skew moves without considering where the skew started. Because of this, users who greatly imbalance the market will be punished less than users who only make small orders. The misalignment of incentives will lead to small users being unfairly punished, while large users can move the skew drastically, putting the entire market at risk.

Vulnerability Details

The getMarkPrice function aims to modify the market price based on the current skew and what the new skew will be. In general, when the skew moves away from balanced, the user will experience negative price impact. And when the user moves the skew towards balanced, they will get positive price impact.

The price is determined by taking the average of the priceBeforeDelta and priceAfterDelta.

markPrice = priceBeforeDelta.add(priceAfterDelta).div(ud60x18Convert(2)); //@audit misalignment of price impact

The issue with this is that by taking the average, large swings are cushioned while small swings will experience most of the positive/negative impact from wherever the skew is.

Take for example:

  • The current skew of the market is 0 (perfectly balanced).

  • The price of the asset is $100.

  • With 0 skew, the price before delta is $100.

Now examine the following scenario to see how a smaller position is punished by a much larger amount despite a smaller impact on the skew.

Alice (Big swing)

  • Opens a position with a size of 1000.

  • Price before is $100.

  • Price after is $109.50 (9.5% impact for moving the skew from 0 to 950).

  • Mark price is the average of the above two prices: ((100 + 109.5) / 2) = 104.75.

  • Alice's price is $104.75.

Bob (Small swing)

  • Follows Alice and opens a small position with a size of 50.

  • Price before is $109.5.

  • Price after is $110 (0.5% impact for moving the skew from 950 to 1000).

  • Mark price is the average of the above two prices: ((109.5 + 110) / 2) = 109.75.

  • Bob's price is $109.75.

Despite Bob having nothing to do with the state of the skew and only making a small order, he is getting almost a 5% worse price. Meanwhile, Alice drastically imbalances the market and is only impacted by half of the damage that has been done.

With a high likelihood and medium impact, a medium severity makes the most sense.

The high likelihood comes from the fact that this misalignment will always be present and impact every skew change.

The medium impact is based on large swings getting more favorable prices despite hurting the market, while small swings will get worse prices by consequence of the large swing users.

Impact

  • Users will wrongly get unfavorable prices leading to a lowered PnL.

  • Anyone can imbalance the market and only be partially punished.

Tools Used

  • Manual analysis

Recommendations

The best way to mitigate this is to appropriately punish large trades that move the skew away from balanced. To do this, consider moving the markPrice towards the priceAfterDelta as the sizeDelta grows if the skew is moving away from balanced.

Some version of the following would allow you to dynamically adjust how much of the negative price impact a user should experience based on how much they are imbalancing the market.

markPrice = priceBeforeDelta.add(priceAfterDelta).mul(x).div(ud60x18Convert(10));

If x = 5, this would result in the same output that the function currently does. But as sizeDelta grows and the balance worsens, you can increase the value of x so more of the negative price impact is applied.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 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.