DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Valid

Order Fee Should Not Use FillPrice

Summary

When calculating funding, fillPrice should not be used as it is unfair to short traders who pay more fees for helping to balance the skew.

Vulnerability Detail

When calculating orderFee, fillPrice is used:

function _fillOrder() {
...
ctx.orderFeeUsdX18 = perpMarket.getOrderFeeUsd(sizeDeltaX18, fillPriceX18);
...
function getOrderFeeUsd() {
...
orderFeeUsd = markPriceX18.mul(sizeDelta.abs().intoUD60x18()).mul(feeBps);
...
}

fillPrice includes a premium/discount according to how the trader affected the current market skew. As a result, shorts unfairly pay more fees when they balance the market and less when they imbalance the market.

Consider this scenario:

  • index price = 1000

  • short trade (positive price impact), fill price = 1010 => more fees are paid

  • short trade (negative price impact), fill price = 990 => less fees are paid

Impact

Short traders are not incentivized to balance long skew, but incentivized to worsen short skew. This leads to persistent imbalanced skew which is detrimental to all traders as fill price cannot converge with true oracle price.

Code Snippet

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/branches/SettlementBranch.sol#L399

Tool used

Manual Review

Recommendation

Use an oracle price instead of fillPrice to calculate orderFee.

Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

giraffe0x Submitter
over 1 year ago
inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Order fees should be computed using Index price

Support

FAQs

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

Give us feedback!