# Bonding Curve

Hypers.fun uses a **constant product bonding curve** with virtual reserves to determine token prices.

### Why bonding curve?

| Traditional AMM             | Hypers.fun bonding curve   |
| --------------------------- | -------------------------- |
| Needs external LPs          | No LP required             |
| Liquidity can be pulled     | Always available liquidity |
| Price depends on pool depth | Price anchored to NAV      |
| Slippage varies wildly      | Predictable price impact   |

### The formula

Token pricing follows the constant product formula (`x × y = k`):

```
Buy:  tokensOut = virtualTokens × usdcIn / (virtualBase + usdcIn)
Sell: usdcOut   = virtualBase × tokensIn / (virtualTokens + tokensIn)
```

**Example**

Assume:

* `virtualBase` = `2,000,000` USDC
* `virtualTokens` = `2,000,000` tokens
* You buy with `10,000` USDC

```
tokensOut = 2,000,000 × 10,000 / (2,000,000 + 10,000)
         = 20,000,000,000 / 2,010,000
         ≈ 9,950.25 tokens

Average execution premium ≈ 0.5%
Post-trade spot price ≈ +1.0%
```

### Virtual reserve mechanism

Virtual reserves simulate deep liquidity even for small vaults. This prevents extreme price swings when TVL is low.

| Parameter       |   Default | Meaning               |
| --------------- | --------: | --------------------- |
| `virtualBase`   | 2,000,000 | Virtual USDC reserve  |
| `virtualTokens` | 2,000,000 | Virtual token reserve |

How it works:

```
Actual Price = NAV × (virtualBase / virtualTokens)
```

The virtual reserves don't represent real assets. They are parameters that control the curve shape.

### Dynamic scaling

Fixed virtual reserves break at extremes:

* Small vault → price impact too high
* Large vault → price impact too low

So we scale virtual reserves proportionally with TVL:

```solidity
function getEffectiveVirtualTokens() public view returns (uint256) {
    uint256 assets = getEstimatedAssets();
    if (assets <= initialAssets) return virtualTokens;
    return (virtualTokens * assets) / initialAssets;
}

function getEffectiveVirtualBase() public view returns (uint256) {
    uint256 assets = getEstimatedAssets();
    if (assets <= initialAssets) return virtualBase;
    return (virtualBase * assets) / initialAssets;
}
```

Example:

| Vault TVL        | Effective virtual reserves | $10K buy impact |
| ---------------- | -------------------------- | --------------- |
| $1,000 (initial) | 2M / 2M                    | \~0.5%          |
| $100,000         | 200M / 200M                | \~0.5%          |
| $10,000,000      | 20B / 20B                  | \~0.5%          |

Result: **consistent price impact regardless of vault size.**

### Maximum purchase limit

To prevent single trades from manipulating prices, each transaction is capped:

```solidity
maxBuyBps = 100; // max 1% of total assets per transaction
```

|   Vault TVL | Max single buy |
| ----------: | -------------: |
|    $100,000 |         $1,000 |
|  $1,000,000 |        $10,000 |
| $10,000,000 |       $100,000 |

If you want to buy more, split into multiple transactions.

### Price boundaries

Prices are capped to prevent extreme deviations from NAV:

| Boundary     | Limit | Meaning                            |
| ------------ | ----- | ---------------------------------- |
| Max premium  | +100% | Price cannot exceed `2×` NAV       |
| Max discount | -50%  | Price cannot fall below `0.5×` NAV |

```solidity
uint256 maxPrice = (nav * (BPS + maxPremiumBps)) / BPS;  // 2× NAV
uint256 minPrice = (nav * (BPS - maxDiscountBps)) / BPS; // 0.5× NAV
```

### Summary

```
Base price     = NAV (Total Assets / Total Supply)
Actual price   = NAV × (virtualBase / virtualTokens)
Virtual reserves scale with TVL (dynamic scaling)
Boundaries     = 0.5× NAV to 2× NAV
Max buy        = 1% of TVL per transaction
```


---

# 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://hyper-fun.gitbook.io/hypers.fun/tokenomics/bonding-curve.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.
