> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olympex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Slippage and price impact

> Price impact is what your trade size costs against the available liquidity. Slippage is how far you let the price move before the transaction reverts.

Two different numbers decide how much a swap delivers. Price impact is the cost of your trade's size against the liquidity available, and it is already part of the quote. Slippage is the tolerance you set for price movement between the quote and the block that includes your transaction. Olympex turns your slippage into a minimum output that the transaction enforces on-chain. It doesn't report price impact, so you measure it yourself.

## Slippage

`slippage` is a percentage sent as a string: `"1"` is 1% and `"0.5"` is 0.5%. It is required on [`POST /quotes`](/api-reference/quotes/get-quote) and [`POST /swap`](/api-reference/swap/build-swap), in both modes. Send the same value to both, so the minimum you show matches the one the calldata enforces: `minimumReceived` from the quote for cross-chain transfers, and `minOutAmount` from `/swap` for single-chain swaps.

Slippage sets the floor of the trade:

| Mode | Minimum output | Where it comes from |
| - | - | - |
| Single-chain | `swap.minOutAmount`, in base units of the output token | `POST /swap`. The transaction reverts if it would deliver less. |
| Cross-chain | `quote.minimumReceived`, in base units of the destination token | `POST /quotes`. The provider computes it. |

In the single-chain example on [Build a swap](/api-reference/swap/build-swap), `/swap` returns `outAmount` `"9991223"` and, with `slippage` `"1"`, `minOutAmount` `"9891061"`, about 1% lower. For USDC's 6 decimals, the user expects 9.991223 USDC and receives at least 9.891061 USDC. In the cross-chain example on [Get a quote](/api-reference/quotes/get-quote), 10 USDT on Polygon to USDT on Ethereum, `toTokenAmount` `"9985000"` comes with `minimumReceived` `"9885149"`, also about 1% lower.

## Price impact

Price impact is the gap between the pair's market price and the average price your trade gets, caused by the trade's size relative to the liquidity it draws on. It grows with the amount and shrinks with deeper liquidity. Splitting a trade across venues, which sources do inside `routes`, is one way to reduce it.

Price impact is already reflected in `outAmount`: a quote for a larger amount returns a lower rate. The API doesn't return a separate price-impact figure. To measure it, compare the rate of your trade with the rate of a small reference trade for the same pair:

<CodeGroup>
  ```ts TypeScript theme={null}
  import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests

  type QuoteData = { quote: { outAmount: string } };

  const quote = (amount: string) =>
    olympexRequest<QuoteData>("POST", "/quotes", {
      mode: "single-chain",
      params: {
        chainId: 137,
        inTokenAddress: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", // USDT
        outTokenAddress: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", // USDC
        amount,
        slippage: "1",
        gasPrice: "35",
      },
    });

  const [reference, trade] = await Promise.all([quote("1"), quote("10000")]);

  // Token decimals cancel out, so the base-unit outAmount values compare directly.
  const referenceRate = Number(reference.quote.outAmount) / 1;
  const tradeRate = Number(trade.quote.outAmount) / 10000;
  const priceImpactPercent = (1 - tradeRate / referenceRate) * 100;
  console.log(`Price impact: ${priceImpactPercent.toFixed(2)} %`);
  ```

  ```python Python theme={null}
  from sign_request import olympex_request  # /authentication/sign-requests


  def quote(amount):
      return olympex_request("POST", "/quotes", {
          "mode": "single-chain",
          "params": {
              "chainId": 137,
              "inTokenAddress": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",  # USDT
              "outTokenAddress": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",  # USDC
              "amount": amount,
              "slippage": "1",
              "gasPrice": "35",
          },
      })


  reference, trade = quote("1"), quote("10000")

  # Token decimals cancel out, so the base-unit outAmount values compare directly.
  reference_rate = int(reference["quote"]["outAmount"]) / 1
  trade_rate = int(trade["quote"]["outAmount"]) / 10000
  price_impact_percent = (1 - trade_rate / reference_rate) * 100
  print(f"Price impact: {price_impact_percent:.2f} %")
  ```
</CodeGroup>

The result is an estimate. The reference quote carries a little impact of its own, the two quotes can come from different sources, and prices can move between the two calls, so a small negative result means "no measurable impact". Gas isn't part of `outAmount`; for small trades it can cost more than price impact does. See [Gas and fees](/concepts/gas-and-fees).

## Price impact versus slippage

| | Price impact | Slippage |
| - | - | - |
| What it is | The cost of your trade's size | Your tolerance for price movement after the quote |
| Who sets it | The market: liquidity at the time of the quote | You, in `params.slippage` |
| When it applies | Already included in `outAmount` | Between the quote and on-chain execution |
| In the API | Not returned. Measure it with a reference quote. | Sent as `slippage`. Enforced as `minOutAmount` or reported as `minimumReceived`. |
| How to reduce it | Trade a smaller amount, or split the trade over time | Send promptly, so the price has less time to move |

## Quotes are not reserved

Olympex doesn't hold a price between calls. For single-chain swaps, `POST /swap` returns its own `outAmount` and `minOutAmount` for the calldata it builds, and those are the numbers the transaction commits to: show them to the user before anyone signs. Cross-chain `/swap` returns neither, so show the quote's `toTokenAmount` and `minimumReceived`. Then send right away. The calldata carries an on-chain expiry, 5 minutes on most routes, and prices keep moving while it waits. Some routes also include a market maker's firm quote that expires within seconds of the build: if the transaction reverts because that quote expired, build the swap again.

## Choosing a slippage tolerance

Slippage is a trade-off between two failure modes:

* **Too tight:** normal price movement between the quote and inclusion pushes the output below the minimum, and the transaction reverts. The user still pays gas for the reverted transaction.
* **Too loose:** the minimum output drops, so the trade can fill at a worse price. A wide tolerance also leaves more room for bots that trade around pending transactions (sandwich attacks) to extract value from the swap.

Set it by what you trade:

* Stablecoin pairs and deep liquidity move little between quote and execution, and tolerate tight settings. The examples in these docs use `"1"` on a stablecoin pair.
* Volatile or thinly traded tokens need more room.
* Cross-chain routes can include swaps on both chains and a bridge, listed in `middlewareRoute`, which gives the price more time to move.
* Measure and adjust. Track how often your transactions revert and how realized output compares with `outAmount`, per pair, and tune your defaults from that data.

<Warning>
  Don't widen slippage to force a failing trade through. If quotes or transactions keep failing, request a fresh quote or reduce the amount. A wider tolerance only lowers the minimum the user accepts.
</Warning>

## What this means for your integration

* Send the same `slippage` string to `/quotes` and `/swap`.
* Show the minimum the user receives (`minOutAmount` or `minimumReceived`, converted from base units) next to the expected output.
* Measure price impact with a reference quote and warn users above a threshold you choose.
* Build and send promptly. Re-quote instead of widening slippage.

## Related

<CardGroup cols={2}>
  <Card title="Aggregation and routing" icon="route" href="/concepts/aggregation-and-routing">
    How the quote is chosen and how its route is split.
  </Card>

  <Card title="Gas and fees" icon="magnifying-glass-dollar" href="/concepts/gas-and-fees">
    The other costs a swap carries.
  </Card>

  <Card title="Get a quote" icon="code" href="/api-reference/quotes/get-quote">
    The `POST /quotes` reference.
  </Card>

  <Card title="Execute a swap" icon="bolt" href="/guides/execute-a-swap">
    From quote to a confirmed transaction.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.