Closed sherlock-admin2 closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid, agree with sponsors comments:
UnrealisedDebt is taken into account, the flow is:
- account.getUsedMargin → lendingPool.getOpenPosition → ERC4626.maxWithdraw → ERC4626.convertToAssets → lendingPool.totalAssets, the latter taking into account the unrealised debt.
- Confusion may exist as to know which function is overwritten
FCSE507
medium
The current interest is not included in the used margin calculation.
Summary
We process
interests
before executing someactions
in theLending Pool
to apply unrealizeddebt
. However, theused margin
calculation doesn't consider the unrealizeddebt
. As a result, anaccount
that can actually beliquidated
may be marked ashealthy
.Vulnerability Detail
When an
account
isliquidatable
, someone initiatesliquidation
. This imposes additionaldebt
on theaccount
, includinginitiation rewards
,termination rewards
, etc.After some time, the
collateral
value increases due to market conditions.Anyone can settle the
auction
for thisaccount
.Here,
getUsedMargin()
doesn't consider unrealizeddebt
, so thecollateral
value may fall between thegetUsedMargin()
value and theactual used margin
. This implies that theauction
of thisaccount
can be concluded, and someone can initiateliquidation
for thisaccount
again immediately.Impact
This incurs additional
debt
to theaccounts
and is unfair.Code Snippet
https://github.com/sherlock-audit/2023-12-arcadia/blob/main/lending-v2/src/LendingPool.sol#L876-L877 https://github.com/sherlock-audit/2023-12-arcadia/blob/main/lending-v2/src/Liquidator.sol#L444-L445
Tool used
Manual Review
Recommendation
The
getUsedMargin
calculation should also include unrealizeddebt
.Duplicate of #1