# Farm

The farm contract is used to deploy liquidity mining programs, accept funding of liquidity mining rewards, and pay users their rewards.

***

## Interface

### `get_farm_data`

Returns farm data.

**Arguments**

*None*

**Returns**

| Data Type | Description           |
| --------- | --------------------- |
| `int`     | Farm index            |
| `int`     | Start time            |
| `int`     | End time              |
| `slice`   | Router address        |
| `slice`   | Pool manager address  |
| `slice`   | Jetton mint address   |
| `slice`   | Jetton wallet address |
| `int`     | Rewards               |
| `int`     | Is initialized        |
| `slice`   | Admin address         |
| `int`     | Number of stakes      |
| `int`     | Seconds claimed X128  |

***

## Messages

### Stake Liquidity

```plaintext
Opcode: 0xb1e1dd6e
```

| Data Type | Description    |
| --------- | -------------- |
| `Uint32`  | Opcode         |
| `Uint64`  | Query ID       |
| `Int32`   | Pool index     |
| `Int32`   | Low tick       |
| `Int32`   | High tick      |
| `Uint128` | Liquidity      |
| `Uint256` | Tx count       |
| `Uint64`  | Position index |

***

### Unstake Liquidity

```plaintext
Opcode: 0x23b6f845
```

| Data Type | Description         |
| --------- | ------------------- |
| `Uint32`  | Opcode              |
| `Uint64`  | Query ID            |
| `Uint256` | Seconds inside X128 |
| `Uint256` | Seconds             |
| `Address` | User address        |
| `Uint1`   | Should restake      |

***

### Stake LP

```plaintext
Opcode: 0x898c03ae
```

| Data Type   | Description    |
| ----------- | -------------- |
| `Uint32`    | Opcode         |
| `Uint64`    | Query ID       |
| `Int32`     | Pool index     |
| `Int32`     | Lower tick     |
| `Int32`     | High tick      |
| `Uint128`   | Liquidity      |
| `Uint256`   | Tx count       |
| `^Cell`     | User data      |
| → `Address` | User address   |
| → `Uint64`  | Position index |

***

### Stake Notification (Farm)

```plaintext
Opcode: 0x4a88935e
```

| Data Type | Description  |
| --------- | ------------ |
| `Uint32`  | Opcode       |
| `Uint64`  | Query ID     |
| `Address` | User address |

***

### Refund Rewards

```plaintext
Opcode: 0xb7959473
```

| Data Type | Description                 |
| --------- | --------------------------- |
| `Uint32`  | Opcode                      |
| `Uint64`  | Query ID                    |
| `Coins`   | Amount of rewards to refund |

***

### Transfer Notification (Funding Rewards)

```plaintext
Opcode: 0x7362d09c
```

| Data Type | Description   |
| --------- | ------------- |
| `Uint32`  | Opcode        |
| `Uint64`  | Query ID      |
| `Coins`   | Reward amount |
| `Address` | Sender        |


---

# 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.titan.tg/colossus-concentrated-liquidity-amm/smart-contracts/farm.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.
