Skip to content
/ Cobra Public

Cobra - personal off-chain DeX router for Solana; Buy, sell, search pools, and more on all Raydium, Pump.fun, and Meteora AMMs.

Notifications You must be signed in to change notification settings

FLOCK4H/Cobra

Repository files navigation

Important

This software is open-source & free of any charge, there are no fees, nor ads included in the repo.
Consider feeding the Cobra if the project comes useful.
Wallet: FL4CKfetEWBMXFs15ZAz4peyGbCuzVaoszRKcoVt3WfC

Cobra

Supported Solana Markets:

  1. Raydium CLMM
  2. Meteora DLMM
  3. PumpFun
  4. PumpSwapAMM
  5. MeteoraDAMM v1
  6. MeteoraDAMM v2
  7. Meteora Dynamic Bonding Curve
  8. Raydium CPMM
  9. Raydium AMM V4
  10. Raydium Launchlab

Cobra composes of 3 parts:

  • CobraRouter
  • CobraNET (Optional)
  • CobraWallets (Optional)

and a CLI, a Command Line Interface wrapper around CobraRouter and CobraWallets:

image

Check out How to run CLI

After setting up Cobra properly, the features are:

  • Generating Wallets, Grinding Custom Wallets
  • Buying, selling on supported markets (& in Pump.fun AMM - creating new pools)
  • Detecting mint's market and pool address
  • Fetching pool's states/ keys (for developers)
  • Interfacing with supported markets using available methods (for developers)

Setup

1. Download the repository and install the required modules

$ git clone https://github.com/FLOCK4H/Cobra
$ pip install -r req.txt
🖱️ I am a developer

2. Install CobraRouter module:

$ cd CobraRouter
$ pip install .

3. Usage:

from CobraRouter.detect import CobraDetector
from CobraRouter.router import Router
import asyncio
from solana.rpc.async_api import AsyncClient
import aiohttp

async def main():
    client = AsyncClient("https://api.apewise.org/rpc?api-key=")
    session = aiohttp.ClientSession()
    router = Router(client, session)
    detector = CobraDetector(router, "https://api.apewise.org/rpc?api-key=")
    detect = await detector._detect("9R1pCPM7GRr9F4gk978LqBQiPKfYStbZKc5iKV4imoon")
    print(detect)
    await client.close()
    await session.close()
    await router.close()

if __name__ == "__main__":
    asyncio.run(main())

Example output:

PS C:\Users\swear\Desktop> python .\test.py
BMBcZ9GWMCi9HaCE7BagrLxakzffy6fAGdEpihLRfVPw
[CobraRouter] Route winner (?): 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 -> BMBcZ9GWMCi9HaCE7BagrLxakzffy6fAGdEpihLRfVPw
('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8', 'BMBcZ9GWMCi9HaCE7BagrLxakzffy6fAGdEpihLRfVPw')

Learn how to interact with the library: Cobra Documentation

🖱️ I am a trader

2. Configure the secrets.env file:

Required variables are: RUN_AS_CLI, HTTP_RPC, and PRIVATE_KEY.
Helius can be free tier.
Current fastest HTTP RPC Provider: Apewise

Create or edit secrets.env file; Here you can control SLIPPAGE, which is 1..100 range, and PRIORITY_FEE_LEVEL which is a String and options are: low, medium, high, turbo.

RUN_AS_CLI=True
HTTP_RPC="https://api.apewise.org/rpc?api-key=" # apewise.org -> fastest right now

# CLI CONFIG SECTION
PRIVATE_KEY=2wY3abcde5Pj4xxxxxxxxxxxxxxxxxxxxxxxxxxxx
SLIPPAGE=30
PRIORITY_FEE_LEVEL="high" # "low", "medium", "high", "turbo"

3. Run the CLI

$ python main.py

image

CobraNET

CobraNET is an optional Telegram wrapper around the CobraRouter and CobraWallets, and allows you to host your own Dex Router via Telegram Bot.

Setup

Create secrets.env where you run the application, make sure to set:

secrets.env

RUN_AS_CLI=False
BOT_TOKEN=TELEGRAM_BOT_TOKEN_FROM_BOTFATHER
HTTP_RPC="https://api.apewise.org/rpc?api-key=" # apewise.org -> fastest right now
HELIUS_API_KEY="your-helius-free-or-not-api-key" 

For database operations you will need PostgreSQL installed: PostgreSQL

Initialize the database:

$ cd Cobra
$ python database.py

Run the Cobra with Telegram support:

$ python main.py

Test your bot by entering /start inside the conversation.

image

Learn more about CobraNET here: Cobra Documentation

Contact & Support

Discord: FLOCK4H.CAVE, Telegram: FLOCK4H.CAVE

Telegram private handle: @dubskii420

LICENSE

Copyright 2025 FLOCK4H

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.