The current implementation only checks if ctx.usdcOut == 0
after a swap operation. However, this is not a sufficient validation because a nonzero output does not necessarily mean the swap provided enough USDC to settle the debt. Instead, the output should be compared to the required USDC amount to ensure the vault has sufficient funds to cover its obligations.
This check only verifies whether the output is exactly zero, but does not account for cases where the returned amount is nonzero yet insufficient to cover the unsettled debt.
The purpose of swapping vaultAsset to USDC is to obtain a specific amount of USDC to settle a debt. Therefore, instead of merely checking if usdcOut
is nonzero, the protocol should ensure that the received USDC is sufficient to cover the debt.
Additionally, the protocol can internally estimate how much vaultAsset it should receive when swapping USDC. Using this expected amount as a threshold, rather than just checking for a zero output, would improve accuracy and prevent insufficient swaps.
Debt may remain unsettled: If the swap does not provide enough USDC, the vault might still be unable to cover its obligations.
Insufficient slippage checks expose the protocol to price manipulation, leading to potential fund losses.
Instead of checking only if ctx.usdcOut == 0
, we should compare it against the required amount of USDC:
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.