After both the open and unwind operations, the contract checks whether the 1inch swap returned more tokens than needed to repay the flash loan. The normal behavior would be to return any excess to the owner or hold it for explicit withdrawal.
Instead, the excess tokens are automatically supplied back to Aave as additional collateral without the owner's knowledge or consent. This silently increases the position size and locks the excess funds in Aave, requiring a separate unwindPosition call to retrieve them.
Likelihood:
1inch swaps frequently return slightly more tokens than the quoted minimum due to favorable market movement between quote time and execution time. The excess is typically small but nonzero.
Every position open and unwind operation routes through this code path, making it a per-transaction occurrence.
Impact:
The owner's position size increases unpredictably, changing the effective leverage ratio and health factor without their input.
Excess tokens become locked in Aave and require a full unwind cycle to extract, incurring additional gas costs and potential slippage.
The code review below traces the leftover handling in both _executeOpenOperation (line 528-532) and _executeUnwindOperation (line 590-595). When the 1inch swap returns more tokens than the flash loan debt, the excess is unconditionally supplied back to Aave as extra collateral. The owner has no way to prevent this or claim the surplus directly.
Instead of auto-depositing leftover tokens into Aave, transfer them directly back to the user. This preserves the intended position size and leverage ratio, and lets the owner decide how to deploy the surplus. Apply the same change to _executeUnwindOperation.
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.
The contest is complete and the rewards are being distributed.