# decreaseLever uses incorrect position address when withdrawing

Position4626._onDecreaseLever withdraws collateral from address(this) instead of leverParams.position, so decreaseLever always reverts for 4626 vaults.

- Payout: Audit contest
- Severity: high
- Program: LoopFi
- Found by: hash
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-loopfi-findings/issues/116
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** CDPVault / Position4626 leverage contract
**Root cause:** The Position4626 override of _onDecreaseLever calls ICDPVault.withdraw(address(this), subCollateral) instead of withdrawing from leverParams.position, where the collateral actually resides.
**Steps:**
1. Call decreaseLever(leverParams, subCollateral, residualRecipient) on a Position4626-associated vault.
2. Contract grants permission and invokes flashlender.creditFlashLoan with encoded params.
3. onCreditFlashLoan calls _onDecreaseLever, which executes ICDPVault(leverParams.vault).withdraw(address(this), subCollateral).
4. Withdrawal fails/reverts because address(this) holds no collateral; the position holds it.
**How found:** Code review of the Position4626 override of _onDecreaseLever, noticing the withdraw target is address(this) rather than the passed-in leverParams.position used elsewhere in the flow.
**Insight:** When a base contract passes a position parameter into an overridable hook, audit each override for whether it uses the passed position or substitutes address(this); mismatched address arguments in delegatecall/flash-loan callback flows are a recurring source of broken functionality.

## Proof of concept (copied exactly from the original report)

**Position4626 _onDecreaseLever withdraws from address(this)**

```
function _onDecreaseLever(
        LeverParams memory leverParams,
        uint256 subCollateral
    ) internal override returns (uint256 tokenOut) {
        // @audit attempts to withdraw from address(this) rather than leverParams.position
=>      uint256 withdrawnCollateral = ICDPVault(leverParams.vault).withdraw(address(this), subCollateral);
```

