During the Dutch Auction, the borrower can keep calling buyLoan() with the loanId
is his/her loan and poolId
is the same pool which the loan was borrowed from so that the loan.auctionStartTimestamp
will be set to the default value of type(uint256).max
. This makes the loan always immature to be seized as seizeLoan() will revert if loan.auctionStartTimestamp == type(uint256).max
.
The borrower first needs to calculate the timeElapsed which is responsible for rate validation of the pool:
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L474-L478
Then he/she can decide when to buy the loan after the original lender have started the auction for this loan so that it can satisfy the rate validation. After being successfully bought with the same poolId, the loan.auctionStartTimestamp's value will be set to default as you can see here: https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L521
Copy this test case into test/Lender.t.sol
Use forge test --mt test_buyLoanWithTheSamePool
to run this test case.
In this POC the borrower waits until there is one minutes left before the auction ending (23 hours 59 minutes, the loan.auctionLength
is 1 days) and calls buyLoan()
, after the action the lender1 cannot seize the loan anymore.
If the borrower observes that there is no pool that has the same config of the old pool and has enough balance to buy his/her loan when it come to an end of the auction, he/she can use this workaround to avoid liquidation of the loan. The lender also loses his time waiting for the auction to end but can't seize the loan to get the collateral assets although no one actually buying the loan, the loan is just re-bought itself from the same pool, which is not the lender's original intention.
Manual
Implement a validation that the new pool buying the loan is not the same pool which the loan is from.
Put the code below this line: https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L493
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.