Untitled

 avatar
unknown
javascript
a year ago
2.4 kB
5
Indexable
import { jitofees } from './src/config';
import { bull_dozer } from './src/send-bundle';
import { pumpFunBuy, pumpFunSell } from './src/swap';
import { TransactionMode } from './src/types';

let tx_list: { [key: string]: any }[] = [];

class Example {
    private mintAddress: string;
    private transactionMode: TransactionMode;

    constructor(mintAddress: string, mode: TransactionMode) {
        this.mintAddress = mintAddress;
        this.transactionMode = mode;
    }

    async processKey(privateKey: string) {
        const solIn = 0.01; // Example value, adjust as needed
        const slippageDecimal = 0.25; // Example value, adjust as needed
        const tokenBalance = 1000; // Example value, adjust as needed

        try {
            // Call the buy function
            let txix = await pumpFunBuy(this.transactionMode, privateKey, this.mintAddress, solIn, slippageDecimal);

            // Check if txix is not undefined before pushing
            if (txix !== undefined) {
                tx_list.push(txix);
                console.log(`Transactions for private key ${privateKey}:`, tx_list);
            } else {
                console.error('pumpFunBuy returned undefined for private key:', privateKey);
            }

            // Optionally call the sell function and handle the result similarly
            // let txixSell = await pumpFunSell(this.transactionMode, privateKey, this.mintAddress, tokenBalance, slippageDecimal);
            // if (txixSell !== undefined) {
            //     tx_list.push(txixSell);
            // }

        } catch (error) {
            console.error('Error processing key:', privateKey, error);
        }
    }
}

// Usage
let pklist = [
    '5Fk5uUBeeeE5ywgtzi94q4iZijBxMpuwARYRbyb7F4dwn6ThqAZ5oPNyQs21NkV6Ba4kKWXKjWyGzNhGVjhMK7zF'
];
const mintAddress = '2MQJqBY6vyYHga5dMekyAnBcMJo6jKBBz9T8NCaG57ij'; // Replace with actual token mint address
const txMode = TransactionMode.Execution; // Set to simulate to test, Execution to perform

const example = new Example(mintAddress, txMode);

// Create an async function to process keys and send the bundle
(async () => {
    for (const privateKey of pklist) {
        await example.processKey(privateKey);
    }

    console.log(1);

    const sendBundleStatus = await bull_dozer(tx_list, jitofees);
    console.log('Bundle send status:', sendBundleStatus);
})();
Editor is loading...
Leave a Comment