The createTaker() function in the PreMarkets.sol contract sets the id of the StockInfo structure before incrementing the offerId. In contrast, the createOffer() function increments the offerId before setting the id. This inconsistency can potentially lead to the same ID being assigned to multiple entities or an ID not being set correctly.
createTaker() function. The id for the StockInfo structure is set before the offerId is incremented.
createOffer() function. The offerId is incremented before setting the id.
This discrepancy can lead to one ID being assigned to two different entities or, in some cases, not being assigned at all.
The inconsistency in ID assignment can cause unexpected behavior in the system, such as ID Collision or Incorrect Data Mapping.
This is the test code.
The result is like this.
As you can see, ID 1 is assigned to two different stocks and ID 2 is not assigned at all.
Manual code review
Increment offerId before setting the id in the createTaker() function, similar to how it is done in the createOffer() function.
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.