Comet is an autonomous liquidity agent for Meteora's Dynamic Liquidity Market Maker (DLMM) on Solana. It provides liquidity using a curved distribution strategy, dynamically rebalances based on market conditions, and exposes a simple REST API for monitoring and control.
- Curved Distribution Strategy: Provides liquidity in a bell-shaped curve around the active bin, leveraging Meteora's zero-slippage bins and dynamic fees
- Adaptive Range Sizing: Dynamically adjusts the liquidity range based on recent price volatility
- Gas-Aware Rebalancing: Only rebalances when expected fee gains outweigh gas costs
- Profit Tracking: Monitors and records earnings, fees, and ROI from liquidity positions
- REST API: Simple endpoints for monitoring, control, and accessing earnings data
- Language: TypeScript (strict mode)
- Package Manager: Bun
- Web Server: Hono
- Dependencies: @meteora-ag/dlmm, @solana/web3.js, @coral-xyz/anchor
-
Install Bun if you haven't already:
curl -fsSL https://bun.sh/install | bash
-
Clone the repository and install dependencies:
git clone <repository-url> cd comet bun install
-
Create a
.env
file based on the.env.example
template:cp .env.example .env
-
Edit the
.env
file with your Solana wallet private key and other configuration options. -
Run the application:
bun run src/index.ts
-
GET /status: Returns pool status (active bin, position details, fees earned, earnings data)
curl http://localhost:3000/status
-
GET /earnings: Returns detailed profit tracking information including current earnings and history
curl http://localhost:3000/earnings
-
POST /rebalance: Manually triggers a rebalance
curl -X POST http://localhost:3000/rebalance
-
GET /metrics: Exposes basic metrics (uptime, last rebalance time, total fees)
curl http://localhost:3000/metrics
-
GET /health: Health check endpoint
curl http://localhost:3000/health
The following environment variables can be configured in the .env
file:
Variable | Description | Default |
---|---|---|
RPC_ENDPOINT | Solana RPC endpoint | https://api.mainnet-beta.solana.com |
WALLET_PRIVATE_KEY | Base64 encoded wallet private key | (required) |
POOL_ADDRESS | DLMM pool address | ARwi1S4DaiTG5DX7S4M4ZsrXqpMD1MrTmbu9ue2tpmEq |
REBALANCE_INTERVAL_MS | Rebalance interval in milliseconds | 3600000 (1 hour) |
INITIAL_RANGE_BINS | Initial range width in bins | 10 |
GAS_THRESHOLD_LAMPORTS | Gas threshold for rebalancing | 50000 |
PORT | Server port | 3000 |
DEBUG | Debug mode | false |
Comet implements a Curved Distribution Strategy with Dynamic Fee Optimization:
- Liquidity Distribution: Provides liquidity in a bell-shaped curve around the active bin
- Range Adjustment: Dynamically adjusts the range width based on recent price volatility
- Rebalancing Conditions:
- The active bin moves outside 70% of the current range
- Estimated fee earnings exceed gas costs
- Significant change in market volatility
Run the unit tests with:
bun test
- Cross-pool migration for better capital efficiency
- Impermanent loss (IL) hedging strategies
- Single-sided liquidity provision
- Advanced fee optimization based on historical data
- Integration with external price oracles
This project was created using bun init
in bun v1.1.38. Bun is a fast all-in-one JavaScript runtime.
Copyright (c) 2025 Comet - Autonomous Liquidity Agent. All rights reserved.