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

Trade orders cannot be filled as SettlementBranch::fillOffchainOrders function is not implementing the documentation

Summary

SettlementBranch::fillOffchainOrders function documentation is to allow traders trading account's position (buy order), the fill price must be less than or equal to the target price, if it decreases the trading account's position (sell order), the fill price must be greater than or equal to the target price.\

SettlementBranch::fillOffchainOrders function does not perform the implementation as in the documentation. Traders would not be able to make profit because orders can not be filled.

Vulnerability Details

if the order increases the trading account's position (buy order), the fill price must be less than or // equal to the target price, if it decreases the trading account's position (sell order), the fill price // must be greater than or equal to the target price.

```ctx.isFillPriceValid = (ctx.isBuyOrder && ctx.offchainOrder.targetPrice <= ctx.fillPriceX18.intoUint256())
!ctx.isBuyOrder && ctx.offchainOrder.targetPrice >= ctx.fillPriceX18.intoUint256());

Impact

This can enable a malicious trader to make profit because orders can not be filled.

Tools Used

manual review plus foundry test

Recommendations

ctx.isFillPriceValid = (!ctx.isBuyOrder && ctx.offchainOrder.targetPrice <= ctx.fillPriceX18.intoUint256()) || (ctx.isBuyOrder && ctx.offchainOrder.targetPrice >= ctx.fillPriceX18.intoUint256());

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

fillOffchainOrders inverses the comparison between `fillPrice` and `targetPrice`

Support

FAQs

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