# @cetusprotocol/farms-sdk

The SDK provides a Farms module for managing farming positions, liquidity, and rewards in the Cetus ecosystem. This module enables users to perform various farming operations with flexibility in how they want to manage their positions.

### Getting Started

### How to Use the Farms SDK?

#### Installation

To start using the `Farms SDK`, you first need to install it in your TypeScript project:

npm link: <https://www.npmjs.com/package/@cetusprotocol/farms-sdk>

```bash
npm install @cetusprotocol/farms-sdk
```

#### Setup

Import the SDK into the TypeScript file where you intend to use it:

```typescript
import { CetusFarmsSDK } from '@cetusprotocol/farms-sdk'
```

#### Initializing the SDK

Initialize the SDK with the required configuration parameters. This typically includes setting up the network environment.

If you would like to use the mainnet network and the official Sui rpc url,  you can do so as follows:

```typescript
const sdk = CetusFarmsSDK.createSDK()
```

If you wish to set your own full node URL or network (You have the option to select either **'mainnet'** or **'testnet'** for the network),  you can do so as follows:

```typescript
const env = 'mainnet'
const full_rpc_url = 'YOUR_FULL_NODE_URL'
const wallet = 'YOUR_WALLET_ADDRESS'

const sdk = CetusFarmsSDK.createSDK({ env })
```

If you wish to set your own full node URL or SuiClient, you can do so as follows:

```typescript
const sdk = CetusFarmsSDK.createSDK({ env, sui_client })
// or
const sdk = CetusFarmsSDK.createSDK({ env, full_rpc_url })
```

### Usage

After linking your wallet, if you need use your wallet address to do something, you should set it by `sdk.setSenderAddress`.

```typescript
const wallet = 'YOUR_WALLET_ADDRESS'

sdk.setSenderAddress(wallet)
```

if you need to change your rpc url, you can do so as follows:

```typescript
const new_rpc_url = 'YOUR_NEW_FULL_NODE_URL'

sdk.updateFullRpcUrl(new_rpc_url)
```

#### Common Parameters

* `pool_id`: The ID of the farms pool
* `position_nft_id`: The ID of the position NFT
* `clmm_position_id`: The ID of the CLMM position
* `coin_type_a` & `coin_type_b`: Coin type identifiers for the trading pair
* `amount_a` & `amount_b`: Amounts of coins to deposit/withdraw

####


---

# 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://cetus-1.gitbook.io/cetus-developer-docs/developer/via-sdk-v2/sdk-modules/cetusprotocol-farms-sdk.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.
