The settleAskTaker function is not properly handling the case where _settledPoints
is less than stockInfo.points
. Specifically:
When _settledPoints < stockInfo.points
, the function calculates collateralFee
based on the full stockInfo.amount
, which is incorrect.
In this case, it also refunds the entire collateralFee
to the offer authority, which is not proportional to the settled points.
The function should calculate the collateralFee
proportionally to the _settledPoints
and distribute it accordingly.
Overpayment of collateral could drain the contract of funds more quickly than intended, potentially leading to liquidity problems if this occurs frequently or with large amounts.
The current implementation might incentivize partial settlements, as the offer authority would receive the full collateral refund even for partial settlements. This could lead to gaming of the system, where users might prefer partial settlements to maximize their returns unfairly.
Calculate the collateralFee
proportionally to _settledPoints
.
Distribute the collateralFee
between the caller and the offer authority based on the ratio of settled to unsettled points.
Valid High, afaik, partial settlements are a valid flow and so when closing bid offers by takers and/or when settling offers by makers, we should return a proportionate amount of funds based on points settled. This issues could be related to issue #1008, but seems to be describing a different issue.
Valid high, in settleAskTaker/settleAskMaker, if the original offer maker performs a partial final settlement, the existing checks [here](https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/DeliveryPlace.sol#L356-L358) and [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L230-L232) will cause an revert when attempting to complete a full settlement, resulting in their collateral being locked and requiring a rescue from the admin. To note, although examples in the documentation implies settlement in a single click, it is not stated that partial settlements are not allowed, so I believe it is a valid user flow.
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.