Liquidity & price impact

Find a maximum trade size for a stated price-impact budget

Invert a fee-free constant-product average-rate formula to find the input size compatible with an explicit impact budget.

For a fee-free constant-product pool, an average output-rate shortfall limit can be translated into an input-size limit. The result is a model calculation, not a universal sizing rule for every AMM.

Define the exact limit

Let x be the starting input reserve and a the trade input. Assume x > 0, a ≥ 0 and a permitted shortfall fraction 0 ≤ b < 1. Relative to the initial output-per-input spot rate, the average-rate shortfall is a / (x + a). To keep that shortfall at or below b, solve:

a / (x + a) ≤ b

a ≤ b × x / (1 − b)

With a hypothetical x of 100,000 and b of 0.01, maximum modeled input is approximately 1,010.10101 tokens. That corresponds to a 1% average output-rate shortfall, not merely a trade equal to 1% of the reserve.

Validate the substitution

Putting 1,010.10101 back into a / (100,000 + a) yields 0.01. The initial output reserve affects how many output tokens are received, but cancels from this relative shortfall measure under the stated model. A 100% shortfall ceiling provides no finite input-size bound in this idealized model, so the displayed inversion does not apply at b = 1.

The underlying invariant comes from the constant-product pool design. This inversion is an illustrative derivation with fees excluded.

Know when to stop using the shortcut

A total execution-cost ceiling must also consider fees and separate payments. A final marginal-price movement limit needs a different formula. Concentrated liquidity can cross range boundaries, and a stable-asset pool follows another curve.

For a real route, obtain quotes near the calculated threshold using the actual state and fee rule. If the selected path changes, the original single-pool formula no longer describes the entire trade.

Never infer an acceptable personal risk level from b. The calculation takes a chosen constraint as input and states the maximum size under assumptions; it does not recommend that constraint or promise execution at the resulting size.

Sources & verification (1)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. Uniswap v2 Core

    Invariant, reserve accounting and historical protocol design; do not repeat obsolete activation status.

    https://uniswap.org/whitepaper.pdf

Continue reading

Measure liquidity within a one-percent price band Relate swap size to the reserve you are adding to Estimate constant-product output from reserves and a fee