# Scripts

## Module info

* **Name**: <mark style="color:green;">`evo::scripts`</mark>
* **Description**: This module contains entry functions for users to call and interact with the <mark style="color:green;">`evo`</mark> contract.

## Public Functions

## Create Pool

### Create pool with two fungible assets

***

Creates a new liquidity pool for two fungible assets. Reverts if the pool already exists.

```
public entry fun create_pool(
    creator: &signer,
    token_0: Object<Metadata>,
    token_1: Object<Metadata>,
    fee: u64,
    sqrt_price: u128,****
)
```

**Function arguments**

| Argument    | Type     | Description                        |
| ----------- | -------- | ---------------------------------- |
| sender      | \&signer | The sender’s signer                |
| token\_0    | Object   | Fungible asset metadata of token 0 |
| token\_1    | Object   | Fungible asset metadata of token 1 |
| fee         | u64      | Fee tier of the pool               |
| sqrt\_price | u128     | Initial sqrt price of the pool     |

### Create pool with one coin and one fungible asset

***

Creates a new liquidity pool with one coin (<mark style="color:green;">`Token0`</mark>) and one fungible asset. Reverts if the pool already exists.

```
public entry fun create_pool_one_coin<Token0>(
    creator: &signer,
    token_1: Object<Metadata>,
    fee: u64,
    sqrt_price: u128,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| Token0   | The coin’s type |

**Function arguments**

| Argument    | Type     | Description                        |
| ----------- | -------- | ---------------------------------- |
| sender      | \&signer | The sender’s signer                |
| token\_1    | Object   | Fungible asset metadata of token 1 |
| fee         | u64      | Fee tier of the pool               |
| sqrt\_price | u128     | Initial sqrt price of the pool     |

### Create pool with two coins

***

Creates a new liquidity pool with two coins <mark style="color:green;">`Token0`</mark> and <mark style="color:green;">`Token1`</mark>. Reverts if the pool already exists.

```
public entry fun create_pool_both_coins<Coin0, Coin1>(
    creator: &signer,
    fee: u64,
    sqrt_price: u128,
)
```

**Function type arguments**

| Argument | Description                    |
| -------- | ------------------------------ |
| Token1   | The coin’s type of the token 0 |
| Token0   | The coin’s type of the token 1 |

**Function arguments**

| Argument    | Type     | Description                    |
| ----------- | -------- | ------------------------------ |
| sender      | \&signer | The sender’s signer            |
| fee         | u64      | Fee tier of the pool           |
| sqrt\_price | u128     | Initial sqrt price of the pool |

## Add liquidity

### Add liquidity to a pool with two fungible assets

***

Adds liquidity to a pool with two fungible assets.

```
public entry fun add_liquidity(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    tick_lower: u32,
    tick_upper: u32,
    amount_0: u64,
    amount_1: u64,
    amount_0_min: u64,
    amount_1_min: u64,
)
```

**Function arguments**

| Argument       | Type     | Description                                                                                                              |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| user           | \&signer | The user’s signer.                                                                                                       |
| pool           | Object   | The liquidity pool to add liquidity to.                                                                                  |
| position\_id   | u64      | The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet. |
| tick\_lower    | u32      | The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| tick\_upper    | u32      | The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| amount\_0      | u64      | The amount of token 0 to add to the liquidity.                                                                           |
| amount\_1      | u64      | The amount of token 1 to add to the liquidity.                                                                           |
| amount\_0\_min | u64      | The minimum amount of token 0 to add to the liquidity.                                                                   |
| amount\_1\_min | u64      | The minimum amount of token 1 to add to the liquidity.                                                                   |

### Add liquidity to a pool with one coin and one fungible asset

***

Adds liquidity to a pool with one coin and one fungible asset.

```
public entry fun add_liquidity_one_coin<CoinType>(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    tick_lower: u32,
    tick_upper: u32,
    amount_0: u64,
    amount_1: u64,
    amount_0_min: u64,
    amount_1_min: u64,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| CoinType | The coin’s type |

**Function arguments**

| Argument       | Type     | Description                                                                                                              |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| user           | \&signer | The user’s signer.                                                                                                       |
| pool           | Object   | The liquidity pool to add liquidity to.                                                                                  |
| position\_id   | u64      | The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet. |
| tick\_lower    | u32      | The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| tick\_upper    | u32      | The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| amount\_0      | u64      | The amount of token 0 to add to the liquidity.                                                                           |
| amount\_1      | u64      | The amount of token 1 to add to the liquidity.                                                                           |
| amount\_0\_min | u64      | The minimum amount of token 0 to add to the liquidity.                                                                   |
| amount\_1\_min | u64      | The minimum amount of token 1 to add to the liquidity.                                                                   |

### Add liquidity to a pool with two coins

***

Adds liquidity to a pool with two coins.

```
public entry fun add_liquidity_both_coins<Coin0, Coin1>(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    tick_lower: u32,
    tick_upper: u32,
    amount_0: u64,
    amount_1: u64,
    amount_0_min: u64,
    amount_1_min: u64,
)
```

**Function type arguments**

| Argument | Description                    |
| -------- | ------------------------------ |
| Coin0    | The coin’s type of the token 0 |
| Coin1    | The coin’s type of the token 1 |

**Function arguments**

| Argument       | Type     | Description                                                                                                              |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| user           | \&signer | The user’s signer.                                                                                                       |
| pool           | Object   | The liquidity pool to add liquidity to.                                                                                  |
| position\_id   | u64      | The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet. |
| tick\_lower    | u32      | The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| tick\_upper    | u32      | The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.              |
| amount\_0      | u64      | The amount of token 0 to add to the liquidity.                                                                           |
| amount\_1      | u64      | The amount of token 1 to add to the liquidity.                                                                           |
| amount\_0\_min | u64      | The minimum amount of token 0 to add to the liquidity.                                                                   |
| amount\_1\_min | u64      | The minimum amount of token 1 to add to the liquidity.                                                                   |

## Remove liquidity |

### Remove liquidity from a pool

***

Removes liquidity from a pool.

```
public entry fun remove_liquidity(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    liquidity: u128,
    amount_0_min: u64,
    amount_1_min: u64,
)
```

**Function arguments**

| Argument       | Type     | Description                                  |
| -------------- | -------- | -------------------------------------------- |
| user           | \&signer | The user’s signer.                           |
| pool           | Object   | The liquidity pool to remove liquidity from. |
| position\_id   | u64      | The position ID of the liquidity.            |
| liquidity      | u128     | The amount of liquidity to remove.           |
| amount\_0\_min | u64      | The minimum amount of token 0 to get.        |
| amount\_1\_min | u64      | The minimum amount of token 1 to get.        |

### Burn position

***

Burns a position.

```
public entry fun burn_position(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
)
```

**Function arguments**

| Argument     | Type     | Description              |
| ------------ | -------- | ------------------------ |
| user         | \&signer | The user’s signer.       |
| pool         | Object   | The liquidity pool.      |
| position\_id | u64      | The position ID to burn. |

### Collect fee

***

Collects fee from a position.

```
public entry fun collect_fee(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    amount_0_requested: u64,
    amount_1_requested: u64,
    recipient: address,
)
```

**Function arguments**

| Argument             | Type     | Description                      |
| -------------------- | -------- | -------------------------------- |
| user                 | \&signer | The user’s signer.               |
| pool                 | Object   | The liquidity pool.              |
| position\_id         | u64      | The position ID.                 |
| amount\_0\_requested | u64      | The amount of token 0 requested. |
| amount\_1\_requested | u64      | The amount of token 1 requested. |
| recipient            | address  | The recipient address.           |

### Collect reward

***

Collects reward from a position.

```
public entry fun collect_reward(
    user: &signer,
    pool: Object<LiquidityPool>,
    position_id: u64,
    reward_index: u64,
    amount_requested: u64,
    recipient: address,
)
```

**Function arguments**

| Argument          | Type     | Description                     |
| ----------------- | -------- | ------------------------------- |
| user              | \&signer | The user’s signer.              |
| pool              | Object   | The liquidity pool.             |
| position\_id      | u64      | The position ID.                |
| reward\_index     | u64      | The reward index.               |
| amount\_requested | u64      | The amount of reward requested. |
| recipient         | address  | The recipient address.          |

## Swap functions

### Swap exact fungible asset for fungible asset

***

Swaps an exact amount of fungible asset for another fungible asset.

```
public entry fun swap_exact_fa_for_fa(
    trader: &signer,
    pool: Object<LiquidityPool>,
    token_in: Object<Metadata>,
    amount_in: u64,
    amount_out_min: u64,
    sqrt_price_limit: u128,
    recipient: address,
)
```

**Function arguments**

| Argument           | Type     | Description                         |
| ------------------ | -------- | ----------------------------------- |
| trader             | \&signer | The trader’s signer.                |
| pool               | Object   | The liquidity pool.                 |
| token\_in          | Object   | The input token metadata.           |
| amount\_in         | u64      | The amount of input token.          |
| amount\_out\_min   | u64      | The minimum amount of output token. |
| sqrt\_price\_limit | u128     | The sqrt price limit.               |
| recipient          | address  | The recipient address.              |

### Swap exact coin for fungible asset

***

Swaps an exact amount of coin for a fungible asset.

```
public entry fun swap_exact_coin_for_fa<CoinType>(
    trader: &signer,
    pool: Object<LiquidityPool>,
    amount_in: u64,
    amount_out_min: u64,
    sqrt_price_limit: u128,
    recipient: address,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| CoinType | The coin’s type |

**Function arguments**

| Argument           | Type     | Description                         |
| ------------------ | -------- | ----------------------------------- |
| trader             | \&signer | The trader’s signer.                |
| pool               | Object   | The liquidity pool.                 |
| amount\_in         | u64      | The amount of input coin.           |
| amount\_out\_min   | u64      | The minimum amount of output token. |
| sqrt\_price\_limit | u128     | The sqrt price limit.               |
| recipient          | address  | The recipient address.              |

### Swap fungible asset for exact fungible asset

***

Swaps a fungible asset for an exact amount of another fungible asset.

```
public entry fun swap_fa_for_exact_fa(
    trader: &signer,
    pool: Object<LiquidityPool>,
    token_in: Object<Metadata>,
    amount_in: u64,
    amount_out_min: u64,
    sqrt_price_limit: u128,
    recipient: address,
)
```

**Function arguments**

| Argument           | Type     | Description                         |
| ------------------ | -------- | ----------------------------------- |
| trader             | \&signer | The trader’s signer.                |
| pool               | Object   | The liquidity pool.                 |
| token\_in          | Object   | The input token metadata.           |
| amount\_in         | u64      | The amount of input token.          |
| amount\_out\_min   | u64      | The minimum amount of output token. |
| sqrt\_price\_limit | u128     | The sqrt price limit.               |
| recipient          | address  | The recipient address.              |

### Swap coin for exact fungible asset

***

Swaps a coin for an exact amount of a fungible asset.

```
public entry fun swap_coin_for_exact_fa<CoinType>(
    trader: &signer,
    pool: Object<LiquidityPool>,
    amount_in: u64,
    amount_out_min: u64,
    sqrt_price_limit: u128,
    recipient: address,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| CoinType | The coin’s type |

**Function arguments**

| Argument           | Type     | Description                         |
| ------------------ | -------- | ----------------------------------- |
| trader             | \&signer | The trader’s signer.                |
| pool               | Object   | The liquidity pool.                 |
| amount\_in         | u64      | The amount of input coin.           |
| amount\_out\_min   | u64      | The minimum amount of output token. |
| sqrt\_price\_limit | u128     | The sqrt price limit.               |
| recipient          | address  | The recipient address.              |

### Swap exact fungible asset for fungible asset with multiple hops

***

Swaps an exact amount of fungible asset for another fungible asset with multiple hops.

```
public entry fun swap_exact_fa_for_fa_multi_hops(
    trader: &signer,
    pools: vector<Object<LiquidityPool>>,
    token_in: Object<Metadata>,
    amount_in: u64,
    amount_out_min: u64,
    recipient: address,
)
```

**Function arguments**

| Argument         | Type            | Description                         |
| ---------------- | --------------- | ----------------------------------- |
| trader           | \&signer        | The trader’s signer.                |
| pools            | vector\<Object> | The liquidity pools.                |
| token\_in        | Object          | The input token metadata.           |
| amount\_in       | u64             | The amount of input token.          |
| amount\_out\_min | u64             | The minimum amount of output token. |
| recipient        | address         | The recipient address.              |

### Swap exact coin for fungible asset with multiple hops

***

Swaps an exact amount of coin for a fungible asset with multiple hops.

```
public entry fun swap_exact_coin_for_fa_multi_hops<CoinType>(
    trader: &signer,
    pools: vector<Object<LiquidityPool>>,
    amount_in: u64,
    amount_out_min: u64,
    recipient: address,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| CoinType | The coin’s type |

**Function arguments**

| Argument         | Type            | Description                         |
| ---------------- | --------------- | ----------------------------------- |
| trader           | \&signer        | The trader’s signer.                |
| pools            | vector\<Object> | The liquidity pools.                |
| amount\_in       | u64             | The amount of input coin.           |
| amount\_out\_min | u64             | The minimum amount of output token. |
| recipient        | address         | The recipient address.              |

### Swap fungible asset for exact fungible asset with multiple hops

***

Swaps a fungible asset for an exact amount of another fungible asset with multiple hops.

```
public entry fun swap_fa_for_exact_fa_multi_hops(
    trader: &signer,
    pools: vector<Object<LiquidityPool>>,
    token_in: Object<Metadata>,
    amount_in_max: u64,
    amount_out_desired: u64,
    recipient: address,
)
```

**Function arguments**

| Argument             | Type            | Description                         |
| -------------------- | --------------- | ----------------------------------- |
| trader               | \&signer        | The trader’s signer.                |
| pools                | vector\<Object> | The liquidity pools.                |
| token\_in            | Object          | The input token metadata.           |
| amount\_in\_max      | u64             | The maximum amount of input token.  |
| amount\_out\_desired | u64             | The desired amount of output token. |
| recipient            | address         | The recipient address.              |

### Swap coin for exact fungible asset with multiple hops

***

Swaps a coin for an exact amount of a fungible asset with multiple hops.

```
public entry fun swap_coin_for_exact_fa_multi_hops<CoinType>(
    trader: &signer,
    pools: vector<Object<LiquidityPool>>,
    amount_in_max: u64,
    amount_out_desired: u64,
    recipient: address,
)
```

**Function type arguments**

| Argument | Description     |
| -------- | --------------- |
| CoinType | The coin’s type |

**Function arguments**

<table><thead><tr><th>Argument</th><th width="228">Type</th><th>Description</th></tr></thead><tbody><tr><td>trader</td><td>&#x26;signer</td><td>The trader’s signer.</td></tr><tr><td>pools</td><td>vector&#x3C;Object></td><td>The liquidity pools.</td></tr><tr><td>amount_in_max</td><td>u64</td><td>The maximum amount of input coin.</td></tr><tr><td>amount_out_desired</td><td>u64</td><td>The desired amount of output token.</td></tr><tr><td>recipient</td><td>address</td><td>The recipient address.</td></tr></tbody></table>


---

# 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.evo.market/technical/clmm/scripts.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.
