# Bonding Curve

### **Contract Info**

* **Contract Name**: `move_fun::bonding_curve`
* **Contract Address**: \[tba]

### Resources

***

#### **BondingCurve**

Represents a bonding curve for a token.

```move
struct BondingCurve has key, drop {
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    growth_constant: u128
}
```

| Name                        | Type | Description                                                           |
| --------------------------- | ---- | --------------------------------------------------------------------- |
| initial\_price\_numerator   | u128 | Initial price numerator for the token.                                |
| initial\_price\_denominator | u128 | Initial price denominator for the token.                              |
| growth\_constant            | u128 | Growth constant (k) that determines how the price scales with supply. |

***

### Public Functions

***

#### **Initialize**

Initializes the bonding curve with initial price and growth constant.

```move
public(friend) fun initialize(
    signer_ref: &signer,
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    growth_constant: u128
)
```

| Input Values                | Type   | Description                                    |
| --------------------------- | ------ | ---------------------------------------------- |
| signer\_ref                 | signer | The signer's reference.                        |
| initial\_price\_numerator   | u128   | The initial numerator for the token price.     |
| initial\_price\_denominator | u128   | The initial denominator for the token price.   |
| growth\_constant            | u128   | The growth constant (k) for the bonding curve. |

***

#### **Calculate Growth Constant**

Calculates the growth constant ( k ) based on the bonding curve parameters.

```move
public(friend) fun calculate_k(
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    target_price_numerator: u128,
    target_supply: u128,
    max_supply: u128
): u128
```

| Input Values                | Type | Description                |
| --------------------------- | ---- | -------------------------- |
| initial\_price\_numerator   | u128 | Initial price numerator.   |
| initial\_price\_denominator | u128 | Initial price denominator. |
| target\_price\_numerator    | u128 | Target price numerator.    |
| target\_supply              | u128 | Target supply amount.      |
| max\_supply                 | u128 | Maximum supply amount.     |

***

#### **Calculate Price**

Calculates the token price based on the supply and bonding curve parameters.

```move
public(friend) fun calculate_price(
    curve: &BondingCurve,
    max_supply: u128,
    decimals: u128,
    new_supply_base_value: u128,
    new_supply_exponent_value: u128
): u128
```

| Input Values                 | Type           | Description                              |
| ---------------------------- | -------------- | ---------------------------------------- |
| curve                        | \&BondingCurve | The bonding curve reference.             |
| max\_supply                  | u128           | Maximum supply of the token.             |
| decimals                     | u128           | Number of decimals to use for precision. |
| new\_supply\_base\_value     | u128           | The new supply base value.               |
| new\_supply\_exponent\_value | u128           | The new supply exponent value.           |

***

#### **Set Market Cap Goal**

Adjusts the bonding curve based on a new target market cap.

```move
public(friend) fun set_market_cap_goal(
    coin_addr: address, 
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    target_price_numerator: u128,
    target_supply: u128,
    max_supply: u128
): u128 acquires BondingCurve
```

| Input Values                | Type    | Description                |
| --------------------------- | ------- | -------------------------- |
| coin\_addr                  | address | Address of the token.      |
| initial\_price\_numerator   | u128    | Initial price numerator.   |
| initial\_price\_denominator | u128    | Initial price denominator. |
| target\_price\_numerator    | u128    | Target price numerator.    |
| target\_supply              | u128    | Target supply amount.      |
| max\_supply                 | u128    | Maximum supply amount.     |

***

### View Functions

***

#### **Initial Price**

Returns the initial price of the bonding curve for a token.

```move
public fun initial_price<CoinType>(): (u128, u128) acquires BondingCurve
```

| Return Values               | Type | Description                             |
| --------------------------- | ---- | --------------------------------------- |
| initial\_price\_numerator   | u128 | Initial price numerator of the token.   |
| initial\_price\_denominator | u128 | Initial price denominator of the token. |

***

#### **Growth Constant**

Returns the growth constant ( k ) for the bonding curve of a token.

```move
public fun growth_constant<CoinType>(): u128 acquires BondingCurve
```

| Return Values    | Type | Description                                 |
| ---------------- | ---- | ------------------------------------------- |
| growth\_constant | u128 | Growth constant ( k ) of the bonding curve. |


---

# 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.yuzu.finance/move.fun/technical/coin-amm/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.
