<!-- canonical: https://0xsimao.com/findings/yieldoor-ii-repay-aave-undefined-behaviour -->

# Code has typos in RebalanceLogic::repayAavePosition() leading to undefined behaviour

Medium · 0xSimao · Leveraged yield farming · 20th June 2025

Finding M-2 of the Yieldoor LoopedVault security review.

- Protocol: https://app.yieldoor.com/
- Report: /reports/yieldoor-ii
- Source: https://github.com/0xSimao/audits/blob/main/0xSimao/2025-06-20-yieldoor-ii.pdf

---

**Description:**

`RebalanceLogic::repayAavePosition()` [code](https://github.com/spacegliderrrr/loopedVault/blob/master/src/libraries/RebalanceLogic.sol#L52-L63) is switched and the collateral or debt amounts intended to be dealt with will not be the actual amounts used. Due to several checks within the code it is unlikely it would still go through and cause any issues, other than the collateral and borrowed amounts not being correct. Technically it could be possible to borrow too much and be liquidated or similar, but very unlikely.

**Recommended Mitigation:**

Fix the correct collateral/debt variables and the limiting of the amount to withdraw.

**0xSimao:**

Fixed in [#ad00401](https://github.com/spacegliderrrr/loopedVault/commit/ad0040106a3c92636afd77e1bf511be21bebbe5c).
