Bad calculation of unsettled realized debt will incur in a bad total debt, that will ruin the swap since the amount that will be received by the user will be different from the expected amount out.
As we can see in the code snippet above: @notice Returns the vault's total unsettled debt in USD, taking into account both the markets'
unrealized debt
, but yet to be settled, and the usdc deposits allocated to the vault.````But what is really taken into account instead of unrealized debt is the
realized debt
as we can see in the code:````sd59x18(self.marketsRealizedDebtUsd).add(unary(ud60x18(self.depositedUsdc).intoSD59x18()));
There are several impacts linked to this issue that come from the use of these 2 view functions:
`getUnsettledRealizedDebt(...)`
`getTotalDebt(...)`
Impact:
Vaults debt might not be settled
The rebalancing of the vault might revert or be performed the wrong way
The swap amount out will be wrong since it uses `getTotalDebt(...)`
Manual review
Replace `marketsRealizedDebtUsd` with marketsUnrealizedDebtUsd
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.