# PoolAction::updateLeverJoin wrongly updates assetsIn array, leading to PositionAction4626::_onIncreaseLever to always revert

PoolAction::updateLeverJoin mis-indexes assetsIn when skipping the Balancer BPT token, corrupting join amounts and making PositionAction4626::_onIncreaseLever revert for ERC4626-collateralized positions.

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

**Target:** PoolAction::updateLeverJoin / PositionAction4626::_onIncreaseLever (Balancer join)
**Root cause:** The skip logic assumes the 4626 collateral's underlying token equals the Balancer poolToken; when it doesn't match any asset, skipIndex never flips and assetsIn is written at the wrong index, duplicating amounts.
**Steps:**
1. Deploy PositionAction4626 with a Balancer pool whose tokens array includes the BPT token at index 0.
2. User deposits sLPETH collateral and borrows underlying.
3. Call increaseLever with auxAction PoolActionParams containing tokens=[BPT, wstETH, bbaweth], tokensIn=[49e18, 0], maxAmountsIn=[0, 49e18, 0].
4. updateLeverJoin writes assetsIn[0]=49e18 and assetsIn[1]=49e18 because poolToken never matches, producing tokensIn=[49e18,49e18].
5. Balancer joinPool reverts with BAL#506 (amount > maxAmountsIn).
**How found:** Code-reading of the skipIndex loop: noticed poolToken is set to the 4626 underlying token rather than the actual Balancer pool token, so the skip branch never triggers and assetIndex stays equal to i, overwriting the wrong slot.
**Insight:** When a loop uses an offset to skip a token (e.g. BPT) in a parallel array, verify the skip condition is derived from the actual pool/vault state (balancerVault.getPool(poolId)) rather than an assumed token address; a mismatched sentinel silently shifts all subsequent indices.

