The collateralFee returned when a Bid Taker is reimbursed is incorrect due to inconsistent use of the _isMaker parameter in the getDepositAmount function. This occurs when a Maker fails to settle all their points.
When a Bid Taker is reimbursed for their collateral after a Maker fails to settle all their points, the collateralFee calculated by DeliveryPlace::closeBidTaker uses the same function that was used to calculate the required collateral when the Taker created their stock. Specifically, it uses the OfferLibraries::getDepositAmount function to determine the collateralFee, which is analogous to transferAmount in PreMarkets::_depositTokenWhenCreateTaker.
In PreMarket::_depositTokenWhenCreateTaker:
The issue arises because both instances of the function use different boolean values for the _isMaker parameter of [OfferLibraries::getDepositAmount]. The implementation in DeliveryPlace::closeBidTaker is incorrect, as the caller in this context is the Taker, not the Maker, and is attempting to get a refund for their unsettled points.
Inspection of the OfferLibraries::getDepositAmount logic reveals that this oversight has significant implications, as the return value differs greatly depending on the case.
The protocol reimburses the Bid Taker an incorrect amount when they call for a refund of their unsettled points, potentially leading to financial discrepancies.
Manual analysis.
Use false instead of true when calling OfferLibraries::getDepositAmount() in DeliveryPlace::closeBidTaker.
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,
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.