Skip to content
Business logic Audit finding Intermediate

Launchpad slippage is not enforced properly during token graduation

The launchpad's buy function checks slippage only against the cost of tokens bought from the bonding curve, not the total purchase including the subsequent AMM swap after graduation. An attacker could cause a buyer to receive far fewer tokens than expected at an exorbitant effective price while the transaction still succeeds.

chaos304 Follow with 0rpse, bigbear1229 and 17 others

Originally disclosed on Code4rena

Submitted by chaos304, also found by 0rpse, bigbear1229, deividrobinson, Ekene, hgrano, HighKingMargo, jesjupyter, Kaysoft, la-arana-inteligente, Legend, NexusAudits, niffylord, nuthan2x, r1ver, randomx, taticuvostru, udogodwin, VinciGearHead, and Web3Vikings

launchpad/Launchpad.sol #L287

When a user wants to buy tokens from the launchpad, they specify the number of base tokens they want to buy and the max amount of quote tokens they want to spend as slippage. The contract then proceeds to buy the base tokens from the curve and checks whether the quote tokens paid is higher than the max amount of quote tokens specified by the user or not and reverts the transaction if so.

function buy(BuyData calldata buyData)
    external
    nonReentrant
    onlyBondingActive(buyData.token)
    onlySenderOrOperator(buyData.account, SpotOperatorRoles.LAUNCHPAD_FILL)
    returns (uint256 amountOutBaseActual, uint256 amountInQuote)
{
    IUniswapV2Pair pair = _assertValidRecipient(buyData.recipient, buyData.token);
    LaunchData memory data = _launches[buyData.token];

    (amountOutBaseActual, data.active) = _checkGraduation(buyData.token, data, buyData.amountOutBase);

    amountInQuote = data.curve.buy(buyData.token, amountOutBaseActual);

    if (data.active && amountInQuote == 0) revert DustAttackInvalid();
@>  if (amountInQuote > buyData.maxAmountInQuote) revert SlippageToleranceExceeded();

    buyData.token.safeTransfer(buyData.recipient, amountOutBaseActual);
    address(data.quote).safeTransferFrom(buyData.account, address(this), amountInQuote);

    _emitSwapEvent({
        account: buyData.account,
        token: buyData.token,
        baseAmount: amountOutBaseActual,
        quoteAmount: amountInQuote,
        isBuy: true,
        curve: data.curve
    });

    // If graduated, handle AMM setup and remaining swap
    if (!data.active) {
        (amountOutBaseActual, amountInQuote) = _graduate(buyData, pair, data, amountOutBaseActual, amountInQuote);
    }
}

This slippage protection mechanism is ineffective when a purchase order exhausts the bonding curve’s supply and triggers the “graduation” to a secondary market (AMM pair). The contract checks the slippage against the cost of tokens bought from the bonding curve only, not the total intended purchase. This allows a transaction to succeed even if the user receives a fraction of their desired tokens at an exorbitant effective price.

Recommended mitigation steps

Consider calculating and checking the price per token the user is willing to pay and the price per token bought instead.

View detailed Proof of Concept


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

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 buyer could receive a fraction of their desired tokens at an exorbitant effective price while the transaction still succeeds, because the slippage check does not cover the full purchase.

What the attacker needed

Purchase exhausts bonding curve supply; triggers graduation to AMM

The fix

The contract should calculate and check the effective price per token for the entire purchase, including any AMM swap after graduation, against the user's specified limit.

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 buy tokens on a launchpad, you set a maximum price you are willing to pay to protect yourself from sudden price changes. This report says that protection is broken when the purchase triggers a move to a secondary market, because the check only looks at part of the cost. So you could pay much more than you intended and still have the transaction go through.

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 GTE Perps and Launchpad

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.