# ShortLongSpell#openPosition can cause user unexpected liquidation when increasing position size

ShortLongSpell.openPosition burns all existing collateral and refunds it to the user when increasing a position, leaving the position undercollateralized and prone to immediate liquidation.

- Payout: Contest reward
- Severity: high
- Program: Blueberry
- Credited: 0x52
- Disclosed: 2023-04-07
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/135
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-04-blueberry%3AH-11
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** ShortLongSpell.openPosition in blueberry-core
**Root cause:** When increasing a position, the spell takes and burns the entire existing collateral and refunds underlying tokens to the user instead of keeping collateral in the position, leaving only isolated collateral backing the debt.
**Steps:**
1. User has an open position with collateral in the wrapper vault.
2. User calls ShortLongSpell.openPosition to increase position size.
3. Code reads pos.collateralSize, calls bank.takeCollateral(collSize), wrapper.burn(burnToken, collSize), then _doRefund(burnToken).
4. All collateral is burned and underlying refunded to user, leaving position collateralized only by isolated collateral.
5. Small price move triggers liquidation.
**How found:** Code review of the openPosition collateral-handling block; noticed collateral is fully burned and refunded rather than retained, reasoning that this removes the buffer protecting the user from liquidation.
**Insight:** In leveraged-position spells, check whether 'increase position' paths preserve existing collateral; a refund of collateral during size increase silently strips the liquidation buffer.
