Maths IA · Calculus · topic 32 of 97
Swapping crypto without a market: the constant-product rule · IB Maths IA idea: guide, sample graph and step-by-step plan
one rule sets every priceSome exchanges have no buyers and sellers at all. A pool holds two kinds of token, and one rule sets every price: the amounts multiplied together never change. You will find out what that rule does to the price you get.
- ✓ you like a simple rule whose consequences take real work to see
- ✓ you want a context for implicit differentiation and optimisation
- ✓ you want to study how a trading rule behaves, not give investment advice
The big idea
Let a pool hold x of token X and y of token Y, with x·y = k kept constant by every trade. The graph is a hyperbola. The price of X in terms of Y is y/x, which is minus the gradient of the curve. Show that with implicit differentiation, not only by dividing. A trade moves the pool along the curve, so a large trade gets a worse price than the quoted one. You can find the exact amount received and how the shortfall, called slippage, grows with trade size. Then ask what happens to a person who put tokens into the pool when the outside price moves. Their loss compared with just holding has a neat formula in the price ratio r, and its derivative and symmetry are classic calculus. Keep the focus on the mathematics of the rule, not on predicting any price.
Make it yours: pick one twist
Copying a classic won't show your choices. Pick one of these (or invent your own) and your IA becomes yours.
Swipe for more twists →
Differentiate x·y = k implicitly to get dy/dx = −y/x and compare it with the slope of the curve y = k/x.
→ Two routes to one result, so you can check one against the other. Explain what the negative sign means for a trader.Find the tokens received for a trade of size dx and compare with the quoted price times dx.
→ A rational function of dx. Study its limit as dx grows and say what it means for the largest possible trade.Define slippage as the fall from the quoted price and find how it depends on dx / x.
→ A function of one ratio, so every pool size gives the same curve. Show why, and use it to compare pools.Charge 0.3% of the input before the trade and recompute the output and the pool's constant.
→ k now grows with every trade. Find how much and test your formula by running many trades in a spreadsheet.Compare the pool's value with the value of simply holding the tokens when the price ratio becomes r, and find a formula.
→ A function IL(r) with a maximum at r = 1. Differentiate it, prove the symmetry between r and 1/r, and graph it on a log axis.Find the trading volume at which fee income cancels impermanent loss for a given price move.
→ Two models meet in one equation. State what you assume about volume and about price paths.Your Maths IA research question: run the check
which pool? which quantity?Write your own question first. Then make sure it ticks every box:
- Names the rule: the invariant, the fee and the sizes of the pool you test.
- Names what you find: a price, an output, a slippage curve or the loss compared with holding.
- Says how formulas are tested: a step-by-step spreadsheet of trades or published pool rules.
- Uses calculus for something you could not do by arithmetic alone, such as a derivative, a limit or an optimum.
- States what you leave out: other traders, price paths, gas costs and every claim about future prices.
The model
A pool, one trader and one rule. Draw the pool with your own starting amounts and mark which quantity stays fixed in each step.
How your Maths IA could be laid out
The usual order for a topic like this, what each part needs to show, and roughly how much of your 12 to 20 pages it takes. The words are all yours.
What a constant-product pool is, why it needs no order book, and what you will find. No view on any price.
The curve, the marginal price from implicit differentiation, and a check against y = k/x.
Exact output for a trade, slippage as a function of trade size, with a worked example and a limit.
The modified rule, the growth of k, and a spreadsheet of repeated trades against your formula.
Derivation of IL(r), its derivative, its symmetry, and a graph on a log axis with sample values.
Back to your aim: the price rule, slippage, the fee effect and the loss formula, with numbers.
No outside trading, fixed fee, no price path, simplified loss. Say which assumption matters most and what the model cannot say about real pools.
Where every rule and parameter came from.
What your Maths IA graph could look like
show the slippage gapMade-up values to show the form of a strong graph, not the answer: the amount of Y a trader receives against the amount of X paid, compared with the quoted price. Yours will use your own pool. example only
- Exact output and the quoted-price line on one set of axes, so the shortfall is visible.
- Axis labels give units: tokens of each kind, not money.
- Plot a few of your spreadsheet trades as points: agreement with the curve is your evidence.
- Say what the exact curve approaches for very large trades.
- Another graph to consider: slippage as a percentage against dx / x.
The maths in action
worked through, not sketched!The graph above was a sketch with made-up numbers. This figure works the idea through from the model itself, so you can see what a finished figure looks like. The source line under it says where every number comes from.
How big a trade hurts the price?
Slippage grows with the size of the trade compared with the pool. Calculate it for several sizes and explain why a large pool is less sensitive.
Your game plan
Tick steps off as you go. We'll remember on this device.
0 of 10 done
- Read and predictRead how a constant-product pool works. Before any algebra, guess whether a trade of ten per cent of the pool costs ten per cent in price.
- Set up the poolChoose starting amounts and define x, y, k, the quoted price and the trade. Sketch the curve with your numbers.
- Price from the derivativeDifferentiate x·y = k implicitly to find dy/dx, and check it against the derivative of y = k/x.
- Trial run (1 lesson)Make a spreadsheet of ten trades and compare it with your formula for the output. Fix any mismatch now: the order of the steps, what k includes, rounding.
- SlippageFind the exact output and the shortfall from the quoted price. Show that slippage depends only on the ratio of the trade to the pool.
- Add the feeApply a fee to the input, rerun your spreadsheet and find how k grows. Compare the growth with your own formula.
- Impermanent lossDerive IL(r) for a price ratio r. Differentiate it, prove IL(r) = IL(1/r) and graph it on a log axis.
- Go further, with a reasonCompare fee income with the loss, or change the rule to a different invariant. HL: prove one more property yourself.
- Reflect as you goAfter every result, write one line on what it means and what it assumes. These lines become your evaluation.
- Cut, check, then sendCheck every graph has labelled axes, every symbol is defined once and the conclusion answers your aim. Then send your teacher one draft.
The maths you'll use
- Rational functions – Write the output as , find its asymptote and compare it with the straight line given by the quoted price.
- Implicit differentiation – Differentiate to get and interpret the gradient as the price.
- Derivative of a quotient – Differentiate , find the stationary point at and justify the maximum.
- Symmetry and logarithmic scales – Show , so is an even function of , and plot it on a logarithmic axis.
- Iteration in a spreadsheet – Run many trades with a fee, track , and compare the growth with a formula.
Key equations
Syllabus links
- 2.8Reciprocal and simple rational functions
- 5.3Differentiating powers of x
- 5.6Standard derivatives; chain, product and quotient rules
- 5.7Second derivative and graph behaviour
- 5.8Maxima, minima, inflexion and optimisation
- 5.14Implicit differentiation, related rates, optimisationHL
- 2.4Key features of graphs
- 5.3Differentiating powers of x
- 5.4Tangents and normals
- 5.9Further derivatives; chain, product, quotient rules; related ratesHL
- 5.10Second derivative testHL
Read up first
Data and sources to start from
A spreadsheet of trades you generate from the rule, plus the published rules of an exchange pool to choose the fee and the formulas.
References to cite
- Adams, H., Zinsmeister, N., & Robinson, D. (2020). Uniswap v2 core.
- Stewart, J. (2015). Calculus: Early transcendentals (8th ed.). Cengage Learning. (Implicit differentiation.)
Cite what you actually use, in your own format, and say where each number came from.
Traps to avoid in this Maths IA
no price predictions- Treating the quoted price y/x as the price you get. It applies only to an infinitely small trade.
- Forgetting that a fee changes k, and then wondering why the spreadsheet drifts from your formula.
- Using money amounts for the tokens without saying how you value them. Keep to token units until you define a price.
- Calling the impermanent loss a real loss of money. It is a comparison with holding, and it only appears when the price ratio changes.
- Differentiating without saying with respect to what. Say whether the derivative is dy/dx or dIL/dr.
- Drifting into advice about which tokens or pools to use. The task is the mathematics of the rule.
More Maths IA ideas like this
Bitcoin's 21 million cap: a geometric series in code●●○
How much should you bet or invest? The Kelly criterion●●○
Setting a price: how to maximise profit from real data●●○
Pricing an option: from coin flips to Black-Scholes●●●
This guide shows how a topic like this is usually approached. It is not an IA. Your question, choices, data, analysis and words must be your own: change something, tell your teacher where the idea came from, and follow your school's rules on outside help.