# Price and market cap

The whole supply sits in one position spanning from the floor to the top of the tick range, so
Tartarus pricing has a simple closed form. It behaves like a constant-product pool in which the quote
side starts at zero.

## The math

Let `M` be the starting market cap in quote, and `f` the fraction of supply bought so far. Before fees:

```
quote spent to reach f   =  M · f / (1 − f)
price at f               =  floor / (1 − f)²
market cap at f          =  M / (1 − f)²
```

Market cap here means **price × 1,000,000,000**, the fully diluted figure. There is only one supply
number, and every token that is not in the pool has been bought from it.

## At launch config 0

Config 0 has `startingTick` 171400, tick spacing 200, and a floor of about 0.000000036 HYPE per token,
which makes `M` about **36.02 HYPE**.

| Supply bought | Cost (HYPE) | Market cap (HYPE) | Multiple of start |
|---|---|---|---|
| 0.1% | 0.04 | 36.1 | 1.00× |
| 1% | 0.36 | 36.8 | 1.02× |
| 5% | 1.90 | 39.9 | 1.11× |
| 10% | 4.00 | 44.5 | 1.23× |
| 25% | 12.0 | 64.0 | 1.78× |
| 50% | 36.0 | 144 | 4× |
| 75% | 108 | 576 | 16× |
| 90% | 324 | 3,602 | 100× |
| 99% | 3,566 | 360,217 | 10,000× |

Costs are cumulative from launch and exclude the swap fee. A trade of the same size moves the price
much less once a token has been bought into, because the same quote buys fewer tokens at a higher
price.

Live figures are in `GET /v1/protocol`: `launchConfigs[].floorPrice`, `floorMarketCap` and
`floorMarketCapUsd`.

## The starting tick

`startingTick` is the **tokens-per-quote** price at the floor, in raw units, for every quote asset. A
higher tick means a cheaper token.

```
tokensPerQuote = 1e9 · quoteUsd / targetMcapUsd
P              = tokensPerQuote · 10^(18 − quoteDecimals)
tick           = floor(ln(P) / ln(1.0001)), rounded down to a multiple of tickSpacing
```

The owner retunes this with `updateLaunchConfig` as the quote's price moves. Launched pools keep the
price they opened at.

## Reading the price

`StateView.getSlot0(poolId)` returns `sqrtPriceX96`, which is V4's `currency1` per `currency0`, in raw
units. On a HYPE pool that is tokens per HYPE, so invert it for a price in HYPE:

```ts
const [sqrtPriceX96] = await client.readContract({
  address: STATE_VIEW, abi: stateViewAbi, functionName: "getSlot0", args: [poolId],
});
const tokensPerHype = (Number(sqrtPriceX96) / 2 ** 96) ** 2;
const priceInHype = 1 / tokensPerHype;
```

That float is fine for display. Never use it to size a trade. The API's `price`, `marketCap`,
`priceUsd` and `marketCapUsd` come already computed.

## What "floor" guarantees

The floor is where **Tartarus's own liquidity** ends. It is not a promise about what a token is worth.
Near the floor there may be very little quote in the pool to sell into. Third parties can also add
their own V4 liquidity to a pool, because the hook does not block it, though that liquidity earns no
LP fee and does not change the locked position.