getUserCollateralValue(userAddress)
is called after user.nftTokenIds
has been deleted, making it return wrong value.
According to the event definition, the LiquidationFinalized event is supposed to emit the address of liquidator, the account being liquidated, the debt being repaid and the value of the collateral being liquidated.
For the value of collateral, it makes a call to getUserCollateralValue(userAddress)
. This function loops through the array of user.nftTokenIds to determine and return the value. The issue is that the user's array of nftTokenIds is already deleted by this time, which wipes the relevant NFT data.
The delete happens here: https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/LendingPool/LendingPool.sol#L519
And the event is emited after that at this point: https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/LendingPool/LendingPool.sol#L535
Loss of Trust and Transparency
One of the key purposes of emitting events in smart contracts is to provide transparency and ensure all actions within the contract can be tracked and verified by external observers (like users or dApps). If the wrong event is emitted:
Users will be misled, which could result in a lack of trust in the contract or the dApp.
The emitted logs may show inaccurate or incorrect information, damaging the overall reliability of the system.
Manual Review
Fetch and store collateral value before deleting user NFT data. Then pass it in to the Emit.
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.