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

# Algorithms

> Mathematical deep-dive chapter: the invariants, pricing formulas, and edge cases behind every Raydium product.

## Who this chapter is for

Protocol researchers, auditors, and advanced integrators who want to understand the *why* behind the math rather than just call the instructions. Product pages give a summary and defer here for derivations.

## Chapter contents

> [card] [Constant product (xy=k)](https://docs.raydium.io/algorithms/constant-product.md)
>
> Invariant, marginal price, swap input/output formulas, slippage as a function of trade size.

> [card] [CLMM math](https://docs.raydium.io/algorithms/clmm-math.md)
>
> Sqrt-price representation, liquidity ↔ amount conversion, single-tick swap step, fee-growth accumulator, multi-tick swap iteration.

> [card] [Bonding curves](https://docs.raydium.io/algorithms/bonding-curves.md)
>
> LaunchLab's curve formula(s), graduation threshold derivation, continuous vs. discrete pricing.

> [card] [Slippage and price impact](https://docs.raydium.io/algorithms/slippage-and-price-impact.md)
>
> Definitions, how SDK computes `minAmountOut`, what "price impact" means across AMM types, MEV considerations.

> [card] [Token-2022 transfer fees](https://docs.raydium.io/algorithms/token-2022-transfer-fees.md)
>
> How a transfer-fee-bearing token changes the effective swap input and output amounts, and how the CPMM/CLMM programs handle it.

> [card] [Impermanent loss](https://docs.raydium.io/algorithms/impermanent-loss.md)
>
> IL formulas for CPMM and CLMM, worked examples, and the break-even fee APR thresholds every LP should know.

> [card] [Estimating CLMM APR](https://docs.raydium.io/algorithms/clmm-apr.md)
>
> How Raydium computes the APR shown on CLMM pools and how to project APR for a prospective range before opening it.

## Writing brief

* Use LaTeX-style math sparingly; show formulas as code blocks with inline prose.
* Every formula is followed by a worked numeric example.
* Every page has a "Where this is implemented" section that points to the relevant line range in the on-chain program source, for auditors.
* Do not re-derive the same formulas on product pages — link here.


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