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

# Curve Configuration

> How DBC's multi-segment bonding curve works — defining up to 16 price-liquidity points, understanding curve shape, and translating curves to PoolConfig parameters.

## The Multi-Segment Bonding Curve

DBC uses a **piecewise concentrated-liquidity curve** with up to 16 segments. Each segment is defined by a `(sqrt_price, liquidity)` pair, creating a price path from the initial price to the migration price.

The curve is stored as an array of `LiquidityDistributionConfig` points in the `PoolConfig` account:

```rust theme={"system"}
pub struct LiquidityDistributionConfig {
    pub sqrt_price: u128,  // upper bound √price of this segment
    pub liquidity: u128,   // virtual liquidity in this segment
}
```

Up to **16** price points (`MAX_CURVE_POINT`).

***

## How the Curve Works

The curve defines how many quote tokens are needed to move the price through each segment:

```
Δquote = liquidity × (√P_upper - √P_lower)
```

A segment with **high liquidity** requires more quote tokens to traverse (flatter price movement). A segment with **low liquidity** is traversed quickly (steep price movement).

### Example: Two-Segment Curve

```
Segment 1: sqrt_price = X₁, liquidity = L₁  (steep launch phase)
Segment 2: sqrt_price = X₂, liquidity = L₂  (flat mature phase)

           ↑ price
     X₂ --|----_________ (L₂: flat, needs many tokens to move price)
     X₁ --|-____         (L₁: steep, few tokens move price a lot)
          |
          initial_sqrt_price
```

***

## Key Curve Parameters

### `sqrt_start_price`

The initial price when the pool opens. Token price starts here and moves up as buyers purchase.

### `sqrt_price` per segment

Each segment's `sqrt_price` is the **upper price bound** of that segment. When the current price reaches it, trading moves to the next segment.

### `migration_sqrt_price`

The price at which the pool migrates. Derived from `migration_quote_threshold` and the total curve:

```
When: quote_reserve >= migration_quote_threshold → migrate
```

### `swap_base_amount`

Total base tokens available for sale through the curve:

```
swap_base_amount = Σ Δbase_per_segment
```

This is pre-calculated from the curve definition and stored in config.

***

## Token Supply Models

<Tabs>
  <Tab title="Dynamic Supply">
    Base tokens are minted on demand as buyers purchase. The total supply grows with each buy.

    * `fixed_token_supply_flag = 0`
    * Requires the `token_update_authority` to be set so the program can mint
    * Post-migration: minting authority is revoked

    **Best for:** Most meme coin / community launches.
  </Tab>

  <Tab title="Fixed Supply">
    All tokens are pre-minted and deposited into the base vault. Leftover tokens (unsold at migration) are returned to `leftover_receiver`.

    * `fixed_token_supply_flag = 1`
    * Pre-migration supply = `pre_migration_token_supply`
    * Post-migration supply = `post_migration_token_supply`
    * Leftover = `pre_migration_token_supply - swap_base_amount - post_migration_token_supply`

    **Best for:** Projects with fixed total supply tokenomics.
  </Tab>
</Tabs>

***

## Visualizing Curve Shapes

Different curve shapes serve different launch strategies:

<AccordionGroup>
  <Accordion title="Steep-then-flat (standard launch)">
    A steep early segment rewards early buyers with a lower average price, then the curve flattens as the supply enters wider distribution. Most DBC launches use this shape.

    ```
    Segment 1: high liquidity → price barely moves per token sold
    Segment 2: low liquidity  → price rises quickly at the end
    ```

    Wait — actually it's the opposite: **low liquidity = steep price**, **high liquidity = flat price**.

    Correct shape for "cheap early, expensive later":

    * Segment 1: **low** liquidity (steep — small buys push price up a lot)
    * Last segment: **high** liquidity (flat — many tokens needed to move price)
  </Accordion>

  <Accordion title="Flat price (stable launch)">
    All segments at roughly equal liquidity creates a near-linear price path. Price discovery is gradual and predictable.
  </Accordion>

  <Accordion title="Exponential / aggressive">
    Very low liquidity throughout → price spikes rapidly. Not recommended for broad distribution.
  </Accordion>
</AccordionGroup>

***

## Calculating Curve Parameters

The TypeScript SDK provides helpers for building curve configurations:

```typescript theme={"system"}
import {
  buildCurve,
  buildCurveAndCreateConfig,
  CurveType,
} from "@meteora-ag/dynamic-bonding-curve-sdk";

// Build a standard launch curve
const curveConfig = buildCurve({
  totalTokenSupply: 1_000_000_000, // 1B tokens
  initialMarketCap: 30_000,        // $30K initial market cap in USD
  migrationMarketCap: 500_000,     // $500K migration market cap in USD
  migrationOption: MigrationOption.DammV2,
  tokenBaseDecimal: 6,
  tokenQuoteDecimal: 9,
  lockedVesting: { ... },
  feeSchedulerMode: FeeSchedulerMode.Linear,
});
```

***

## Constraints

| Constraint                    | Value                      |
| ----------------------------- | -------------------------- |
| Max curve segments            | 16                         |
| `sqrt_price` ordering         | Must be strictly ascending |
| Minimum liquidity per segment | > 0                        |
| `token_decimal`               | 1–9                        |
