> For the complete documentation index, see [llms.txt](https://docs.yuzu.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yuzu.finance/move.fun/technical/coin-amm/router.md).

# Router

## **Contract Info**

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

***

### Resources

***

#### **Info**

Represents the global storage for managing the bonding curve metadata, and only admins can modify it.

```move
struct Info<phantom BuyCoinType, phantom SellCoinType> has key {
    initial_price_numerator: u64,
    initial_price_denominator: u64,
    bonding_curve_goal: u64,
    dex: TypeInfo,
}
```

| Name                        | Type     | Description                                                 |
| --------------------------- | -------- | ----------------------------------------------------------- |
| initial\_price\_numerator   | u64      | Initial price numerator of the bonding curve.               |
| initial\_price\_denominator | u64      | Initial price denominator of the bonding curve.             |
| bonding\_curve\_goal        | u64      | Total sales goal after which the liquidity pool is created. |
| dex                         | TypeInfo | The DEX where the liquidity pool will be created.           |

***

### Entry Functions

***

#### **Create Legacy Coin with Bonding Curve**

Initializes a new bonding curve for a legacy coin. Only callable by the owner of the buy coin.

```move
public(friend) entry fun create<BuyCoinType, DEX>(
    deployer: &signer,
    name: String,
    symbol: String,
    logo: String,
    banner: String,
    description: String,
    links: vector<String>,
    max_wallet_balance: Option<u64>,
    bundled_launch_amount_base_value: Option<u64>,
    bundled_launch_amount_exponent_value: Option<u64>
) acquires Info
```

| Input Values                             | Type   | Description                                 |
| ---------------------------------------- | ------ | ------------------------------------------- |
| deployer                                 | signer | The deployer's signer reference.            |
| name                                     | String | Name of the legacy coin.                    |
| symbol                                   | String | Symbol of the legacy coin.                  |
| logo                                     | String | URL to the logo of the coin.                |
| banner                                   | String | URL to the banner of the coin.              |
| description                              | String | Description of the coin.                    |
| links                                    | vector | List of links related to the coin.          |
| max\_wallet\_balance                     | Option | Optional maximum wallet balance limit.      |
| bundled\_launch\_amount\_base\_value     | Option | Optional base value for bundled launch.     |
| bundled\_launch\_amount\_exponent\_value | Option | Optional exponent value for bundled launch. |

***

#### **Buy Legacy Coin**

Allows users to buy legacy coins based on the bonding curve.

```move
public(friend) entry fun buy<BuyCoinType>(
    buyer: &signer,
    amount_base_value: u64,
    amount_exponent_value: u64
) acquires Info
```

| Input Values            | Type   | Description                          |
| ----------------------- | ------ | ------------------------------------ |
| buyer                   | signer | The buyer's signer reference.        |
| amount\_base\_value     | u64    | Base value of the amount to buy.     |
| amount\_exponent\_value | u64    | Exponent value of the amount to buy. |

***

#### **Sell Legacy Coin**

Allows users to sell legacy coins back into the bonding curve.

```move
public(friend) entry fun sell<BuyCoinType>(
    seller: &signer,
    amount_base_value: u64,
    amount_exponent_value: u64
) acquires Info
```

| Input Values            | Type   | Description                           |
| ----------------------- | ------ | ------------------------------------- |
| seller                  | signer | The seller's signer reference.        |
| amount\_base\_value     | u64    | Base value of the amount to sell.     |
| amount\_exponent\_value | u64    | Exponent value of the amount to sell. |

***

### View Functions

***

#### **Get Bonding Curve Goal**

Returns the bonding curve goal for the given coin.

```move
#[view]
public fun bonding_curve_goal<BuyCoinType>(): u64 acquires Info
```

| Return Values        | Type | Description             |
| -------------------- | ---- | ----------------------- |
| bonding\_curve\_goal | u64  | The bonding curve goal. |

***

#### **Get Initial Price**

Returns the initial price of the bonding curve.

```move
#[view]
public fun initial_price<BuyCoinType>(): (u64, u64) acquires Info
```

| Return Values               | Type | Description                    |
| --------------------------- | ---- | ------------------------------ |
| initial\_price\_numerator   | u64  | The initial price numerator.   |
| initial\_price\_denominator | u64  | The initial price denominator. |

***

#### **Get DEX**

Returns the DEX where the liquidity pool will be created.

```move
#[view]
public fun dex<BuyCoinType>(): TypeInfo acquires Info
```

| Return Values | Type     | Description                                       |
| ------------- | -------- | ------------------------------------------------- |
| dex           | TypeInfo | The DEX where the liquidity pool will be created. |
