A critical error has been found in the `closeBidTaker` function where the bid taker is incorrectly classified as a maker during the calculation of the deposit amount. This mistake leads to the wrong amount being sent by the bid taker, potentially causing financial discrepancies.
The vulnerability arises in the `closeBid` function, where the calculation of the deposit amount for the bid taker is incorrectly handled. Specifically, the code mistakenly sets the bid taker as a maker:
In the `getDepositAmount` function, the `_isMaker` parameter is set to `true`, which is incorrect for a bid taker. According to the intended logic:
For taker orders, `_isMaker` should always be set to `false`. By setting it to `true`, the function incorrectly multiplies the amount by the collateral rate:
This leads to the wrong deposit amount being calculated and sent, as the amount should not be multiplied when the order is made by a taker.
This vulnerability results in bid takers sending the wrong deposit amount. Specifically, they end up sending an amount that has been incorrectly multiplied
- Manual code review
To fix this issue, it is essential to ensure that the `_isMaker` parameter is correctly set to `false` for bid takers. The logic should be adjusted as follows:
### Corrected Code Example
This change ensures that the deposit amount for takers is calculated correctly, without applying the incorrect multiplication by the collateral rate.
Invalid, the computations are correct, when taker close a bid offer, of type `Bid` represented in their stock, the offerType of maker must be that of `Ask` as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L137-L139) when the offer is created. In which `(_offerType == OfferType.Ask && _isMaker) ` will result in the following computations performed as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/libraries/OfferLibraries.sol#L44-L51), so the collateral will be refunded appropriately,
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.