Protocol fee conversion uses pre‑swap price snapshot
The protocol fee is converted to the fee currency using the pre-swap price snapshot, so a swap that moves the price leaves the fee under-valued. An attacker can prime the price with a small swap, execute a large swap, and unwind to make the protocol collect less in wBLT.
Source: https://github.com/sherlock-audit/2025-09-bmx-deli-swap-judging/issues/4
Found by
blockace, cergyk, globalace, silver_eth, x15
Description
In the concentrated‑liquidity hook (DeliHook), the fee is denominated in the user’s specified token using the pre‑swap price snapshot, then converted to the fee currency (wBLT) before the swap executes.
The swap then moves the price, but the fee amount in wBLT is not re‑valued after the move. This lets an attacker bias the conversion rate (“prime”) right before the large swap and unwind after, so the protocol under‑collects fees in wBLT. The documented floor/ceil asymmetry on token0↔token1 conversions can be chosen by the attacker to further cheapify the fee.
The codepath reads the price before the swap and computes a base fee in the specified token. _beforeSwap pulls sqrtPriceX96 from StateLibrary.getSlot0 (pre‑swap), and computes
(uint160 sqrtPriceX96,,, uint24 poolFee) = StateLibrary.getSlot0(poolManager, key.toId());
// fee in specified-token units
uint256 baseFeeSpecified = FullMath.mulDiv(absAmountSpecified, uint256(poolFee), 1_000_000);
This is explicitly done before the swap in the concentrated hook.
Next it converts that base fee to wBLT using the pre-swap price and asymmetric rounding. If the specified token isn't wBLT, the hook converts via $p = \text{token1 per token0} = \frac{\text{sqrt}^2}{2^{192}}$ with:
- token0 → token1:
floor(base * p)(twomulDivfloors) - token1 → token0:
ceil(base / p)(twomulDivRoundingUp)
These exact paths are implemented in _beforeSwap and stored into _pendingFee.
It then charges the fee amount computed pre‑swap after the swap without re‑pricing. _afterSwap simply takes feeOwed = _pendingFee (the amount computed off the pre‑swap snapshot) and transfers that many wBLT to the FeeProcessor. There is no recomputation against the post‑swap price.
As a result If the swap moves price materially (common on steep concentrated curves), the conversion done at the pre‑swap price can be far from the fair post‑swap valuation. An attacker can
-
Prime the price with a small swap so that the pre-swap $p$ used for conversion is favorable (for example, make $p$ high to minimize
ceil(base/p)when paying fee in token0; or make $p$ low to minimizefloor(base*p)when paying fee in token1). -
Execute a large swap; the fee (in wBLT) is charged at the pre-swap conversion.
-
Unwind the prime (or do an opposite-leg cycle across two pools).
Because the hook allows either rounding floor (token0→token1) or ceil (token1→token0), an attacker can choose orientation and exactInput/Output so the rounding direction plus the stale price both reduce the wBLT amount actually paid.
Note: This issue is specific to the concentrated hook shown above. The constant‑product hook computes/forwards fees differently and does not use
sqrtPriceX96for fee conversion; this finding targets the concentrated path.
Recommendation
Store baseFeeSpecified and whether it’s token0/token1 in _beforeSwap, but delay the conversion to wBLT until _afterSwap and convert using sqrtPriceX96 read after the swap. This aligns the fee’s valuation point with the deduction point. (All the plumbing you need is already there: _pendingFee and _pendingCurrency handoffs, and _afterSwap is already where the fee is transferred.)
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/morphex-labs/deli-swap-contracts/pull/23
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The fee is converted to wBLT using the pre-swap price and not recomputed after the swap changes the price.
Impact
The protocol could under-collect fees in wBLT when a swap moves the price materially.
What the attacker needed
Ability to swap in the pool; swap moves price materially
The fix
The protocol team fixed this issue by delaying the conversion to wBLT until after the swap and using the post-swap price.
How it was found
- Prime the price with a small swap so the pre-swap conversion rate is favourable.
- Execute a large swap; the fee in wBLT is charged at the pre-swap conversion.
- Unwind the prime or do an opposite-leg cycle across two pools.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A hook is code that runs before and after a swap. The fee is calculated before the swap using the old price, but the swap changes the price. An attacker can nudge the price first so the fee is calculated too low, then do a big swap and undo the nudge.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.