> For the complete documentation index, see [llms.txt](https://docs.titan.tg/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.titan.tg/colossus-concentrated-liquidity-amm/smart-contracts/farm.md).

# 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        |
