Attacker can swap wBTC in the DeliHook multiples times to not pay / pay less swap fees
The DeliHook contract rounds down the base fee when calculating swap fees, allowing an attacker to pay zero or reduced fees by swapping small amounts of wBTC. This results in lost fee revenue for liquidity providers.
0x73696d616f Follow with 0xDyDx
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-09-bmx-deli-swap-judging/issues/203
Found by
0x73696d616f, 0xDyDx
Summary
DeliHook::_beforeSwap() rounds down the baseFeeSpecified instead of rounding up, allowing an attacker to abuse the low gas fees on Base and the high btc price to not pay any fees (or half).
The attacker swaps in a pool with the DeliHook and wBTC, with a fee of for example 300 (0.03%). For a wBTC amount of 3000 wei or 3 USD, baseFeeSpecified = 3000 * 300 / 1e6 = 0.9 = 0, and the user pays 0. If a 0 fee is problematic for any reason, the attacker can specify 6000 wei, and still save 1 wBTC due to rounding down each time.
The attack is economic viable because 1 wei of wBTC = 1 * 100_000 / 1e8 = 0.001 USD, and the gas cost of a single swap, when bundled together to optimize hot storage, is many times smaller. As an example, a sample swap takes a fee of 0.001566 USD, without using the hot storage properties nor fixed costs, and is already close to profitability. If swaps are made in a loop, the gas price of each swap will go down a lot due to not having fixed tx costs and hot storage loading, making the attack viable. In times of lower gas usage, it is even more profitable.
This causes a 100% fee loss for users of the protocol, hence high severity.
Note: it should also round up when converting the baseFeeSpecified to the fee currency, when needed.
Root Cause
DeliHook.sol:231 rounds down instead of up.
Internal Pre-conditions
None
External Pre-conditions
None
Attack Path
- Attacker swaps in a loop wBTC, paying 1 less wBTC each time due to rounding down, so the lps (FeeProcessor, DailyEpochGauge) receive much less fees.
Impact
A single attacker can cause a significant loss, if all users do this, they would eliminate all lp fees, or very significantly reduce them, and it is profitable.
PoC
See above.
Mitigation
Round up the fee.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/morphex-labs/deli-swap-contracts/pull/24
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
Impact
A single attacker can cause a significant loss, and if all users do this, they would eliminate all lp fees, or very significantly reduce them, and it is profitable.
What the attacker needed
None
The fix
The protocol team fixed this issue by rounding up the fee.
How it was found
- Attacker swaps in a loop wBTC, paying 1 less wBTC each time due to rounding down, so the lps (FeeProcessor, DailyEpochGauge) receive much less fees.
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.
When you swap tokens on a decentralised exchange, you pay a small fee. This report shows that a rounding mistake in the fee calculation lets someone pay less than they should, or even nothing, by swapping tiny amounts. That means the people who provide the tokens for trading earn less money.
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.