oselezi / solana-volume-sdk

SDK to be used to generate trading volume and market making through various of AMMs on Solana
MIT License
30 stars 24 forks source link
blockchain bundle jito jito-bundle jito-solana market-making node program sdk solana solana-program swap typescript volume

Solana Volume SDK

npm version license

A powerful and easy-to-use SDK for generating trading volume and market making on the Solana blockchain.

Table of Contents

Introduction

The Solana Volume SDK allows developers to easily interact with the Solana blockchain to generate trading volume, create market maker orders, and perform swaps. It leverages the power of the Solana ecosystem and integrates with popular decentralized exchanges (DEXes) and services like Jupiter and Jito for MEV protection.

Features

Installation

Install the SDK via npm:

npm install @oselezi/solana-volume-sdk

Or using yarn:

yarn add @oselezi/solana-volume-sdk

Usage

Setup

import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { Amm } from '@oselezi/solana-volume-sdk';

// Initialize Solana connection
const connection = new Connection('https://api.mainnet-beta.solana.com');

// Load your payer wallet (ensure you handle private keys securely)
const payerSecretKey = Uint8Array.from([/* Your Secret Key Array */]);
const payerWallet = Keypair.fromSecretKey(payerSecretKey);

// Specify the token mint address
const mint = new PublicKey('YourTokenMintAddress');

// Create an instance of the Amm class
const amm = new Amm(connection, payerWallet, { disableLogs: false });

Generate Volume

// Volume generation parameters
const minSolPerSwap = 0.001; // Minimum SOL per swap
const maxSolPerSwap = 0.002; // Maximum SOL per swap
const mCapFactor = 1;        // Market cap factor
const speedFactor = 1;       // Speed factor (1 is normal speed)

// Start volume generation
amm.volume(
  mint,
  minSolPerSwap,
  maxSolPerSwap,
  mCapFactor,
  speedFactor,
  {
    includeDexes: ['Raydium', 'Orca', 'Whirlpool'], // Optional: specify DEXes
    jitoTipLamports: 100_000,                      // Optional: tip amount for Jito in lamports
  }
).catch(console.error);

Create Makers

// Number of maker orders to create
const totalMakersRequired = 5000;

// Start creating makers
amm.makers(
  mint,
  totalMakersRequired,
  {
    includeDexes: ['Raydium', 'Orca', 'Whirlpool'], // Optional: specify DEXes
    jitoTipLamports: 100_000,                      // Optional: tip amount for Jito in lamports
  }
).then((stats) => {
  console.log('Maker stats:', stats);
}).catch(console.error);

Execute a Single Swap

// Swap parameters
const direction: 'buy' | 'sell' = 'buy';
const amount = 0.5; // Amount in SOL

// Execute the swap
amm.swap(
  mint,
  direction,
  amount,
  {
    includeDexes: ['Raydium', 'Orca', 'Whirlpool'], // Optional: specify DEXes
    jitoTipLamports: 100_000,                      // Optional: tip amount for Jito in lamports
  }
).catch(console.error);

Perform Custom Swap for Makers

// Create a signer for the swap
const signer = Keypair.generate();

// Swap parameters for makers
const direction: 'buy' | 'sell' = 'buy';
const dexes = 'Raydium,Orca,Whirlpool'; // DEXes to include

// Execute the swapMakers method
amm['swapMakers'](
  direction,
  mint,
  signer,
  'recentBlockhash', // Replace with actual blockhash
  dexes
).then((transaction) => {
  // Handle the transaction, e.g., send it to the network
}).catch(console.error);

Perform Custom Swap for Volume

// Create a signer for the swap
const signer = Keypair.generate();

// Swap parameters for volume
const direction: 'buy' | 'sell' = 'sell';
const amount = 1_000_000; // Amount in lamports
const dexes = 'Raydium,Orca,Whirlpool'; // DEXes to include

// Execute the swapVolume method
amm['swapVolume'](
  direction,
  mint,
  amount,
  'recentBlockhash', // Replace with actual blockhash
  signer,
  dexes
).then((transaction) => {
  // Handle the transaction, e.g., send it to the network
}).catch(console.error);

Note: The swapMakers and swapVolume methods are private methods intended for internal use within the Amm class. The above examples demonstrate how to use them if you choose to expose them or adjust their access modifiers.

API Reference

Class: Amm

Constructor

constructor(connection: Connection, payerKeypair: Keypair, options?: AmmOptions)

Methods

Note: The swapMakers and swapVolume methods are marked as private in the class. If you wish to use them directly, you can change their access modifiers or use them as shown in the Usage section.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Submit a pull request.

Please make sure to follow the coding style guidelines and include appropriate tests.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Disclaimer

This SDK is provided as-is, without warranty of any kind. Use it at your own risk. Ensure you understand the implications of interacting with the Solana blockchain and handle private keys securely.


If you have any questions or need further assistance, feel free to open an issue on the GitHub repository or contact me directly.

Note: Replace placeholders like YourTokenMintAddress and /* Your Secret Key Array */ with actual values specific to your setup.


Acknowledgments


Contact