DeltaLogicLabs
Mantis
TypeScript

An autonomous liquidity agent that watches Meteora DLMM pools, reasons over live on-chain data, and rebalances positions before they bleed.

Last updated Jun 29, 2026
26
Stars
0
Forks
7
Issues
0
Stars/day
Attention Score
58
Language breakdown
TypeScript 98.4%
Dockerfile 1.6%
โ–ธ Files click to expand
README

Mantis

License Runtime Chain

An autonomous liquidity agent that watches Meteora DLMM pools, reasons over live on-chain data, and rebalances positions before they bleed.

Live Liquidity Board

Mantis live liquidity board

Live operating view for Mantis: watched DLMM pools, fee/IL ratio, bin drift, volume authenticity, risk gates, and the agent's current HOLD, REBALANCE, EXIT, or ENTER decision.

Decision Flow

Mantis decision flow

How Mantis decides: recall pool memory, observe on-chain state, reason over fee and impermanent-loss pressure, simulate the rebalance, record the outcome, and pass the final action through risk gates.


The problem

Concentrated liquidity earns fees only when the active price bin sits inside your range. When the market drifts โ€” and it always does โ€” your position silently collects impermanent loss instead. Most LPs either don't notice or react too late.

mantis fixes this with a Claude-powered agent that runs every 10 minutes, checks every pool in your watchlist, and either holds, shifts the range, or pulls liquidity entirely.


How it thinks

Every cycle, the agent goes through the same sequence:

1. recall     โ†’ query memory for past patterns on this pool
  • observe โ†’ fetch pool state, bin array, volume authenticity
  • reason โ†’ compute fee/IL ratio, bin drift, TVL velocity
  • simulate โ†’ if REBALANCE, estimate IL cost before committing
  • record โ†’ write new observations back to memory
  • decide โ†’ HOLD | REBALANCE | EXIT | ENTER
The decision is intercepted by a risk gate before anything happens on-chain. Confidence below threshold, drawdown above limit, or a position cap breach โ€” any of these blocks execution and logs a warning to memory so future cycles are aware.

Memory

The agent remembers. Every outcome โ€” fee earned, IL incurred, bad pool flagged โ€” gets stored in a Chroma vector database and retrieved by cosine similarity on the next relevant cycle. Entries expire automatically (90 days for patterns, 60 for warnings). Near-duplicate memories merge instead of pile up.

This is what makes it self-improving: it gets slower to enter pools it's been burned by before, and faster to recognize patterns it's profited from.


Volume authenticity

Before any decision, the agent scores each pool's volume on a 0โ€“1 scale. Volume/TVL ratio above 10x, fee rate outside the 0.02%โ€“2% band, or low TVL with outsized volume all push the score down. Pools below 0.70 are skipped entirely. This alone filters most of the wash-traded noise on DLMM.


Quickstart

git clone https://github.com/DeltaLogicLabs/mantis
cd mantis
bun install
bun run setup            # interactive .env wizard
docker-compose up -d     # starts Chroma
bun run dev              # paper trading by default

To run the historical simulation:

bun run backtest

Configuration

Key .env variables:

| Variable | Default | Description | |----------|---------|-------------| | WATCHLIST_POOLS | โ€” | Comma-separated pool addresses | | PAPER_TRADING | true | Disable to execute on-chain | | MINPOOLTVL_USD | 50000 | Skip pools below this TVL | | MINFEEIL_RATIO | 1.2 | Minimum fee/IL ratio to hold | | VOLUMEAUTHTHRESHOLD | 0.70 | Skip pools below this authenticity score | | SCANINTERVALMS | 600000 | Scan frequency (default 10 min) | | CONFIDENCE_THRESHOLD | 0.65 | Minimum agent confidence to act |


Risk gates

Decisions pass through six checks in order before any on-chain action:

  • Confidence below CONFIDENCE_THRESHOLD โ†’ reject
  • Max concurrent positions reached โ†’ reject ENTER
  • Portfolio drawdown > 10% โ†’ pause new entries
  • Position size > 30% of portfolio โ†’ cap and allow
  • Invalid bin range (inverted or > 100 bins wide) โ†’ reject REBALANCE
  • EXIT โ†’ always approved, no conditions

Technical Spec

IL Estimation โ€” DLMM Bin Step Math

The fee/IL ratio uses the actual bin step to convert drift distance into a price ratio, then applies the standard CPMM IL formula:

priceRatio r = (1 + binStep/10_000)^binsDrifted
IL fraction  = 2โˆšr / (1 + r) โˆ’ 1

Prior approach multiplied drift ratio by a flat 0.2% coefficient, which underestimated IL on high-step pools (binStep 25+) and overestimated on tight-step pairs (binStep 1). The binStep value is read directly from lbPair.binStep via the @meteora-ag/dlmm SDK and passed through to the strategy.

Bin Utilization Filter

MINBINUTILIZATION (default 0.30) blocks pools where fewer than 30% of fetched bins have non-zero reserves. One-sided pools where liquidity has clustered into a narrow band violate the distribution assumption used in the IL model. The check runs in passesPreFilter before any API call or agent invocation.

Memory Merge Threshold

ChromaDB returns cosine distance (0 = identical, 2 = maximally dissimilar). The merge guard checks distance < 1 โˆ’ SIMILARITYMERGETHRESHOLD. The threshold is set to 0.92, meaning distance < 0.08 โ€” near-duplicate observations only. Prior value of 0.70 was being used as if it were distance (wrong direction), merging entries with similarity as low as 30%.

Recency-Weighted Memory Retrieval

getRelevantContext blends cosine similarity with a recency score:

const recencyScore = Math.exp(-age / RECENCYHALFLIFEMS); // 30-day half-life
blended = simScore  0.7 + recencyScore  0.3

A 90-day-old warning scores 0.05 on the recency term vs 0.33 for a 30-day-old entry at identical cosine similarity โ€” recent signals take precedence without discarding older ones entirely.

Risk Gate Checks (in order)

  • Confidence below CONFIDENCE_THRESHOLD โ†’ reject
  • Max concurrent positions reached โ†’ reject ENTER
  • Duplicate pool guard โ†’ reject ENTER if same pool already held (use REBALANCE instead)
  • Portfolio drawdown > 10% โ†’ pause new entries
  • Position size > 30% of portfolio โ†’ cap and allow
  • Rebalance range > MAXREBALANCERANGE_BINS โ†’ reject REBALANCE
  • EXIT โ†’ always approved

Stack

  • Runtime: Bun 1.2
  • Agent: Claude Agent SDK (stopreason === "tooluse" loop)
  • Memory: ChromaDB, cosine distance merge threshold 0.08, 30-day recency decay
  • On-chain: @meteora-ag/dlmm SDK, Helius RPC, Meteora REST API
  • Config: Zod schema validation, hard exit on invalid env

License

โ–Ž MIT. Use it however you want.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท DeltaLogicLabs/Mantis ยท Updated daily from GitHub