Skip to content
Business logic Audit finding Intermediate

Taker fees can be bypassed via asymmetric liquidity provision to a pool

Asymmetric liquidity provision charges only the swap fee on the virtual swap, not the taker fee. An attacker could deposit asymmetrically and immediately withdraw, effectively swapping without paying the taker fee.

cu5t0mPe0 Follow with dandan and haxagon

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-dango-dex-judging/issues/268

Found by

cu5t0mPe0, dandan, haxagon

Summary

Taker fees can be bypassed via liquidity provision to a pool

Root Cause

During a swap / order against a XYK or geometric pool, there are two fees charged to the user,

  1. the swap / LP fee, the fee paid to liquidity providers of the pool
  2. the taker fee, the fee paid to the taxman for swapping against the pool (which is considered a taker order)

It is possible to bypass the taker fee, via asymmetric liquidity provision to a pool. During asymmetric liquidity provision, a swap fee is charged based on a virtual swap on the pool using a portion of the liquidity and then adding the rest of the liquidity that is balanced with the pool ratio after the virtual swap is done.

https://github.com/left-curve/left-curve/blob/main/dango/dex/src/core/liquidity_pool.rs#L177-L246

RS
        // In case the deposit is asymmetrical, we need to apply a deposit fee.
        //
        // This is to prevent an attack where a user deposits asymmetrically,
        // then immediately withdraw symmetrically, essentially accomplishing a
        // swap without paying the swap fee.
        //
        // We determine the deposit fee rate based oracle price as follows:
        //
        // - Suppose the pool's reserve is `A` dollars of the 1st asset and `B`
        //   dollars of the 2nd asset.
        // - Suppose a user deposits `a` dollars of 1st asset and `b` dollars of
        //   the 2nd asset.
        // - Note that `A`, `B`, `a`, and `b` here are values in USD, not the
        //   unit amounts.
        // - Without losing generality, assume a / A > b / B. In this case, the
        //   user is over-supplying the 1st asset and under-supplying the 2nd
        //   asset. To make the deposit symmetrical, the user needs to swap some
        //   1st asset into some 2nd asset.
        // - Suppose user swap `x` dollars of the 1st asset into the 2nd asset.
        //   Also suppose our pool does the swap at exactly the oracle price
        //   without slippage. This assumption obviously isn't true, but is good
        //   enough for the purpose of preventing the aforementioned attack.
        // - We must solve:
        //   (a - x) / (A + x) = (b + x) / (B - x)
        //   The solution is:
        //   x = (a * B - A * b) / (a + A + b + B)
        // - We charge a fee assuming this swap is to be carried out. The USD
        //   value of the fee is:
        //   x * swap_fee_rate
        // - To charge the fee, we mint slightly less LP tokens corresponding to
        //   the ratio:
        //   x * swap_fee_rate / (a + b)
        ...
        let fee_rate = {
            let price = oracle_querier.query_price(reserve.first().denom, None)?;
            let a = price
                .value_of_unit_amount::<24>(*deposit.first().amount)?
                .into_next();
            let reserve_a = price
                .value_of_unit_amount::<24>(*reserve.first().amount)?
                .into_next();

            let price = oracle_querier.query_price(reserve.second().denom, None)?;
            let b = price
                .value_of_unit_amount::<24>(*deposit.second().amount)?
                .into_next();
            let reserve_b = price
                .value_of_unit_amount::<24>(*reserve.second().amount)?
                .into_next();

            let deposit_value = a.checked_add(b)?;
            let reserve_value = reserve_a.checked_add(reserve_b)?;

            // IMPORTANT!
            // we have to be sure that abs( a * reserve_b - b * reserve_a ) is not approxed to 0
            // because the low precision.
            // For this reason, it make sense to keep 24 decimal places in value_of_unit_amount
            // and use into_next() to avoid overflows.
            // Otherwise the fee rate could be 0 even if very low amount of tokens are deposited even unbalance.
            // Since we don't have gas price, this can be an attack vector.
            abs_diff(a.checked_mul(reserve_b)?, b.checked_mul(reserve_a)?)
                .checked_div(deposit_value.checked_add(reserve_value)?)?
                .checked_mul(self.swap_fee_rate.into_next())?
                .checked_div(deposit_value)?
                .checked_into_prev()?
        };

The problem is that only the LP / swap fee is charged on the virtual swap. The virtual swap does not charge the taker fee which allows someone to first provide an asymmetric deposit and then burn the received LP tokens and in effect realizing the virtual swap, completely bypassing the taker fee.

Internal Pre-conditions

External Pre-conditions

Attack Path

Suppose we have a geometric pool consisting of 10 ETH and 20000 USDC and 1 ETH = 2000 USDC and a swap fee of 0.1% and a taker fee of 1%. (We make swap fee negligible to taker fee to emphasise the difference.)

An attacker wants to swap 1 ETH for USDC in this pool. They can call add_liquidity with 2.222 ETH. They then immediately burn the LP tokens via withdraw_liquidity to withdraw some ETH and USDC, realizing their virtual swap performed during the asymmetric deposit without incurring any taker fees.

Amount of USDC virtual swap:

$$ x = \frac{4444 \cdot 20000}{20000 + 20000 + 4444} = 2000 $$

Fee rate:

$$ f = \frac{2000 \cdot 0.001}{4444} = 0.00045 $$

Total ETH withdrawn after LP token burn:

$$ ETH = (1-0.00045)(\frac{44444}{40000} - 1)(\frac{44444}{40000})^{-1}(12.2222) = 1.2215 $$

Total USDC withdrawn after LP token burn:

$$ USDC = (1-0.00045)(\frac{44444}{40000} - 1)(\frac{44444}{40000})^{-1}(20000) = 1999 $$

Essentially, the 0.1% swap fee is charged from both the USDC and ETH when redeeming the LP tokens, however notice we can completely bypass the taker fee via this path of asymmetric liquidity provision then withdrawal.

Impact

The protocol receives less fees than intended.

PoC

No response

Mitigation

No response

The original report as published on Sherlock, by cu5t0mPe0. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 asymmetric deposit fee calculation applies only the swap fee rate to the virtual swap and omits the taker fee.

Impact

The protocol receives less fees than intended.

What the attacker needed

Access to a pool with asymmetric liquidity; ability to add and withdraw liquidity

How it was found

  1. Call add_liquidity with an asymmetric amount of tokens to trigger a virtual swap.
  2. Immediately burn the received LP tokens via withdraw_liquidity to realise the virtual swap.
  3. Observe that only the swap fee was charged and the taker fee was avoided.

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 pool lets people trade one token for another and charges two fees: one to the pool's liquidity providers and one to the protocol. When someone adds tokens in an unbalanced way, the pool pretends a small trade happened and charges only the first fee. By adding unbalanced tokens and then immediately taking them back out, a user gets the trade without paying the protocol's fee.

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.

More by cu5t0mPe0

View all

4 more disclosed reports, best first.

More from Dango DEX

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.