Note: At the judges request here, this downgraded issue from the same warden has been included in this report for completeness.
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/actions/Compensate.sol#L60-L62
Users can repay their debts partially. If they have other credits with due dates earlier than the debt they want to compensate for, they can always make the compensation regardless of whether the due date falls within the minimum tenor period.
However, it is not possible to create new debt/credit and compensate using this new credit if the due date is within the minimum tenor period. In such cases, the newly created debt and credit positions are just for compensation, and the owner is the same user, so the minimum tenor period check should not be necessary.
Imagine the minimum tenor period is long and a user has a large debt position. If the ETH price drops, their position may soon become liquidatable. If the user has some USDC but no ETH, they would want to repay their debt partially to increase their CR again. However, if the due date is within the minimum tenor period, they cannot do this. As a result, their position can be liquidated, leading to a loss.
The size of the loss depends on the debt size, so users will try to minimize the loss by reducing the debt size. Nevertheless, due to the unnecessary minimum tenor period check, users can still experience losses.
Imagine Bob borrowed USDC from Alice, and Candy borrowed USDC from Bob. Both debts have the same due dates and are within the minimum tenor period. There is a fluctuation in the ETH price, prompting both users to want to reduce their debts.
In this scenario, Bob can compensate using the credit that Candy will pay to him. However, Candy cannot reduce his debt due to the minimum tenor period check.
As previously mentioned, these newly created debt and credit positions are solely for compensation, and Candy owns both positions. This does not constitute actual lending/borrowing. Therefore, users should be allowed to create these positions even if the due date is within the minimum tenor period. It should be permissible because compensation can occur using credits with due dates within the minimum tenor period. In this context, there should be no distinction between these two methods.
Please add below test to the test/local/actions/Compensate.t.sol:
Please remove the minimum tenor period check from the compensate function.
Error
aviggiano (Size) disputed and commented:
lanrebayode77 (warden) commented:
hansfriese (judge) decreased severity to Low and commented:
