The function `settleVaultsDebt` settles the vaults debt or credit by swapping assets to usdc and vice versa.
If the vault has debt it should swap the vaults assets to USDC and if in credit then swap the vaults available USDC to its underlying asset. But the current implementation is faulty. The if statement to check if vault is in debt or not is incorrect.
The if statement incorrectly checks if vault has debt or not.
The calculation in the if block is if the vault is in debt. But the line : `if (ctx.vaultUnsettledRealizedDebtUsdX18.lt(SD59x18_ZERO))` is incorrect as it contradicts the code and comment in the if block.
The code has to be executed if the `ctx.vaultUnsettledRealizedDebtUsdX18` is greater than 0, not is lesser than 0. If greater than 0 means that it has debt. The current check if when the vault is in credit. This disrupts the whole process as the calculation for debt and credit will be opposite to what is required.
Incorrect debt and credit calculation and swaps.
VS Code
Change to :
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.