The matchlowestSell function does not account for updating the ercAmount of ask orders that are only partially filled by incoming bids, potentially leading to inaccuracies in the displayed order book.
An incoming bid order is placed that matches with an existing ask order, but only partially fills it.
The matchlowestSell function is executed for the incoming bid, matching it against the lowest available ask order.
In the scenario where an ask order is partially filled, the matchlowestSell function correctly updates ethEscrowed for the seller and records the filled ERC amount in matchTotal.askFillErc. However, it fails to adjust the remaining ercAmount for the ask order that remains on the market. This oversight means the order book could display incorrect information about the available quantity for that ask order, potentially misleading future matching attempts.
The ask order remains in the order book with its original ercAmount, not reflecting the partial fill. This could lead to mismatches in the order book, affecting market integrity and participant decision-making.
Tools Used
Manual
Recommended Mitigation Steps
Implement a mechanism within matchlowestSell or at an appropriate point following a partial match, to update the remaining ercAmount for partially filled ask orders.
Lines of code
https://github.com/code-423n4/2024-03-dittoeth/blob/main/contracts/facets/BidOrdersFacet.sol#L224
Vulnerability details
Impact
The
matchlowestSell
function does not account for updating theercAmount
of ask orders that are only partially filled by incoming bids, potentially leading to inaccuracies in the displayed order book.Proof of Concept
Github:
Scenario Steps:
An incoming bid order is placed that matches with an existing ask order, but only partially fills it.
The
matchlowestSell
function is executed for the incoming bid, matching it against the lowest available ask order.In the scenario where an ask order is partially filled, the
matchlowestSell
function correctly updatesethEscrowed
for the seller and records the filled ERC amount inmatchTotal.askFillErc
. However, it fails to adjust the remainingercAmount
for the ask order that remains on the market. This oversight means the order book could display incorrect information about the available quantity for that ask order, potentially misleading future matching attempts.The ask order remains in the order book with its original
ercAmount
, not reflecting the partial fill. This could lead to mismatches in the order book, affecting market integrity and participant decision-making.Tools Used
Manual
Recommended Mitigation Steps
Implement a mechanism within
matchlowestSell
or at an appropriate point following a partial match, to update the remainingercAmount
for partially filled ask orders.Assessed type
Context