# Appendix: Math

## Setup

Each day we have five relevant values:

* Yesterday’s asset prices in dollars, p’
* Today’s asset prices in dollars, p
* Yesterday’s (human) quantity vector, q’ on a *per LP token* basis
* Today’s (human) quantity vector, q on a *per LP token* basis
* Our target wealths vector, v, which we take to be wealth fractions:

$$
\sum\_i v\_i = 1 \ \ \ v\_i \geq 0
$$

Observe that v should *tend to* be proportional to the actual wealth (q\_i\*p\_i) on each asset i.

### Calculating Daily Returns & Benchmarks

All of these benchmarks are designed so that 0 represents no change. Since the values are expected to be small, they may not need to have log taken for additive basis points.

**Daily $ Returns**

$$
\frac{\sum\_i p\_iq\_i - \sum\_i p'\_iq'\_i}{\sum\_i p'\_iq'\_i}
$$

This measures how much the portfolio increased in $ terms since yesterday.

### Daily Crypto Basis Returns

$$
\frac{\sum\_i p\_iq\_i - \sum\_i p\_iq'\_i}{\sum\_i p\_iq'\_i}
$$

This value will be negative if we would prefer yesterday’s portfolio to today’s portfolio at today’s prices.

### Rebalanced Portfolio Benchmark

$$
\sum\_i \left(\frac{p\_i}{p'\_i}\right) v\_i - 1
$$

This is our target benchmark for Clipper: our daily dollar gain should track it closely and ideally outperform.

Observe that a rebalanced portfolio can *outperform* a static (”held”) portfolio consisting of any (!) initial combination of the assets themselves. For instance, imagine the two-asset case consisting of a risky asset and a stablecoin. On day one, the risky asset doubles in price. On day two the risky asset returns to its original value. It can be verified that a 50-50 rebalanced portfolio will return 1.125x, vs. 1x for simply holding any combination of assets for the two days.

### CPMM Loss Benchmark

In the CPMM, we have that:

$$
\begin{align\*}
\prod q\_i^{v\_i} & = C \\
\sum\_i v\_i \log q\_i & = \log C
\end{align\*}
$$

Day-to-day, the portfolio of the CPMM changes to have wealth proportional to the new set of prices. By working out this constant log-sum, we get the following expression for how much “impermanent” loss a CPMM mechanism takes on:

$$
\frac{\prod\_i \left( \frac{p\_i}{p'\_i} \right)^{v\_i} - \sum\_i \left( \frac{p\_i}{p'\_i} \right)v\_i}{\sum\_i \left( \frac{p\_i}{p'\_i} \right)v\_i}
$$

This value is at most 0 when the prices are the same. Clipper’s crypto performance (loss or gain) should substantially outperform this benchmark.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clipper.exchange/introduction/clippers-benchmark-no-impermanent-loss/appendix-math.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
