Skip to content

algo-traders-club/comet

Repository files navigation

Comet - Autonomous Liquidity Agent for Meteora DLMM

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.

Features

  • 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

Tech Stack

  • Language: TypeScript (strict mode)
  • Package Manager: Bun
  • Web Server: Hono
  • Dependencies: @meteora-ag/dlmm, @solana/web3.js, @coral-xyz/anchor

Setup

  1. Install Bun if you haven't already:

    curl -fsSL https://bun.sh/install | bash
  2. Clone the repository and install dependencies:

    git clone <repository-url>
    cd comet
    bun install
  3. Create a .env file based on the .env.example template:

    cp .env.example .env
  4. Edit the .env file with your Solana wallet private key and other configuration options.

  5. Run the application:

    bun run src/index.ts

API Endpoints

  • 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
    

Configuration

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

Strategy Details

Comet implements a Curved Distribution Strategy with Dynamic Fee Optimization:

  1. Liquidity Distribution: Provides liquidity in a bell-shaped curve around the active bin
  2. Range Adjustment: Dynamically adjusts the range width based on recent price volatility
  3. Rebalancing Conditions:
    • The active bin moves outside 70% of the current range
    • Estimated fee earnings exceed gas costs
    • Significant change in market volatility

Testing

Run the unit tests with:

bun test

Future Enhancements

  • 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

License

MIT

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.

About

Comet - Autonomous Liquidity Agent for Meteora DLMM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published