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

Lack of Slippage mechanism between market order creation and filling

Summary

MarketOrders lack a slippage mechanism, which would protect users from massive price movements between order creation and order being filled.

Vulnerability Details

Users create market orders to open positions or alter existing market positions through OrderBranch.createMarketOrder. These orders can then be filled by the keepers.
However, there can be a time delay between when order is created and when it is filled which can be up to 5-10minutes. Note that this may be less time than the user can cancel the order as there is a time limit placed on pending orders checked through marketOrder.checkPendingOrder

function checkPendingOrder(Data storage self) internal view {
GlobalConfiguration.Data storage globalConfiguration = GlobalConfiguration.load();
uint128 marketOrderMinLifetime = globalConfiguration.marketOrderMinLifetime;
if (
self.timestamp != 0 && marketOrderMinLifetime != 0
&& block.timestamp - self.timestamp <= marketOrderMinLifetime
) {
revert Errors.MarketOrderStillPending(self.timestamp);
}
}
}

During this time, it is possible for there to be a significant shift in the market markPrice. This can due to an attack or normal market conditions. The current markPrice at the time of filling is what is used to match the order and alter the position, which can be different from what the user originally expected.
Generally, in such scenarios protocols should provide a range which the user is comfortable with and skip filling if it falls out of that range. In this case however, users have no protection to random market movements.

Impact

Users have no protection against massive price movements as their orders are filled at current market markPrice which may be drastically different from the markPrice when the user created their order.

Tools Used

Manual Review

Recommendations

Implement a slippage mechanism in marketOrders to protect users

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

fillMarketOrder lacks slippage protection

Support

FAQs

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