The PreMarket#createOffer function is currently unable to create more than one offer, which renders the project unusable.
The PreMarket#createOffer function is designed to create virtual offers, which are then added to the market using the PreMarket#listOffer function. However, there is a flaw in the current design that prevents the creation of additional offers after the first one. Hereβs a detailed explanation of how this issue arises:
To create an offer, random addresses for the maker, offer, and stock are generated using the offerId state variable as follows:
Before creating the offer and setting up the makerInfoMap, offerInfoMap, and stockInfoMap mappings, the offerId state variable is incremented:
However, this incremented offerId is incorrectly passed as the offerId in the offer creation process:
Due to this incrementing issue, the next call to PreMarket#createOffer will fail. This is because the function will revert with the following checks: the offerAddr is generated based on the incremented offerId, but offerId has already been set to the previous offer:
The malfunction of one of the main project functionalities means users cannot create offers, rendering the system unusable.
manual code review
Increment the offerId after setting the mappings, rather than before.
I believe this is valid low severity, although there is inconsistency here when using the correct `offerId` for assigning offerIds and generating the unique addresses as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L67-L69), this is purely an accounting error for offerIds. If we generate the offerId using current `offerId - 1`, the appropriate listing/taker orders can still be created against those offers.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.