> For the complete documentation index, see [llms.txt](https://docs.dextrabot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dextrabot.com/dextrabot/polymarket-bots/polymarket-liquidity-pool-farming-bot.md).

# Polymarket Liquidity Pool Farming Bot

## Polymarket LP Farm Bot: User Documentation

### 1. Overview

The Polymarket LP Farm Bot is an automated trading script designed to provide liquidity (LP) on Polymarket orderbooks. Instead of directional betting, the bot acts as a short-term liquidity provider. It places passive limit orders, monitors the orderbook, and dynamically adjusts or exits its positions based on the configured strategy.

***

### 2. Core Behavior & Execution Flow

When the bot is started, it follows a continuous loop:

1. **Market Identification**\
   It either connects to a specific market directly or scans for an active market matching predefined asset and timeframe traits
2. **Order Placement**\
   It quotes a price and size on one or both sides of the market (Yes/No)
3. **Monitoring & Repositioning**\
   The bot watches the orderbook. If its orders fall too far behind or market depth drops below safe levels, it cancels and replaces the orders to maintain its target position
4. **Execution & Exit (Post-Fill)**\
   When an order is filled, the bot switches from placing passive liquidity to executing an exit strategy—either quickly escaping the position, working a limit exit, or attempting to capture the spread by merging the opposite side

***

### 3. Parameter Configuration Guide

#### 3.1 Market Selection

*How the bot knows where to trade.*

* **`market_slug`**\
  The direct identifier of a market. If provided, the bot bypasses automatic selection and operates only here
* **`asset`**\
  e.g., `btc`, `eth`. Used for auto-selection to find relevant markets
* **`period`**\
  e.g., `15`, `60` (in minutes). Defines the duration/expiry window of the market

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>If <code>market_slug</code> is empty, the bot will scan Polymarket for a market matching the <code>asset</code> and <code>period</code> and automatically deploy there.</p></div>

  \---

#### 3.2 Strategy & Positioning

*How the bot decides where to place its orders.*

* **`side`**
  * `buy`: Provides liquidity on the first outcome
  * `sell`: Provides liquidity on the second outcome
  * `all`: Engages in dual-sided market making (quoting both Yes and No)
* **`target_price_mode`**
  * `rank`: The bot targets a specific position in the orderbook queue (e.g., `1` for the front of the queue, `2` for the second best price)
  * `cents`: The bot stays a fixed dollar amount away from the best price (e.g., `2` cents behind the top bid)
* **`target_price_value`**\
  The numerical input for the chosen mode

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The bot will constantly attempt to maintain this specific pricing requirement. If the market moves away, the bot will pull its old order and place a new one at the new target level.</p></div>

  \---

#### 3.3 Sizing and Safety Limits

*How the bot protects capital and manages trade size.*

* **`order_size_mode`**
  * `shares`: The bot bids for a fixed amount of contract shares
  * `usd`: The bot places dollar-denominated orders, adjusting the share amount based on the current price
* **`order_size_value`**\
  The numerical size value
* **`min_orderbook_size_mode`**\
  Defines a required liquidity threshold in the market before the bot will participate (modes: `none`, `shares`, `usd`)
* **`min_orderbook_size_value`**\
  The minimum required liquidity

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>If <code>min_orderbook_size</code> is not met, the bot considers the market temporarily unsafe/too thin, cancels any active LP orders at that level, and waits until the depth thickens up.</p></div>
* **`refresh_interval_sec`**\
  Forces the bot to restart its order process after `X` seconds, adding activity and preventing stale orders

***

#### 3.4 Post-Fill Execution (Exit Strategy)

*How the bot behaves after someone takes its liquidity.*

* **`exit_mode`**
  * `limit`: The bot attempts a controlled exit by placing a limit order at an advantageous price, working the book until closed
  * `market`: The bot rushes to close the position immediately at the best available market price
  * `merge`: For dual-sided strategies. Instead of closing, the bot completes the market by buying the opposite outcome side, thus guaranteeing the spread without directional risk
* **`exit_target_price_mode`** & **`exit_target_price_value`**\
  Function identical to the entry pricing parameters, determining the strict price target when the bot places a limit exit

***

#### 3.5 System (in development)

* **`dry_run`**\
  Set to `live` for real capital deployment, or `dry_run` for simulated actions allowing you to observe bot logs without financial risk

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.dextrabot.com/dextrabot/polymarket-bots/polymarket-liquidity-pool-farming-bot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
