Skip to main content

What You’ll Build

A compound bot that runs on a loop and:
  1. Monitors your open LP positions for accrued fees
  2. Claims fees once they cross a configurable threshold
  3. Swaps the claimed tokens into SOL in the same flow
  4. Re-deposits the SOL back into the same pool to compound your yield
No smart contract knowledge needed — the bot uses LP Agent’s Open API end-to-end.
The new claim-fee-tx endpoint can return swap-to-SOL transactions in the same response, so you don’t need a separate swap step before re-depositing. All transactions are landed via Jito for a much higher landing rate — for free.

How Compounding Works

LP fees accrue inside your position but don’t earn additional fees on their own — they sit idle until you claim and redeploy them. A compound cycle turns those idle fees into more liquidity:

The Bot’s Decision Loop

Every check interval, the bot follows this flow:

Key Decisions the Bot Makes


Prerequisites

  • An LP Agent API key (get one from the API Dashboard)
  • A Solana wallet with SOL for transaction fees
  • Node.js >= 18

Configuration

Tune these settings before running the bot:

Step-by-Step

Step 1: Setup

Set up your API client and wallet (same boilerplate as the zap-in tutorial):

Step 2: Find Positions With Accrued Fees

Query your open positions and pick the ones whose uncollected fees are worth claiming.
Fees are claimable regardless of whether the position is in range — accrued fees stay in the position until you collect them. If a position has drifted out of range, you can still claim and either re-deposit elsewhere or pair this with rebalancing.

Step 3: Generate Claim + Swap-to-SOL Transactions

The claim-fee-tx endpoint can return both the claim and the swap-to-SOL transactions in one call when you pass swapToNative: true.
What you get back:
If a fee token is already SOL, no swap tx is generated for it — it’s transferred to your wallet directly by the claim tx.

Step 4: Sign & Land

Sign every tx and submit them via the landing endpoint. The landing endpoint sends the claim bundle first, then the swap bundle.
Always use landing-claim-fee-tx instead of submitting the txs yourself via RPC. LP Agent’s Jito integration provides a much better landing rate — for free.

Step 5: Re-Deposit Into the Same Pool

After the claim lands, your wallet has more SOL. Read the new SOL balance, set aside a reserve for future fees, and zap the rest into the same pool.
This example opens a fresh position centered on the current price rather than topping up the original position. Most strategies prefer this — it keeps your range tight around the current price even as the market moves.

Reference

Choosing MIN_FEE_USD

Each compound cycle costs roughly 0.01–0.03 SOL in transaction fees (claim + swap-to-SOL + zap-in). At ~150/SOL,thats150/SOL, that's 1.50–4.50.SetMINFEEUSDsothegaincomfortablycoversthecost4.50. Set `MIN_FEE_USD` so the gain comfortably covers the cost — `5` is a safe default for most users.

Common Errors

Tips

  • Run on a slow cadence: Fees accrue over hours, not seconds. Checking every 5–15 minutes is plenty and keeps API usage low.
  • Out-of-range positions: Fees are still claimable, but if you re-deposit into the same range you’ll be adding to dead liquidity. Consider rebalancing instead, or set the new bin range around the current active bin (which is what the example bot does).
  • Consider tax implications: Each claim is a taxable event in many jurisdictions — check with your local rules.
  • DAMM V2 support: The same code works for DLMM and DAMM V2 — the only difference is the type field in the request body.

API Endpoints Used


Complete Bot Script

Here’s the full bot ready to copy-paste and run:

Next Steps