OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Unnecessary Double Transfer in `buyOrder()` (Gas Optimization)

The current implementation transfers protocolFee and sellerReceives separately, which costs more gas:


iUSDC.safeTransferFrom(msg.sender, address(this), protocolFee);
iUSDC.safeTransferFrom(msg.sender, order.seller, sellerReceives);

Optimization:
A single safeTransferFrom for the full amount followed by an internal transfer to the protocol would save gas:

iUSDC.safeTransferFrom(msg.sender, address(this), order.priceInUSDC);
iUSDC.safeTransfer(order.seller, sellerReceives);

Scope:

  • https://github.com/CodeHawks-Contests/2025-07-orderbook/blob/main/src/OrderBook.sol

  • ../src/OrderBook.sol

I was unable to select scope in scope section !

Updates

Lead Judging Commences

yeahchibyke Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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