gianlucamazza
solana-mmaker
TypeScript

This project is a Solana Market Maker Bot designed to automate trading strategies on the Solana blockchain using the Jupiter swap protocol.

Last updated Jul 6, 2026
94
Stars
34
Forks
0
Issues
0
Stars/day
Attention Score
83
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Solana Market Maker Bot

This project is a Solana Market Maker Bot designed to automate trading strategies on the Solana blockchain using the Jupiter swap protocol. It implements a portfolio rebalancing strategy between SOL and SPL tokens (50/50 by default), automatically executing trades to restore the target balance when price fluctuations create imbalances.

โš ๏ธ No official token. This project has no associated cryptocurrency, coin, or token, and is not affiliated with any pump.fun / memecoin launch. Any coin claiming to represent, fund, or be "official" for this project is a scam โ€” do not buy it and do not connect your wallet to it. The maintainer will never ask you to sign a transaction or connect a wallet in relation to this repository.

Features

  • Automatic Portfolio Rebalancing: Maintains a configurable value balance between token pairs (default 50/50)
  • Jupiter Integration: Uses Jupiter Aggregator for optimal swap execution
  • Price Tolerance: Rebalances only when the imbalance exceeds a configurable share of the portfolio (default 2%)
  • Slippage Protection: Default 0.5% (50 bps) maximum slippage
  • Priority Fees: Includes 200,000 lamport priority fees for faster transaction confirmation
  • BIP39 Wallet Support: Load keypairs from a file or derive them from a mnemonic
  • Robust Transaction Handling: Re-broadcasts transactions until confirmed, with expiry tracking and timeouts
  • Fault Tolerance: A failed RPC/API call skips the cycle instead of crashing the bot; Jupiter requests retry with exponential backoff on rate-limits/5xx
  • Graceful Shutdown: SIGINT/SIGTERM stop the bot after the current cycle
  • Simulation Mode: Test strategies without executing actual trades (ENABLE_TRADING=false)

Project Structure

.
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ eslint.config.mjs
โ”œโ”€โ”€ .env.example                # Template for environment configuration
โ”œโ”€โ”€ .github
โ”‚   โ””โ”€โ”€ workflows/ci.yml        # CI: build, lint, test, audit (Node 20 & 22)
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ api
โ”‚   โ”‚   โ”œโ”€โ”€ jupiter.ts          # Jupiter API client with quote and swap functionality
โ”‚   โ”‚   โ””โ”€โ”€ solana.ts           # Solana RPC client (@solana/kit) and mint helpers
โ”‚   โ”œโ”€โ”€ constants
โ”‚   โ”‚   โ””โ”€โ”€ constants.ts        # Token mint addresses
โ”‚   โ”œโ”€โ”€ main.ts                 # Entry point and setup
โ”‚   โ”œโ”€โ”€ strategies
โ”‚   โ”‚   โ””โ”€โ”€ basicMM.ts          # Rebalancing market-making strategy implementation
โ”‚   โ”œโ”€โ”€ utils
โ”‚   โ”‚   โ”œโ”€โ”€ convert.ts          # Token unit conversion utilities (Decimal-based)
โ”‚   โ”‚   โ”œโ”€โ”€ transactionSender.ts # Robust transaction submission with retry logic
โ”‚   โ”‚   โ””โ”€โ”€ sleep.ts            # Asynchronous sleep utility
โ”‚   โ””โ”€โ”€ wallet.ts               # Signer loading (@solana/kit) from file or mnemonic
โ””โ”€โ”€ tests                       # Vitest unit tests
    โ”œโ”€โ”€ basicMM.test.ts
    โ””โ”€โ”€ convert.test.ts

Requirements

  • Node.js (version 20.x or later; the @solana/kit signer relies on WebCrypto Ed25519)
  • A funded Solana wallet with SOL and SPL tokens

Setup

  • Install Node.js: Ensure that you have Node.js installed on your machine. You can download it from here
  • Clone the Repository: Clone the repository to your local machine:
git clone https://github.com/gianlucamazza/solana-mmaker.git
   cd solana-mmaker
  • Install Dependencies:
npm install
  • Environment Variables: Copy .env.example to .env and fill in your values:
cp .env.example .env

Environment Variables

| Variable | Required | Description | | ---------------------------- | -------- | ------------------------------------------------------------------------------ | | SOLANARPCENDPOINT | yes | Solana RPC endpoint URL | | USER_KEYPAIR | no\* | Path to a JSON secret-key file (solana-keygen format) | | SOLANA_MNEMONIC | no\* | BIP39 mnemonic to derive the keypair from | | ENABLE_TRADING | no | true to execute real swaps; anything else runs in simulation mode | | JUPITERAPIBASE_URL | no | Override the Jupiter API base URL (default: https://lite-api.jup.ag/swap/v1) | | MMWAITTIME_MS | no | Milliseconds between rebalance checks (default: 60000) | | MMSLIPPAGEBPS | no | Maximum slippage in basis points (default: 50) | | MMPRICETOLERANCE | no | Portfolio imbalance fraction required to trigger a rebalance (default: 0.02) | | MMREBALANCEPERCENTAGE | no | Target share of total value held in the first token (default: 0.5) | | MMMINIMUMTRADEVALUEUSD | no | Minimum trade value in USD for a rebalance to be executed (default: 1) | | MMPRIORITYFEE_LAMPORTS | no | Priority fee in lamports attached to swaps (default: 200000) | | MMSKIPPREFLIGHT | no | true to skip RPC preflight simulation when sending swaps (default: false) |

\* Keypair resolution order: USERKEYPAIR file โ†’ SOLANAMNEMONIC โ†’ ~/.config/solana/id.json. Set at most one of the two variables.

Running the Bot

To start the market maker bot in development mode:

npm run dev

For production after building:

npm run build
npm start

Testing and Linting

npm test       # Vitest unit tests
npm run lint   # ESLint over src and tests

Configuration Options

The strategy parameters can be set through the MM_* environment variables above, or programmatically via the MarketMaker constructor:

const marketMaker = new MarketMaker({
  waitTime: 60000, // ms between rebalance checks
  slippageBps: 50, // max slippage in basis points
  priceTolerance: 0.02, // imbalance fraction that triggers a rebalance
  rebalancePercentage: 0.5, // target share of value in the first token
  minimumTradeValueUsd: 1, // minimum trade value in USD worth executing
});

Customizing Trading Pairs

To change the traded pair:

  • Add your token mint addresses to src/constants/constants.ts
  • Update the token configuration in the MarketMaker constructor (src/strategies/basicMM.ts); SPL token decimals are verified on-chain at startup
  • Ensure you have balances of both tokens in your wallet

Safety and Security

  • Always review the strategy and start with small amounts for testing
  • Use a dedicated wallet with only the tokens you intend to trade
  • The bot uses priority fees to ensure transactions confirm quickly
  • All sensitive information is stored in environment variables; keys and mnemonics are never logged
  • Transaction timeout protection prevents hanging on failed transactions

Contribution

Contributions are welcome! Please feel free to fork the repository, make changes, and submit pull requests.

Disclaimer

This project is for educational and experimental purposes only. Use it at your own risk. The authors are not responsible for any financial losses or damages.

There is no official token associated with this project (see the notice at the top).

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท gianlucamazza/solana-mmaker ยท Updated daily from GitHub