The finalizeLiquidation function in LendingPool.sol emits a LiquidationFinalized event at the end of execution. However, the collateralLiquidated value in this event is determined using the getUserCollateralValue function, which returns 0 at this stage of execution due to the user’s collateral having already been transferred and user.nftTokenIds being deleted. This results in an inaccurate event emission, which could mislead off-chain services or monitoring systems.
In the finalizeLiquidation function:
The contract transfers all NFTs owned by the user to the stabilityPool.
The user.nftTokenIds array is deleted after transferring the NFTs.
The event LiquidationFinalized is emitted, where the collateralLiquidated value is determined by calling getUserCollateralValue(userAddress).
However, since user.nftTokenIds has been deleted, getUserCollateralValue returns 0, leading to incorrect data in the emitted event.
Relevant code snippet:
Since getUserCollateralValue relies on user.nftTokenIds, which is already deleted, the function always returns 0, resulting in an incorrect event emission.
Off-chain monitoring systems relying on LiquidationFinalized for accurate collateral liquidation data may be misled.
Potential issues with integrations that depend on correct event logs for liquidation tracking.
Manual code review
To ensure accurate event emission, the contract should store the user's collateral value before deleting user.nftTokenIds and pass this value to the event.
Suggested fix:
Modify the function as follows:
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.