Skip to content

Asset classes and instruments · AMM constant product

What does a trade cost in a constant-product pool?

The cost and price impact of a buy, an LP position against holding, and the extra cost to a user of a sandwiched trade, on the reserves you enter.

Inputs

No lesson works an example for this tool, so it opens on round starting values. The tool suggests no number: enter your own.

0 by default, as in the lessons.

The size you enter; it is never solved for.

Cost of buying 1.00 tokens40,404.04 MDTConstant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees
  • k = x × y · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees400,000,000
  • Spot price, y ÷ x · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees40,000.00 MDT
  • Average price paid · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees40,404.04 MDT
  • Average over spot · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees1.01%
  • Cost of buying 10.00 tokens · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees444,444.44 MDT
  • Average price paid for 10.00 tokens · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees44,444.44 MDT
  • Average over spot for 10.00 tokens · Constant-product pool, x × y = k, on the entered reserves; a pool fee is charged on the quote paid in and kept outside k; impermanent loss is versus holding, excludes pool fees earned, and the model assumes no fees11.11%
  • LP value ÷ hold value, 2√r ÷ (1 + r) · versus holding; excludes pool fees earned; model assumes no fees0.9428
  • Impermanent loss · versus holding; excludes pool fees earned; model assumes no fees−5.72%
  • LP position value · versus holding; excludes pool fees earned; model assumes no fees$14,142
  • Shortfall against holding · versus holding; excludes pool fees earned; model assumes no fees$858
  • Cost to the user, sandwiched · cost to the user only, at the entered front-run size, which is not solved for40,813.20 MDT
  • Extra cost to the user from the sandwich · cost to the user only, at the entered front-run size, which is not solved for; the same fee treatment on both costs409.16 MDT
  • User's average price over spot, sandwiched · cost to the user only, at the entered front-run size, which is not solved for2.03%

A pool of 100.00 tokens and 4,000,000.00 MDT has k = 400,000,000 and a spot price of 40,000.00 MDT. Buying 1.00 costs 40,404.04 MDT (1.01% over spot); buying 10.00 averages 44,444.44 MDT (11.11%), with a 0.00% pool fee: constant-product arithmetic on the entered reserves. At a price ratio of 2.00 the LP position is worth 0.9428 of holding: $14,142 against $15,000, a shortfall of $858 (−5.72%), versus holding; excludes pool fees earned; model assumes no fees. Cost to the user of a sandwiched trade: with 0.50 tokens bought ahead (the entered size, not solved for), the user pays 40,813.20 MDT against 40,404.04 MDT unsandwiched (the same fee treatment on both), an extra 409.16 MDT, 2.03% over spot, within the entered 3.00% tolerance. Framed only as cost to the user. Protocol risk and the total-loss row: a pool can lose its reserves to a contract failure, or a token can go to zero, and an LP position falls with it. No protocol is named or evaluated, and no fee-APR or yield figure is shown.

Educational and informational only — not investment advice, a recommendation, or an offer to buy or sell any security. Investing involves risk, including the possible loss of principal. Worked examples use fictional companies and figures.

Used in these lessons

When it helps

Working through price impact, impermanent loss or a sandwiched trade in a constant-product pool.

Reading the result

The pool keeps x times y constant, so each token taken out costs more quote than the last: that curve is the price impact, and the same curve leaves an LP behind simply holding when the price moves (versus holding, pool fees earned excluded). The sandwich is the cost to the user only, at a front-run size you enter. Protocol risk is not in any of these numbers.

Nothing you enter is saved or sent. Calculators earn no XP.