# Lighter Farming Module

### Overview

The Lighter Farming module enables you to set up automated trading on Lighter, a decentralized perpetual exchange on zkSync.

***

### Prerequisites

Before setting up the Lighter Farming module, ensure you have:

1. **Lighter Account:** A registered account on [Lighter](https://app.lighter.xyz/)
2. **Wallet Connection:** Your wallet connected to Lighter platform
3. **Minimum Balance:** At least 5 USDC deposited in your Lighter account
4. **API Key Generated:** Follow the steps in [Getting Your API Keys](https://app.lighter.xyz/apikeys) section

***

### Getting Your API Keys

#### Step 1: Access API Keys Section

1. Navigate to Lighter application at <https://app.lighter.xyz/>
2. Connect your wallet
3. Click on **Tools** dropdown menu in the top navigation
4. Select **API Keys** from the menu

<figure><img src="https://3477217969-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWiG6XtemfC9IwxonZpa%2Fuploads%2FWQ4wTpWDikdZkpmqV5tg%2FScreenshot%202025-10-10%20at%2013.48.58.png?alt=media&#x26;token=9e813473-5875-4b20-a9e1-6f46a49a960d" alt="" width="246"><figcaption></figcaption></figure>

#### Step 2: Generate New API Key

1. On the API Keys page, click the **"Generate API Key"** button in the top right corner

<figure><img src="https://3477217969-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWiG6XtemfC9IwxonZpa%2Fuploads%2F9PPPE1iMR1127hmhP3rd%2FScreenshot%202025-10-10%20at%2013.49.08.png?alt=media&#x26;token=1faf5902-958d-4cc0-bb89-97a7ac6c2ca6" alt=""><figcaption></figcaption></figure>

#### Step 3: Set API Key Index

1. Enter an **API Key Index** number between 2-254
   * **Important:** Indexes 0 (Desktop) and 1 (Mobile) are reserved and cannot be used
   * You can create up to 253 keys per account using indexes 2-254
   * Example: Use "111" or any number between 2-254
2. Click **"Generate"** button

<figure><img src="https://3477217969-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWiG6XtemfC9IwxonZpa%2Fuploads%2FFtvWE0HE6ewNqFjUn0li%2FScreenshot%202025-10-10%20at%2013.49.17.png?alt=media&#x26;token=089245cc-c2f0-4ee6-8dcd-feff2d5276bb" alt="" width="563"><figcaption></figcaption></figure>

#### Step 4: Save Your Keys

After generation, you'll receive three pieces of information:

1. **API Key Index:** Your chosen index number (e.g., 111)
2. **Public Key:** Your public key&#x20;
3. **Private Key:** Your private key&#x20;

<figure><img src="https://3477217969-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWiG6XtemfC9IwxonZpa%2Fuploads%2FjwvgLfwcTmj8NXUyiUQH%2FScreenshot%202025-10-10%20at%2013.49.31.png?alt=media&#x26;token=36ceaa77-b2c1-4474-96f4-634bb1b164c7" alt="" width="563"><figcaption></figcaption></figure>

**⚠️ CRITICAL:** Save your **Private Key** immediately! It will not be accessible after closing this popup. Store it securely - you'll need it for the farming module configuration.

### ⚙️ Farming Module Configuration

#### Accessing the Module

1. Open **DextraBot**
2. Go to the **Farming** tab
3. Select **Lighter** from the module list

***

### 📊 Configuration Parameters

#### Basic Settings

| Field               | Description                                           |
| ------------------- | ----------------------------------------------------- |
| **Login Address**   | The wallet you used on Lighter                        |
| **API Private Key** | Paste the private key you saved earlier               |
| **API Key Index**   | The same index number you chose when creating the key |
| **Select Pair**     | Choose which trading pair to farm                     |

#### Trading Parameters

| Field                  | Description                                                  | Range |
| ---------------------- | ------------------------------------------------------------ | ----- |
| Trade **Per Hour (n)** | How many trades happen per hour. More orders = more activity | 1-180 |
| **Leverage**           | Position multiplier. 3× means profit/loss × 3                | 1-20  |
| **Direction**          | LONG (buys only) • SHORT (sells only) • RANDOM (mix)         | -     |
| **Take Profit %**      | Auto-close position when profit reaches this %               | 0-100 |
| **Stop Loss %**        | Auto-close position if loss reaches this %                   | 0-100 |

***

### 🧠 Order Types

Lighter gives you three "brains" for how your bot will open and close orders. Think of these as different **strategies** for trading behavior.

#### 🟢 MARKET Mode

**Strategy:** Fast entry, fast exit

* 1 hour split into **n random time slots**
* Each slot: Market order → Wait → Market close
* Best for: Volatile markets, quick trades

```
Timeline Example (n=10):
|--Market In--|-------Wait-------|--Market Out--|
     5 min            wait             close
```

#### 🟡 LIMIT Mode

**Strategy:** Patient entry, smart exit

* 1 hour divided into **n equal blocks**
* First half: Try limit orders every 10 seconds
* Second half: Try limit exit, market if needed
* Best for: Stable markets, fee optimization

```
Timeline Example (1 block):
|---Try Limit Entry---|---Try Limit Exit---|
    (10s intervals)      (10s intervals)
```

#### 🔵 RANDOM Mode

**Strategy:** Natural mixed pattern

* Randomly chooses MARKET or LIMIT for each interval
* Creates organic-looking trading patterns
* Best for: Balanced approach, avoiding patterns

***

### 📐 Timing Formula Explained

#### How Time Intervals Work

```
Base Calculation:
average_interval = 3600 seconds ÷ n orders

Jitter Addition:
if n ≤ 20: variation = 25%
if n > 20: variation = 35%

Final Range:
minimum = average - variation
maximum = average + variation
```

***

### 🔄 Delta-Neutral Mode (Lighter-Lighter)

#### What is Delta-Neutral?

Uses **two Lighter accounts** with opposing positions:

* Account A → Always LONG
* Account B → Always SHORT
* Result: Zero market exposure, pure farming rewards

#### Configuration

1. Set up two separate API keys (different wallets)
2. Configure both accounts in the module
3. Select "Lighter-Lighter Delta Mode"
4. Both accounts will mirror each other's timing

> ⚠️ **IMPORTANT:** Both wallets must use **different API Key Index numbers**! For example: Wallet A uses index 2, Wallet B uses index 3. If both wallets use the same index (e.g., both use 2), the system will NOT work!

<figure><img src="https://3477217969-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWiG6XtemfC9IwxonZpa%2Fuploads%2Fq8sX2zaqB1tOftF1ph0E%2FScreenshot%202025-10-28%20at%2015.58.06.png?alt=media&#x26;token=3cb5bdfd-0a8f-428f-b671-a46b0e78a03b" alt="API Key Indexes must be unique!" width="563"><figcaption></figcaption></figure>
