When harvesting a strategy and adjusting the debt, all the leftover collateral that is not used to swap the withdrawn collateral from Aave for WETH to repay the flashloan will be locked and lost in the Strategy contract
Audit: 2024-05-bakerfi-findings
Severity: HIGH

# Lines of code

https://github.com/code-423n4/2024-05-bakerfi/blob/main/contracts/core/strategies/StrategyLeverage.sol#L545-L547
https://github.com/code-423n4/2024-05-bakerfi/blob/main/contracts/core/hooks/UseSwapper.sol#L95-L97


# Vulnerability details

## Impact
Collateral can be locked and lost in the Strategy contract.

## Proof of Concept
When harvesting a strategy and adjusting the debt to maintain the loan to value of the strategy, the strategy does the following steps:
1. Computes the deltaDebt required to readjust the loan to value within the accepted boundaries.
2. Takes a WETH flashloan on Balancer for the exact deltaDebt amount
3. Repays WETH on Aave for the exact amount that was flashloaned borrowed on Balancer
4. Uses the UniQuoterV2 to compute the amount of collateral needed to repay the flashloan (including the flashloan fees)
5. Withdraws collateral from Aave for exact amount computed by the UniQuoterV2
6. Does an `EXACT_OUTPUT` swap on Uniswap. It requests to receive the exact `debtAmount + fees` (to repay the flashloan) in exchange for at most the withdrawn amount of collateral from Aave
7. Does a couple of extra checks and finally the flashloan is repaid.

The problem identified on this report is caused due to some issues in the steps 4 & 6. Let's dive into it.

The ***first part of the problem*** is caused due to the way how the UniQuoter is invoked. [The `fee` of the pool that is sent to the UniQuoter is hardcoded to be `500`](https://github.com/code-423n4/2024-05-bakerfi/blob/main/contracts/core/strategies/StrategyLeverage.sol#L545-L547), which represents a pool of (0.05% fee). This can cause two problems:
1. The execution can be reverted if there is not an existing pool for the COLLATERAL/WETH at a 0.05% fee. The UniQuoter will receive the call and will derive the address of the pool based on the tokenIn, tokenOut and fee. **If there is not a pool for the 0.05% fee (500), the call will be reverted and the whole harvesting execution will blown up.**

2. The second problem is when the `swapFeeTier` is different than 500, or in other words, that the fee of the UniPool that is configured for the strategy is different than 500 (0.05%), for example, if the strategy is configured to work with a pool with a fee of 0.01% (100).
- In this case, the execution won't revert, but the computed amount will be bigger than what is really required. For example
  - The `debtAmount + fee` to repay the flashloan is 100WETH.
  - The UniQuoter will compute how much collateral is required to get 100WETH by swapping the collateral on a UniPool with a 0.05% fee. to make calculations easier, assume collateral and weth have a 1:1 conversion.
    - 100 collateral + 0.05% fee charged by the pool ===> 100 + 0.5 ===> 100.5 Collateral.
  - Then, the execution will withdraw from Aave the computed amount by the UniQutoer (100.5).
  - Now, once the Strategy has the 100.5 collateral on its balance, the execution will do a swap requesting 100 WETH to repay th