The whole implementation of the rebalanceVaultsAssets
is completely incorrect
In the function we can see that the following steps are made:
1.It swaps the in-debt vault's assets for USDC using _convertAssetsToUsdc.
In some cases the swapped amount of collateral tokens may be enough to cover for the debt of the vault which is simular to the settleVaultsDebt
After that the following storage updates are made:
Here in point 4) we can see that the debt of the vault will be decreased by the usd that the collateral purchased. After that in point 3) the depositedUsdc
will actually be decreased which results in the getUnsettledRealizedDebt
remaining the same for the in debt vault.
In point 1) and 2) the vault that is in credit receives some USDC that is subtracted from the deposited USDC in point(3). However as a result the in credit vault will also have the same unrealizedDebt
.
After all these operations are completed both vaults will still have the same unsettled debt, however the inDebt vault will lose collateral.
Loss for the inDebt vault
Manual Review
rebalanceVaultsAssets
should facilitate settlement of their credit and debt, while currently it is the same.
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.