├── .gitignore ├── src ├── constants │ ├── index.ts │ └── constants.ts ├── jito │ ├── index.ts │ ├── utils.ts │ ├── types.ts │ ├── bundle.ts │ ├── shared.ts │ ├── google │ │ └── protobuf │ │ │ └── timestamp.ts │ ├── searcher-client.ts │ ├── packet.ts │ ├── block-eng-bundle.ts │ └── searcher.ts ├── utils │ ├── index.ts │ ├── logger.ts │ ├── unwrap_sol.ts │ ├── wrap_sol.ts │ └── utils.ts ├── IDL │ └── index.ts ├── sell.ts ├── buy.ts ├── volume-bot.ts ├── nozomi │ └── tx-submission.ts ├── pool.ts └── pumpswap.ts ├── .env.copy ├── tsconfig.base.json ├── tsconfig.json ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | *.db 4 | *.log -------------------------------------------------------------------------------- /src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./constants" -------------------------------------------------------------------------------- /src/jito/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./bundle"; 2 | export * from "./utils" -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './utils'; 2 | export * from './logger'; 3 | export * from "./unwrap_sol"; 4 | export * from "./wrap_sol"; -------------------------------------------------------------------------------- /src/IDL/index.ts: -------------------------------------------------------------------------------- 1 | // pump-fun.json should be a valid JSON file 2 | export const IDL = require("./pumpswap-idl.json"); 3 | export * from "./pumpswap-idl"; -------------------------------------------------------------------------------- /.env.copy: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY= 2 | RPC_ENDPOINT=https://mainnet.helius-rpc.com?api-key= 3 | RPC_WEBSOCKET_ENDPOINT=wss://mainnet.helius-rpc.com/?api-key= 4 | COMMITMENT_LEVEL=processed 5 | LOG_LEVEL=info 6 | BLOCK_ENGINE_URL=amsterdam.mainnet.block-engine.jito.wtf 7 | JITO_TIPS=0.001 8 | 9 | -------------------------------------------------------------------------------- /src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | import pino from "pino"; 2 | 3 | const transport = pino.transport({ 4 | target: 'pino-pretty', 5 | }); 6 | 7 | export const logger = pino( 8 | { 9 | level: 'info', 10 | redact: ['poolKeys'], 11 | serializers: { 12 | error: pino.stdSerializers.err, 13 | }, 14 | base: undefined, 15 | }, 16 | transport, 17 | ); 18 | -------------------------------------------------------------------------------- /src/sell.ts: -------------------------------------------------------------------------------- 1 | import { PublicKey, TransactionInstruction, SystemProgram, LAMPORTS_PER_SOL, TransactionMessage, 2 | ComputeBudgetProgram, 3 | VersionedTransaction, } from '@solana/web3.js'; 4 | import { connection, wallet_1 } from './constants'; 5 | import { PumpSwapSDK } from './pumpswap'; 6 | 7 | 8 | 9 | async function sell_example(){ 10 | 11 | 12 | const pumpswap_sdk = new PumpSwapSDK(); 13 | pumpswap_sdk.sell_percentage(new PublicKey(""), wallet_1.publicKey, 1); // 1 = 100%, sell all 14 | 15 | } 16 | sell_example(); 17 | -------------------------------------------------------------------------------- /src/buy.ts: -------------------------------------------------------------------------------- 1 | import { PublicKey, TransactionInstruction, SystemProgram, LAMPORTS_PER_SOL, TransactionMessage, 2 | ComputeBudgetProgram, 3 | VersionedTransaction, } from '@solana/web3.js'; 4 | import { connection, wallet_1 } from './constants'; 5 | import { AnchorProvider } from "@coral-xyz/anchor"; 6 | import { PumpSwapSDK } from './pumpswap'; 7 | 8 | async function buy_example(){ 9 | 10 | const pumpswap_sdk = new PumpSwapSDK(); 11 | pumpswap_sdk.buy(new PublicKey(""), wallet_1.publicKey, 0.22); // 0.22 sol 12 | 13 | } 14 | buy_example(); -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./src/*.ts", "./src/**/*.ts"], 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": true, 6 | "declarationMap": true, 7 | "allowSyntheticDefaultImports": true, 8 | "experimentalDecorators": true, 9 | "emitDecoratorMetadata": true, 10 | "noImplicitAny": false, 11 | "strictNullChecks": true, 12 | "esModuleInterop": true, 13 | "resolveJsonModule": true, 14 | "skipLibCheck": true 15 | }, 16 | "ts-node": { 17 | "compilerOptions": { 18 | "module": "commonjs" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/jito/utils.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Bundle } from 'jito-ts/dist/sdk/block-engine/types'; 3 | import { SearcherClient, searcherClient } from 'jito-ts/dist/sdk/block-engine/searcher'; 4 | import { logger } from '../utils/logger'; 5 | import { VersionedTransaction } from '@solana/web3.js'; 6 | import { Meta, Packet } from './packet'; 7 | import {writeLineToLogFile} from "../utils" 8 | 9 | export async function onBundleResult(c: SearcherClient){ 10 | c.onBundleResult( 11 | (result) => { 12 | logger.info(`received bundle result: ${result}`); 13 | console.log(result); 14 | //writeLineToLogFile(`received bundle result: ${result}`); 15 | }, 16 | (e) => { 17 | logger.error(`received error ${e} when listening the bundle result`); 18 | //writeLineToLogFile(`received error ${e} when listening the bundle result`); 19 | } 20 | ) 21 | } 22 | export const serializeTransactions = ( 23 | txs: VersionedTransaction[] 24 | ): Packet[] => { 25 | return txs.map(tx => { 26 | const data = tx.serialize(); 27 | 28 | return { 29 | data, 30 | meta: { 31 | port: 0, 32 | addr: '0.0.0.0', 33 | senderStake: 0, 34 | size: data.length, 35 | flags: undefined, 36 | } as Meta, 37 | } as Packet; 38 | }); 39 | }; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | // "include": ["4-layered/src/**/*", "constants", "utils", "trading-modules/trading", "streaming", "token-filters", "raydium", "jito", "4-layered/main-algo"], 4 | //"exclude": ["node_modules"], 5 | "compilerOptions": { 6 | 7 | "module": "es2022", 8 | "target": "es2022", 9 | "allowJs": true, /* Specify what module code is generated. */ 10 | "moduleResolution": "node", /* Specify what module code is generated. */ /* Allow 'import x from y' when a module doesn't have a default export. */ 11 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 12 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 13 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 14 | 15 | /* Type Checking */ 16 | //"strict": true, 17 | "strictNullChecks": false, // Add this /* Enable all strict type-checking options. */ /* Skip type checking .d.ts files that are included with TypeScript. */ 18 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test.ts", 3 | "version": "1.0.0", 4 | "main": "test.ts", 5 | "scripts": { 6 | "test": "" 7 | }, 8 | "dependencies": { 9 | "@coral-xyz/anchor": "^0.30.1", 10 | "@coral-xyz/borsh": "^0.30.1", 11 | "@debridge-finance/solana-transaction-parser": "^3.2.1", 12 | "@metaplex-foundation/js": "^0.20.1", 13 | "@project-serum/anchor": "^0.26.0", 14 | "@project-serum/serum": "^0.13.65", 15 | "@raydium-io/raydium-sdk": "^1.3.1-beta.47", 16 | "@raydium-io/raydium-sdk-v2": "^0.1.55-alpha", 17 | "@shyft-to/solana-transaction-parser": "^1.1.17", 18 | "@solana/buffer-layout": "^4.0.1", 19 | "@solana/buffer-layout-utils": "^0.2.0", 20 | "@solana/spl-token": "^0.4.0", 21 | "@solana/web3.js": "^1.98.0", 22 | "@triton-one/yellowstone-grpc": "^0.4.0", 23 | "@types/express": "^5.0.0", 24 | "async-lock": "^1.4.1", 25 | "async-mutex": "^0.5.0", 26 | "bigint-buffer": "^1.1.5", 27 | "bn.js": "^5.2.1", 28 | "bs58": "^5.0.0", 29 | "child_process": "^1.0.2", 30 | "commander": "^12.1.0", 31 | "csv-parser": "^3.2.0", 32 | "dotenv": "^16.4.1", 33 | "express": "^4.21.1", 34 | "fast-csv": "^5.0.2", 35 | "jito-ts": "^4.0.0", 36 | "node-fetch": "^3.3.2", 37 | "node-telegram-bot-api": "^0.64.0", 38 | "pino": "^8.18.0", 39 | "pino-pretty": "^10.3.1", 40 | "pino-std-serializers": "^6.2.2", 41 | "postgres": "^3.4.5", 42 | "request": "^2.88.2", 43 | "tedious": "^18.6.1" 44 | }, 45 | "devDependencies": { 46 | "@types/bn.js": "^5.1.5", 47 | "@types/global-tunnel-ng": "^2.1.4", 48 | "@types/node": "^22.10.2", 49 | "prettier": "^3.2.4", 50 | "ts-node": "^10.9.2", 51 | "typescript": "^5.7.3" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/utils/unwrap_sol.ts: -------------------------------------------------------------------------------- 1 | 2 | import { NATIVE_MINT, getOrCreateAssociatedTokenAccount, createCloseAccountInstruction } from "@solana/spl-token"; 3 | import { connection, wallet_1 } from "../constants"; 4 | import { Transaction, LAMPORTS_PER_SOL, sendAndConfirmTransaction, ComputeBudgetProgram } from "@solana/web3.js"; 5 | import { Keypair } from "@solana/web3.js"; 6 | 7 | export async function unwrapSol(wallet:Keypair){ 8 | // wSol ATA 9 | const wSolAta = await getOrCreateAssociatedTokenAccount(connection, wallet, NATIVE_MINT, wallet.publicKey); 10 | 11 | // close wSol account instruction 12 | const transaction = new Transaction; 13 | transaction.add( 14 | createCloseAccountInstruction( 15 | wSolAta.address, 16 | wallet.publicKey, 17 | wallet.publicKey 18 | ) 19 | ); 20 | transaction.add( 21 | ComputeBudgetProgram.setComputeUnitPrice({ 22 | microLamports: 0.005 * LAMPORTS_PER_SOL, 23 | }) 24 | ) 25 | 26 | // submit transaction 27 | const txSignature = await sendAndConfirmTransaction(connection, transaction, [wallet]); 28 | 29 | // validate transaction was successful 30 | try { 31 | const latestBlockhash = await connection.getLatestBlockhash(); 32 | await connection.confirmTransaction({ 33 | blockhash: latestBlockhash.blockhash, 34 | lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, 35 | signature: txSignature, 36 | }, 'confirmed'); 37 | } catch (error) { 38 | console.log(`Error unwrapping sol: ${error}`); 39 | }; 40 | await new Promise((resolve) => setTimeout(resolve, 3000)); 41 | const new_sol_balance = await connection.getBalance(wallet.publicKey); 42 | console.log(`new sol balance: ${new_sol_balance/LAMPORTS_PER_SOL}`); 43 | return txSignature; 44 | } 45 | 46 | async function main(){ 47 | unwrapSol(wallet_1) 48 | } 49 | 50 | // main(); 51 | -------------------------------------------------------------------------------- /src/constants/constants.ts: -------------------------------------------------------------------------------- 1 | import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes"; 2 | import { logger } from "../utils/logger"; 3 | import { retrieveEnvVariable } from "../utils/utils"; 4 | import { 5 | Currency, 6 | Token, 7 | TOKEN_PROGRAM_ID, 8 | } from "@raydium-io/raydium-sdk"; 9 | import { 10 | Commitment, 11 | Connection, 12 | Keypair, 13 | PublicKey 14 | } from "@solana/web3.js"; 15 | export const NETWORK = 'mainnet-beta'; 16 | export const COMMITMENT_LEVEL: Commitment = retrieveEnvVariable('COMMITMENT_LEVEL', logger) as Commitment; 17 | export const RPC_ENDPOINT = retrieveEnvVariable('RPC_ENDPOINT', logger); 18 | export const RPC_WEBSOCKET_ENDPOINT = retrieveEnvVariable('RPC_WEBSOCKET_ENDPOINT', logger); 19 | export const LOG_LEVEL = retrieveEnvVariable('LOG_LEVEL', logger); 20 | export const PRIVATE_KEY = retrieveEnvVariable('PRIVATE_KEY', logger); 21 | export const JITO_TIPS = retrieveEnvVariable('JITO_TIPS', logger); 22 | export const connection = new Connection(RPC_ENDPOINT, { 23 | wsEndpoint: RPC_WEBSOCKET_ENDPOINT, 24 | commitment: COMMITMENT_LEVEL, 25 | }); 26 | export const nozomi_connection = new Connection("https://ams1.secure.nozomi.temporal.xyz/?c=YOUR_NOZOMI_API_KEY") 27 | export const wallet_1 = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY)); 28 | export const wsol = "So11111111111111111111111111111111111111112" 29 | const usdc = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" 30 | export const quoteToken = [ 31 | usdc, // USDC 32 | "SOL", // SOL 33 | "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", // USDT 34 | wsol, // WSOL 35 | ]; 36 | export const DEFAULT_TOKEN = { 37 | SOL: new Currency(9, "SOL", "SOL"), 38 | WSOL: new Token( 39 | TOKEN_PROGRAM_ID, 40 | new PublicKey("So11111111111111111111111111111111111111112"), 41 | 9, 42 | "WSOL", 43 | "WSOL" 44 | ), 45 | USDC: new Token( 46 | TOKEN_PROGRAM_ID, 47 | new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), 48 | 6, 49 | "USDC", 50 | "USDC" 51 | ), 52 | }; -------------------------------------------------------------------------------- /src/utils/wrap_sol.ts: -------------------------------------------------------------------------------- 1 | import { NATIVE_MINT, getOrCreateAssociatedTokenAccount, createSyncNativeInstruction, } from "@solana/spl-token"; 2 | import { wallet_1, connection } from "../constants"; 3 | import { Transaction, SystemProgram, LAMPORTS_PER_SOL, sendAndConfirmTransaction, ComputeBudgetProgram } from "@solana/web3.js"; 4 | import {getSPLTokenBalance} from "./utils"; 5 | import { program } from "commander"; 6 | import { logger } from "./logger"; 7 | let wrap_size = 0; 8 | export async function wrap_sol( 9 | amount:number 10 | ){ 11 | // wSol ATA 12 | const wSolAta = await getOrCreateAssociatedTokenAccount(connection, wallet_1, NATIVE_MINT, wallet_1.publicKey); 13 | console.log(`wsol ATA: ${wSolAta.address.toBase58()}`); 14 | // wrap Sol 15 | let transaction = new Transaction().add( 16 | // trasnfer SOL 17 | SystemProgram.transfer({ 18 | fromPubkey: wallet_1.publicKey, 19 | toPubkey: wSolAta.address, 20 | lamports: amount*LAMPORTS_PER_SOL, 21 | }), 22 | // sync wrapped SOL balance 23 | createSyncNativeInstruction(wSolAta.address) 24 | ); 25 | 26 | 27 | // submit transaction 28 | const txSignature = await sendAndConfirmTransaction(connection, transaction, [wallet_1]); 29 | 30 | // validate transaction was successful 31 | try { 32 | const latestBlockhash = await connection.getLatestBlockhash(); 33 | await connection.confirmTransaction({ 34 | blockhash: latestBlockhash.blockhash, 35 | lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, 36 | signature: txSignature, 37 | }, 'confirmed'); 38 | } catch (error) { 39 | console.log(`Error wrapping sol: ${error}`); 40 | }; 41 | // await for 3 second 42 | await new Promise((resolve) => setTimeout(resolve, 3000)); 43 | await check_wsol_balance(wSolAta) 44 | 45 | return txSignature; 46 | } 47 | 48 | export async function check_wsol_balance(wSolAta:any){ 49 | const wsolBalance = await getSPLTokenBalance(connection, NATIVE_MINT, wallet_1.publicKey); 50 | 51 | console.log(`new wsol balance: ${wsolBalance}`); 52 | return wsolBalance; 53 | } 54 | 55 | export async function main(){ 56 | await wrap_sol(0.1); 57 | 58 | } 59 | //main(); -------------------------------------------------------------------------------- /src/jito/types.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | PublicKey, 4 | SystemProgram, 5 | TransactionMessage, 6 | VersionedTransaction, 7 | } from '@solana/web3.js'; 8 | 9 | import {Bundle as IBundle} from './block-eng-bundle'; 10 | import {Header} from './shared'; 11 | import {Packet} from './packet'; 12 | import {serializeTransactions} from './utils'; 13 | 14 | // Represents a bundle of transactions expected to execute all or nothing, atomically and sequentially. 15 | export class Bundle implements IBundle { 16 | private transactions: VersionedTransaction[]; 17 | // Maximum number of transactions a bundle may have. 18 | private readonly transactionLimit: number; 19 | header: Header | undefined; 20 | packets: Packet[]; 21 | 22 | constructor(txs: VersionedTransaction[], transactionLimit: number) { 23 | this.transactions = txs; 24 | this.transactionLimit = transactionLimit; 25 | this.packets = serializeTransactions(txs); 26 | } 27 | 28 | // Adds transactions to the bundle. 29 | addTransactions(...transactions: VersionedTransaction[]): Bundle | Error { 30 | const numTransactions = this.transactions.length + transactions.length; 31 | if (numTransactions > this.transactionLimit) { 32 | return new Error( 33 | `${numTransactions} exceeds transaction limit of ${this.transactionLimit}` 34 | ); 35 | } 36 | 37 | this.transactions.push(...transactions); 38 | this.packets = this.packets.concat(serializeTransactions(transactions)); 39 | 40 | return this; 41 | } 42 | 43 | // Creates a new transaction to tip. 44 | addTipTx( 45 | keypair: Keypair, 46 | tipLamports: number, 47 | tipAccount: PublicKey, 48 | recentBlockhash: string 49 | ): Bundle | Error { 50 | const numTransactions = this.transactions.length + 1; 51 | if (numTransactions > this.transactionLimit) { 52 | return new Error( 53 | `${numTransactions} exceeds transaction limit of ${this.transactionLimit}` 54 | ); 55 | } 56 | 57 | const tipIx = SystemProgram.transfer({ 58 | fromPubkey: keypair.publicKey, 59 | toPubkey: tipAccount, 60 | lamports: tipLamports, 61 | }); 62 | 63 | const instructions = [tipIx]; 64 | 65 | const messageV0 = new TransactionMessage({ 66 | payerKey: keypair.publicKey, 67 | recentBlockhash: recentBlockhash, 68 | instructions, 69 | }).compileToV0Message(); 70 | 71 | const tipTx = new VersionedTransaction(messageV0); 72 | 73 | tipTx.sign([keypair]); 74 | 75 | this.transactions.push(tipTx); 76 | this.packets = this.packets.concat(serializeTransactions([tipTx])); 77 | 78 | return this; 79 | } 80 | } -------------------------------------------------------------------------------- /src/jito/bundle.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Connection, 3 | PublicKey, 4 | Keypair, 5 | VersionedTransaction, 6 | MessageV0, 7 | LAMPORTS_PER_SOL 8 | } 9 | from '@solana/web3.js'; 10 | import { Bundle } from './types'; 11 | import { searcherClient } from 'jito-ts/dist/sdk/block-engine/searcher'; 12 | import { 13 | ChannelCredentials, 14 | ChannelOptions, 15 | ClientReadableStream, 16 | ServiceError, 17 | } from '@grpc/grpc-js'; 18 | import { SearcherServiceClient } from 'jito-ts/dist/gen/block-engine/searcher' 19 | import {SearcherClient} from "./searcher-client"; 20 | import {JITO_TIPS, connection, wsol}from "../constants"; 21 | import { logger, writeLineToLogFile } from '../utils'; 22 | import { onBundleResult} from "./utils" 23 | const blockEngineUrl = process.env.BLOCK_ENGINE_URL || ''; 24 | logger.info(`BLOCK_ENGINE_URL: ${blockEngineUrl}`); 25 | 26 | 27 | export const searcherClientAdv = ( 28 | url: string, 29 | authKeypair: Keypair | undefined, 30 | grpcOptions?: Partial 31 | ): SearcherServiceClient => { 32 | const client: SearcherServiceClient = new SearcherServiceClient( 33 | url, 34 | ChannelCredentials.createSsl(), 35 | { ...grpcOptions } 36 | ); 37 | 38 | return client; 39 | } 40 | 41 | // build a searcher client 42 | const searcher_client:any = searcherClientAdv(blockEngineUrl, undefined, { 43 | "grpc.max_receive_message_length": 64 * 1024 * 1024, // 64MiB 44 | }); 45 | 46 | // construct a searcher bot 47 | const searcher_bot = new SearcherClient(searcher_client); 48 | // Get Tip Accounts 49 | let tipAccounts: string[] = []; 50 | (async () => { 51 | tipAccounts = await searcher_bot.getTipAccounts(); 52 | })(); 53 | 54 | // Send bundle to Jito 55 | export async function sendBundle(isSell: boolean, latestBlockhash: string, transaction: VersionedTransaction, poolId: PublicKey, masterKeypair: Keypair) { 56 | 57 | try { 58 | const _tipAccount = tipAccounts[Math.floor(Math.random() * 6)]; 59 | const tipAccount = new PublicKey(_tipAccount); 60 | const b:Bundle = new Bundle([transaction], 4); 61 | let jito_tips = 0.0001 62 | b.addTipTx( 63 | masterKeypair, 64 | jito_tips*LAMPORTS_PER_SOL, 65 | tipAccount, 66 | latestBlockhash 67 | ); 68 | logger.info( 69 | { 70 | status:`sending bundle.` 71 | } 72 | ) 73 | const uuid = await searcher_bot.sendBundle(b); 74 | logger.info( 75 | { 76 | dexscreener:`https://dexscreener.com/solana/${poolId.toBase58()}?maker=${masterKeypair.publicKey.toBase58()}` 77 | } 78 | ); 79 | return uuid; 80 | }catch (error) { 81 | logger.error(`error sending bundle: ${error}`); 82 | 83 | } 84 | return ""; 85 | 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/volume-bot.ts: -------------------------------------------------------------------------------- 1 | import { PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js'; 2 | import { connection, wallet_1 } from './constants'; 3 | import { PumpSwapSDK } from './pumpswap'; 4 | import { getSPLBalance } from './utils'; 5 | import { logger } from './utils'; 6 | 7 | interface VolumeBotConfig { 8 | tokenMint: string; 9 | minSolAmount: number; 10 | maxSolAmount: number; 11 | minDelayMs: number; 12 | maxDelayMs: number; 13 | maxConcurrentTrades: number; 14 | slippage: number; 15 | } 16 | 17 | export class VolumeBot { 18 | private sdk: PumpSwapSDK; 19 | private config: VolumeBotConfig; 20 | private isRunning: boolean = false; 21 | private activeTrades: number = 0; 22 | 23 | constructor(config: VolumeBotConfig) { 24 | this.sdk = new PumpSwapSDK(); 25 | this.config = config; 26 | } 27 | 28 | private async executeTrade() { 29 | try { 30 | const tokenMint = new PublicKey(this.config.tokenMint); 31 | const solAmount = this.getRandomAmount( 32 | this.config.minSolAmount, 33 | this.config.maxSolAmount 34 | ); 35 | 36 | // Buy tokens 37 | logger.info({ 38 | status: 'Executing buy trade', 39 | solAmount, 40 | tokenMint: tokenMint.toBase58() 41 | }); 42 | await this.sdk.buy(tokenMint, wallet_1.publicKey, solAmount); 43 | 44 | // Wait random delay 45 | await this.randomDelay(); 46 | 47 | // Sell tokens 48 | const tokenBalance = await getSPLBalance(connection, tokenMint, wallet_1.publicKey); 49 | if (tokenBalance > 0) { 50 | logger.info({ 51 | status: 'Executing sell trade', 52 | tokenAmount: tokenBalance, 53 | tokenMint: tokenMint.toBase58() 54 | }); 55 | await this.sdk.sell_exactAmount(tokenMint, wallet_1.publicKey, tokenBalance); 56 | } 57 | 58 | this.activeTrades--; 59 | } catch (error) { 60 | logger.error(`Trade execution error: ${error}`); 61 | this.activeTrades--; 62 | } 63 | } 64 | 65 | private getRandomAmount(min: number, max: number): number { 66 | return Math.random() * (max - min) + min; 67 | } 68 | 69 | private async randomDelay() { 70 | const delay = this.getRandomAmount( 71 | this.config.minDelayMs, 72 | this.config.maxDelayMs 73 | ); 74 | await new Promise(resolve => setTimeout(resolve, delay)); 75 | } 76 | 77 | private async startTradeLoop() { 78 | while (this.isRunning && this.activeTrades < this.config.maxConcurrentTrades) { 79 | this.activeTrades++; 80 | this.executeTrade().catch(error => { 81 | logger.error(`Trade loop error: ${error}`); 82 | this.activeTrades--; 83 | }); 84 | } 85 | } 86 | 87 | public async start() { 88 | if (this.isRunning) { 89 | logger.warn('Bot is already running'); 90 | return; 91 | } 92 | 93 | this.isRunning = true; 94 | logger.info({ 95 | status: 'Starting volume bot', 96 | config: this.config 97 | }); 98 | 99 | // Start multiple trade loops 100 | const tradeLoops = Array(this.config.maxConcurrentTrades) 101 | .fill(null) 102 | .map(() => this.startTradeLoop()); 103 | 104 | await Promise.all(tradeLoops); 105 | } 106 | 107 | public stop() { 108 | this.isRunning = false; 109 | logger.info('Stopping volume bot'); 110 | } 111 | } 112 | 113 | // Example usage 114 | async function main() { 115 | const config: VolumeBotConfig = { 116 | tokenMint: "YOUR_TOKEN_MINT_ADDRESS", 117 | minSolAmount: 0.1, 118 | maxSolAmount: 0.5, 119 | minDelayMs: 1000, // 1 second 120 | maxDelayMs: 5000, // 5 seconds 121 | maxConcurrentTrades: 3, 122 | slippage: 0.3 // 30% slippage 123 | }; 124 | 125 | const bot = new VolumeBot(config); 126 | await bot.start(); 127 | } 128 | 129 | if (require.main === module) { 130 | main().catch(console.error); 131 | } -------------------------------------------------------------------------------- /src/nozomi/tx-submission.ts: -------------------------------------------------------------------------------- 1 | 2 | import { PublicKey, TransactionInstruction, Keypair, Connection, SystemProgram, Transaction, LAMPORTS_PER_SOL } from "@solana/web3.js"; 3 | import {connection, nozomi_connection, JITO_TIPS} from "../constants"; 4 | import bs58 from "bs58"; 5 | import axios from "axios"; 6 | // Define constants 7 | const NOZOMI_TIP = new PublicKey("TEMPaMeCRFAS9EKF53Jd6KpHxgL47uWLcpFArU1Fanq"); 8 | const MIN_TIP_AMOUNT = 1_000_000; 9 | 10 | const listOfValidators = [ 11 | "TEMPaMeCRFAS9EKF53Jd6KpHxgL47uWLcpFArU1Fanq", 12 | "noz3jAjPiHuBPqiSPkkugaJDkJscPuRhYnSpbi8UvC4", 13 | "noz3str9KXfpKknefHji8L1mPgimezaiUyCHYMDv1GE", 14 | "noz6uoYCDijhu1V7cutCpwxNiSovEwLdRHPwmgCGDNo", 15 | "noz9EPNcT7WH6Sou3sr3GGjHQYVkN3DNirpbvDkv9YJ", 16 | "nozc5yT15LazbLTFVZzoNZCwjh3yUtW86LoUyqsBu4L", 17 | "nozFrhfnNGoyqwVuwPAW4aaGqempx4PU6g6D9CJMv7Z", 18 | "nozievPk7HyK1Rqy1MPJwVQ7qQg2QoJGyP71oeDwbsu", 19 | "noznbgwYnBLDHu8wcQVCEw6kDrXkPdKkydGJGNXGvL7", 20 | "nozNVWs5N8mgzuD3qigrCG2UoKxZttxzZ85pvAQVrbP", 21 | "nozpEGbwx4BcGp6pvEdAh1JoC2CQGZdU6HbNP1v2p6P", 22 | "nozrhjhkCr3zXT3BiT4WCodYCUFeQvcdUkM7MqhKqge", 23 | "nozrwQtWhEdrA6W8dkbt9gnUaMs52PdAv5byipnadq3", 24 | "nozUacTVWub3cL4mJmGCYjKZTnE9RbdY5AP46iQgbPJ", 25 | "nozWCyTPppJjRuw2fpzDhhWbW355fzosWSzrrMYB1Qk", 26 | "nozWNju6dY353eMkMqURqwQEoM3SFgEKC6psLCSfUne", 27 | "nozxNBgWohjR75vdspfxR5H9ceC7XXH99xpxhVGt3Bb" 28 | 29 | ] 30 | const nozomi_url = "http://ams1.nozomi.temporal.xyz/?c="; 31 | const nozomi_url1 = "http://fra2.nozomi.temporal.xyz/?c="; 32 | const nozomi_url2 = "http://ewr1.nozomi.temporal.xyz/?c="; 33 | const nozomi_url3 = "http://pit1.nozomi.temporal.xyz/?c="; 34 | const other_server_url =[ 35 | "http://fra2.nozomi.temporal.xyz/?c=", 36 | "http://ewr1.nozomi.temporal.xyz/?c=", 37 | "http://pit1.nozomi.temporal.xyz/?c=" 38 | 39 | ] 40 | const low_latency_api_key = [ 41 | "YOUR_NOZOMI_LOW_LATENCY_KEY" 42 | ] 43 | 44 | const low_latency_api_key_create_token_account = [ 45 | "YOUR_NOZOMI_LOW_LATENCY_KEY" 46 | ] 47 | export async function getRamdomValidator() { 48 | const randomIndex = Math.floor(Math.random() * listOfValidators.length); 49 | return new PublicKey(listOfValidators[randomIndex]); 50 | } 51 | export async function getRandomNozomiAPIKey() { 52 | const randomIndex = Math.floor(Math.random() * low_latency_api_key.length); 53 | return low_latency_api_key[randomIndex]; 54 | } 55 | export async function sendNozomiTx( 56 | ixs: any[], 57 | signer: Keypair, 58 | blockhash:any, 59 | dex:string, 60 | buyOrSell:string, 61 | ): Promise { 62 | const validator = await getRamdomValidator(); 63 | console.log("signer", signer.publicKey.toBase58()); 64 | console.log("Sending tip to", validator.toBase58()); 65 | // Create transfer instruction 66 | let tips = parseFloat(JITO_TIPS); 67 | const tipIx = SystemProgram.transfer({ 68 | fromPubkey: signer.publicKey, 69 | toPubkey: validator, 70 | lamports: tips*LAMPORTS_PER_SOL, 71 | }); 72 | ixs.push(tipIx); 73 | 74 | // Get the latest blockhash 75 | const blockhash1 = await connection.getLatestBlockhash(); 76 | // Create transaction and sign it 77 | const tx = new Transaction().add(...ixs); 78 | if(typeof blockhash1 === "string") { 79 | tx.recentBlockhash = blockhash1; 80 | }else{ 81 | tx.recentBlockhash = blockhash1.blockhash; 82 | tx.lastValidBlockHeight = blockhash1.lastValidBlockHeight 83 | } 84 | tx.feePayer = signer.publicKey; 85 | tx.sign(signer); 86 | console.log(tx); 87 | const b64Tx = Buffer.from(tx.serialize()).toString('base64'); 88 | let url_request = `${nozomi_url}${await getRandomNozomiAPIKey()}`; 89 | let request; 90 | try{ 91 | for(let i=0; i<2; i++){ 92 | request = axios.post(url_request, { 93 | jsonrpc: "2.0", 94 | id: 1, 95 | method: "sendTransaction", 96 | params: [ 97 | b64Tx, 98 | { "encoding": "base64" } 99 | ] 100 | }); 101 | } 102 | 103 | for(const url of other_server_url){ 104 | let url_request = `${url}${await getRandomNozomiAPIKey()}`; 105 | request = axios.post(url_request, { 106 | jsonrpc: "2.0", 107 | id: 1, 108 | method: "sendTransaction", 109 | params: [ 110 | b64Tx, 111 | { "encoding": "base64" } 112 | ] 113 | }); 114 | } 115 | 116 | 117 | 118 | } catch (error) { 119 | console.log(`error sending tx to Nozomi: ${error}`); 120 | 121 | } 122 | 123 | console.log("Transaction sent with signature:", request); 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PumpSwap Volume Bot 2 | 3 | A TypeScript-based volume bot for generating trading volume on PumpSwap DEX. This bot automatically executes buy and sell trades with configurable parameters to generate volume. 4 | 5 | ## Features 6 | 7 | - 🔄 Automated buy/sell cycles 8 | - ⚡ Concurrent trade execution 9 | - 🎲 Random trade amounts and delays 10 | - 📊 Configurable parameters 11 | - 🔒 MEV protection through Jito bundles 12 | - 📝 Comprehensive logging 13 | - ⚠️ Error handling and recovery 14 | 15 | ## Prerequisites 16 | 17 | - Node.js v16 or higher 18 | - npm or yarn 19 | - Solana wallet with SOL for trading 20 | - Helius RPC key 21 | 22 | ## Installation 23 | 24 | 1. Clone the repository: 25 | ```bash 26 | git clone 27 | cd pumpswap-sdk 28 | ``` 29 | 30 | 2. Install dependencies: 31 | ```bash 32 | npm install 33 | ``` 34 | 35 | 3. Create a `.env` file in the root directory: 36 | ```env 37 | PRIVATE_KEY=your_private_key 38 | HELIUS_RPC_KEY=your_helius_rpc_key 39 | ``` 40 | 41 | ## Configuration 42 | 43 | The bot can be configured with the following parameters: 44 | 45 | ```typescript 46 | const config: VolumeBotConfig = { 47 | tokenMint: "YOUR_TOKEN_MINT_ADDRESS", // The token you want to trade 48 | minSolAmount: 0.1, // Minimum SOL per trade 49 | maxSolAmount: 0.5, // Maximum SOL per trade 50 | minDelayMs: 1000, // Minimum delay between trades (1 second) 51 | maxDelayMs: 5000, // Maximum delay between trades (5 seconds) 52 | maxConcurrentTrades: 3, // Number of concurrent trades 53 | slippage: 0.3 // Slippage tolerance (30%) 54 | }; 55 | ``` 56 | 57 | ## Usage 58 | 59 | 1. Import and initialize the bot: 60 | ```typescript 61 | import { VolumeBot } from './src/volume-bot'; 62 | 63 | const config: VolumeBotConfig = { 64 | tokenMint: "YOUR_TOKEN_MINT_ADDRESS", 65 | minSolAmount: 0.1, 66 | maxSolAmount: 0.5, 67 | minDelayMs: 1000, 68 | maxDelayMs: 5000, 69 | maxConcurrentTrades: 3, 70 | slippage: 0.3 71 | }; 72 | 73 | const bot = new VolumeBot(config); 74 | ``` 75 | 76 | 2. Start the bot: 77 | ```typescript 78 | await bot.start(); 79 | ``` 80 | 81 | 3. Stop the bot: 82 | ```typescript 83 | bot.stop(); 84 | ``` 85 | 86 | ## How It Works 87 | 88 | 1. The bot creates multiple concurrent trade loops 89 | 2. Each loop: 90 | - Buys tokens with a random SOL amount 91 | - Waits for a random delay 92 | - Sells the tokens back 93 | - Repeats the process 94 | 95 | ## Safety Features 96 | 97 | - Balance verification before selling 98 | - Error handling for failed transactions 99 | - Configurable slippage protection 100 | - Concurrent trade limiting 101 | - Automatic error recovery 102 | 103 | ## Logging 104 | 105 | The bot logs all activities including: 106 | - Trade execution 107 | - Buy/sell amounts 108 | - Errors and exceptions 109 | - Start/stop events 110 | 111 | ## Important Notes 112 | 113 | 1. Make sure you have enough SOL in your wallet for trading 114 | 2. The bot uses Jito bundles for MEV protection 115 | 3. Monitor your wallet balance and adjust parameters accordingly 116 | 4. Use appropriate delays to avoid rate limiting 117 | 5. Consider network congestion when setting parameters 118 | 119 | ## Disclaimer 120 | 121 | This bot is for educational purposes only. Trading bots can result in financial losses. Use at your own risk. 122 | 123 | ## License 124 | 125 | MIT License 126 | 127 | # PumpSwap SDK 128 | # To Get Start 129 | 1. `npm i` 130 | 131 | 2. Paste your private key and Helius RPC key in .env.copy 132 | 133 | 3. rename it to .env 134 | 135 | # Usage 136 | 137 | ### buy/sell on PumpSwap 138 | ```typescript 139 | import {wallet_1} from "./constants"; 140 | import {PumpSwapSDK} from './pumpswap'; 141 | async function main() { 142 | const mint = "your-pumpfun-token-address"; 143 | const sol_amt = 0.99; // buy 1 SOL worth of token using WSOL 144 | const sell_percentage = 0.5; // sell 50% of the token 145 | const pumpswap_sdk = new PumpSwapSDK(); 146 | await pumpswap_sdk.buy(new PublicKey(mint), wallet_1.publicKey, sol_amt); // 0.99 sol 147 | await pumpswap_sdk.sell_percentage(new PublicKey(mint), wallet_1.publicKey, sell_percentage); 148 | await pumpswap_sdk.sell_exactAmount(new PublicKey(mint), wallet_1.publicKey, 1000); // 1000 token 149 | } 150 | ``` 151 | 152 | ### Fetch the price 153 | ```typescript 154 | import {getPrice} from './pool'; 155 | async function main() { 156 | const mint = new PublicKey("your-pumpfun-token-address"); 157 | console.log(await getPrice(mint)); 158 | } 159 | ``` 160 | 161 | ### Fetch the pool 162 | ```typescript 163 | import {getPumpSwapPool} from './pool'; 164 | async function main() { 165 | const mint = new PublicKey("your-pumpfun-token-address"); 166 | console.log(await getPumpSwapPool(mint)); 167 | } 168 | ``` 169 | 170 | ## Telegram Contact [@g0drlc](https://t.me/g0drlc) 171 | 172 | -------------------------------------------------------------------------------- /src/utils/utils.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from 'pino'; 2 | import fs from "fs"; 3 | import { getAssociatedTokenAddressSync } from '@solana/spl-token'; 4 | import { 5 | Connection, 6 | Keypair, 7 | PublicKey, 8 | Transaction, 9 | SystemProgram, 10 | sendAndConfirmTransaction, 11 | LAMPORTS_PER_SOL, 12 | } from '@solana/web3.js'; 13 | import { logger } from './logger'; 14 | import bs58 from 'bs58'; 15 | import {connection} from "../constants" 16 | import dotenv from 'dotenv'; 17 | import * as path from 'path'; 18 | const relativeDotenvPath = "../../.env"; 19 | 20 | // Resolve the absolute path 21 | const absoluteDotenvPath = path.resolve(__dirname, relativeDotenvPath); 22 | dotenv.config({ 23 | path: absoluteDotenvPath, 24 | }); 25 | const log_path = "" 26 | export const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"); 27 | 28 | 29 | export async function getSPLTokenBalance(connection:Connection, tokenAccount:PublicKey, payerPubKey:PublicKey) { 30 | try{ 31 | const address = getAssociatedTokenAddressSync(tokenAccount, payerPubKey); 32 | const info = await connection.getTokenAccountBalance(address, "processed"); 33 | if (info.value.uiAmount == null) throw new Error("No balance found"); 34 | return info.value.uiAmount; 35 | }catch(err:any){ 36 | logger.error(`Errr when checking token balance...`) 37 | } 38 | return 0; 39 | } 40 | export function retrieveEnvVariable(variableName: string, logger: Logger){ 41 | const variable = process.env[variableName] || ''; 42 | if (!variable) { 43 | logger.error(`${variableName} is not set`); 44 | process.exit(1); 45 | } 46 | return variable; 47 | } 48 | 49 | export function getKeypairByJsonPath(jsonPath: string): any { 50 | try { 51 | const keypairJson = fs.readFileSync(jsonPath, "utf-8"); 52 | const data = JSON.parse(keypairJson); 53 | const mintKeypair = Keypair.fromSecretKey(Uint8Array.from(data)); 54 | return mintKeypair 55 | } catch (e) { 56 | console.log(e); 57 | } 58 | } 59 | export async function printSOLBalance ( 60 | connection: Connection, 61 | pubKey: PublicKey, 62 | info = "" 63 | ) { 64 | const balance = await connection.getBalance(pubKey); 65 | console.log( 66 | `${info ? info + " " : ""}${pubKey.toBase58()}:`, 67 | balance / LAMPORTS_PER_SOL, 68 | `SOL` 69 | ); 70 | }; 71 | 72 | export async function getSOLBalance(connection:Connection, pubKey:PublicKey){ 73 | const balance = await connection.getBalance(pubKey); 74 | return balance / LAMPORTS_PER_SOL; 75 | } 76 | 77 | export async function getSPLBalance ( 78 | connection: Connection, 79 | mintAddress: PublicKey, 80 | pubKey: PublicKey, 81 | allowOffCurve = false 82 | ): Promise { 83 | try { 84 | let ata = getAssociatedTokenAddressSync(mintAddress, pubKey, allowOffCurve); 85 | const balance = await connection.getTokenAccountBalance(ata, "confirmed"); 86 | return balance.value.uiAmount || 0; 87 | } catch (e) {} 88 | return 0; 89 | }; 90 | export async function printSPLBalance ( 91 | connection: Connection, 92 | mintAddress: PublicKey, 93 | user: PublicKey, 94 | info = "" 95 | ) { 96 | const balance = await getSPLBalance(connection, mintAddress, user); 97 | if (balance === null) { 98 | console.log( 99 | `${info ? info + " " : ""}${user.toBase58()}:`, 100 | "No Account Found" 101 | ); 102 | } else { 103 | console.log(`${info ? info + " " : ""}${user.toBase58()}:`, balance); 104 | } 105 | }; 106 | export async function retriveWalletState(wallet_address: string) { 107 | try{ 108 | const filters = [ 109 | { 110 | dataSize: 165, //size of account (bytes) 111 | }, 112 | { 113 | memcmp: { 114 | offset: 32, //location of our query in the account (bytes) 115 | bytes: wallet_address, //our search criteria, a base58 encoded string 116 | }, 117 | }, 118 | ]; 119 | const accounts = await connection.getParsedProgramAccounts( 120 | TOKEN_PROGRAM_ID, //new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") 121 | { filters: filters } 122 | ); 123 | let results = {}; 124 | const solBalance = await connection.getBalance(new PublicKey(wallet_address)); 125 | accounts.forEach((account, i) => { 126 | //Parse the account data 127 | const parsedAccountInfo = account.account.data; 128 | const mintAddress = parsedAccountInfo["parsed"]["info"]["mint"]; 129 | const tokenBalance = 130 | parsedAccountInfo["parsed"]["info"]["tokenAmount"]["uiAmount"]; 131 | results[mintAddress] = tokenBalance; 132 | }); 133 | results["SOL"] = solBalance / 10 ** 9; 134 | return results || {}; 135 | }catch(e){ 136 | console.log(e) 137 | } 138 | return {}; 139 | } 140 | 141 | export async function getDecimals(mintAddress: PublicKey): Promise { 142 | const info:any = await connection.getParsedAccountInfo(mintAddress); 143 | const result = (info.value?.data).parsed.info.decimals || 0; 144 | return result; 145 | } 146 | 147 | export async function writeLineToLogFile(logMessage:string){ 148 | fs.appendFile(log_path, `${logMessage}\n`, (err) => { 149 | if (err) { 150 | console.error('Error writing to log file:', err); 151 | } else { 152 | //console.log('Log message written successfully.'); 153 | } 154 | }); 155 | } 156 | 157 | 158 | async function main(){ 159 | 160 | } 161 | // main() -------------------------------------------------------------------------------- /src/pool.ts: -------------------------------------------------------------------------------- 1 | import { Program } from "@coral-xyz/anchor"; 2 | import { Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; 3 | import {PumpSwap, IDL} from "./IDL"; 4 | import { connection } from "./constants"; 5 | const PUMP_AMM_PROGRAM_ID: PublicKey = new PublicKey('pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA'); 6 | const WSOL_TOKEN_ACCOUNT: PublicKey = new PublicKey('So11111111111111111111111111111111111111112'); 7 | const program = new Program(IDL, { 8 | connection, 9 | }); 10 | 11 | interface Pool { 12 | address: PublicKey; 13 | is_native_base: boolean; 14 | poolData: any; 15 | } 16 | 17 | interface PoolWithPrice extends Pool { 18 | price: number; 19 | reserves: { 20 | native: number; 21 | token: number; 22 | } 23 | } 24 | 25 | const getPoolsWithBaseMint = async (mintAddress: PublicKey) => { 26 | const response = await connection.getProgramAccounts(PUMP_AMM_PROGRAM_ID, { 27 | filters: [ 28 | { "dataSize": 211 }, 29 | { 30 | "memcmp": { 31 | "offset": 43, 32 | "bytes": mintAddress.toBase58() 33 | } 34 | } 35 | ] 36 | } 37 | ) 38 | 39 | const mappedPools = response.map((pool) => { 40 | const data = Buffer.from(pool.account.data); 41 | const poolData = program.coder.accounts.decode('pool', data); 42 | return { 43 | address: pool.pubkey, 44 | is_native_base: false, 45 | poolData 46 | }; 47 | }) 48 | 49 | return mappedPools; 50 | } 51 | 52 | const getPoolsWithQuoteMint = async (mintAddress: PublicKey) => { 53 | const response = await connection.getProgramAccounts(PUMP_AMM_PROGRAM_ID, { 54 | filters: [ 55 | { "dataSize": 211 }, 56 | { 57 | "memcmp": { 58 | "offset": 75, 59 | "bytes": mintAddress.toBase58() 60 | } 61 | } 62 | ] 63 | } 64 | ) 65 | 66 | const mappedPools = response.map((pool) => { 67 | const data = Buffer.from(pool.account.data); 68 | const poolData = program.coder.accounts.decode('pool', data); 69 | return { 70 | address: pool.pubkey, 71 | is_native_base: true, 72 | poolData 73 | }; 74 | }) 75 | 76 | return mappedPools; 77 | } 78 | 79 | const getPoolsWithBaseMintQuoteWSOL = async (mintAddress: PublicKey) => { 80 | const response = await connection.getProgramAccounts(PUMP_AMM_PROGRAM_ID, { 81 | filters: [ 82 | { "dataSize": 211 }, 83 | { 84 | "memcmp": { 85 | "offset": 43, 86 | "bytes": mintAddress.toBase58() 87 | } 88 | }, 89 | { 90 | "memcmp": { 91 | "offset": 75, 92 | "bytes": WSOL_TOKEN_ACCOUNT.toBase58() 93 | } 94 | } 95 | ] 96 | } 97 | ) 98 | 99 | const mappedPools = response.map((pool) => { 100 | const data = Buffer.from(pool.account.data); 101 | const poolData = program.coder.accounts.decode('pool', data); 102 | return { 103 | address: pool.pubkey, 104 | is_native_base: true, 105 | poolData 106 | }; 107 | }) 108 | 109 | return mappedPools; 110 | } 111 | 112 | const getPriceAndLiquidity = async (pool: Pool) => { 113 | const wsolAddress = pool.poolData.poolQuoteTokenAccount; 114 | const tokenAddress = pool.poolData.poolBaseTokenAccount; 115 | 116 | const wsolBalance = await connection.getTokenAccountBalance(wsolAddress); 117 | const tokenBalance = await connection.getTokenAccountBalance(tokenAddress); 118 | 119 | const price = wsolBalance.value.uiAmount! / tokenBalance.value.uiAmount!; 120 | 121 | return { 122 | ...pool, 123 | price, 124 | reserves: { 125 | native: wsolBalance.value.uiAmount!, 126 | token: tokenBalance.value.uiAmount! 127 | } 128 | } as PoolWithPrice; 129 | } 130 | const getPoolsWithPrices = async (mintAddress: PublicKey) => { 131 | const [poolsWithBaseMint, poolsWithQuoteMint] = await Promise.all([ 132 | getPoolsWithBaseMint(mintAddress), 133 | getPoolsWithQuoteMint(mintAddress) 134 | ]) 135 | //const poolsWithBaseMinQuoteWSOL = await getPoolsWithBaseMintQuoteWSOL(mintAddress) 136 | const pools = [...poolsWithBaseMint, ...poolsWithQuoteMint]; 137 | 138 | const results = await Promise.all(pools.map(getPriceAndLiquidity)); 139 | 140 | const sortedByHighestLiquidity = results.sort((a, b) => b.reserves.native - a.reserves.native); 141 | 142 | return sortedByHighestLiquidity; 143 | } 144 | export const calculateWithSlippageBuy = ( 145 | amount: bigint, 146 | basisPoints: bigint 147 | ) => { 148 | return amount - (amount * basisPoints) / 10000n; 149 | }; 150 | export const getBuyTokenAmount = async (solAmount: bigint, mint:PublicKey) => { 151 | const pool_detail = await getPoolsWithPrices(mint); 152 | const sol_reserve = BigInt(Math.floor(pool_detail[0].reserves.native *LAMPORTS_PER_SOL)); 153 | const token_reserve = BigInt(Math.floor(pool_detail[0].reserves.token * 10**6)); 154 | const product = sol_reserve * token_reserve; 155 | let new_sol_reserve = sol_reserve + solAmount; 156 | let new_token_reserve = product / new_sol_reserve + 1n; 157 | let amount_to_be_purchased = token_reserve - new_token_reserve; 158 | 159 | return amount_to_be_purchased; 160 | } 161 | 162 | export const getPumpSwapPool = async (mint:PublicKey) => { 163 | const pools = await getPoolsWithBaseMintQuoteWSOL(mint); 164 | return pools[0].address; 165 | } 166 | 167 | export const getPrice = async (mint:PublicKey) => { 168 | const pools = await getPoolsWithPrices(mint) 169 | return pools[0].price; 170 | } 171 | async function main(){ 172 | const mint = new PublicKey(""); 173 | // console.log(await getBuyTokenAmount(BigInt(0.1*LAMPORTS_PER_SOL), mint)); 174 | // console.log(await getPumpSwapPool(mint)) 175 | console.log(await getPrice(mint)); 176 | 177 | } 178 | // main(); -------------------------------------------------------------------------------- /src/jito/shared.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Long from "long"; 3 | import _m0 from "protobufjs/minimal"; 4 | import { Timestamp } from "./google/protobuf/timestamp"; 5 | 6 | export const protobufPackage = "shared"; 7 | 8 | export interface Header { 9 | ts: Date | undefined; 10 | } 11 | 12 | export interface Heartbeat { 13 | count: number; 14 | } 15 | 16 | export interface Socket { 17 | ip: string; 18 | port: number; 19 | } 20 | 21 | function createBaseHeader(): Header { 22 | return { ts: undefined }; 23 | } 24 | 25 | export const Header = { 26 | encode(message: Header, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 27 | if (message.ts !== undefined) { 28 | Timestamp.encode(toTimestamp(message.ts), writer.uint32(10).fork()).ldelim(); 29 | } 30 | return writer; 31 | }, 32 | 33 | decode(input: _m0.Reader | Uint8Array, length?: number): Header { 34 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 35 | let end = length === undefined ? reader.len : reader.pos + length; 36 | const message = createBaseHeader(); 37 | while (reader.pos < end) { 38 | const tag = reader.uint32(); 39 | switch (tag >>> 3) { 40 | case 1: 41 | message.ts = fromTimestamp(Timestamp.decode(reader, reader.uint32())); 42 | break; 43 | default: 44 | reader.skipType(tag & 7); 45 | break; 46 | } 47 | } 48 | return message; 49 | }, 50 | 51 | fromJSON(object: any): Header { 52 | return { ts: isSet(object.ts) ? fromJsonTimestamp(object.ts) : undefined }; 53 | }, 54 | 55 | toJSON(message: Header): unknown { 56 | const obj: any = {}; 57 | message.ts !== undefined && (obj.ts = message.ts.toISOString()); 58 | return obj; 59 | }, 60 | 61 | create, I>>(base?: I): Header { 62 | return Header.fromPartial(base ?? {}); 63 | }, 64 | 65 | fromPartial, I>>(object: I): Header { 66 | const message = createBaseHeader(); 67 | message.ts = object.ts ?? undefined; 68 | return message; 69 | }, 70 | }; 71 | 72 | function createBaseHeartbeat(): Heartbeat { 73 | return { count: 0 }; 74 | } 75 | 76 | export const Heartbeat = { 77 | encode(message: Heartbeat, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 78 | if (message.count !== 0) { 79 | writer.uint32(8).uint64(message.count); 80 | } 81 | return writer; 82 | }, 83 | 84 | decode(input: _m0.Reader | Uint8Array, length?: number): Heartbeat { 85 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 86 | let end = length === undefined ? reader.len : reader.pos + length; 87 | const message = createBaseHeartbeat(); 88 | while (reader.pos < end) { 89 | const tag = reader.uint32(); 90 | switch (tag >>> 3) { 91 | case 1: 92 | message.count = longToNumber(reader.uint64() as Long); 93 | break; 94 | default: 95 | reader.skipType(tag & 7); 96 | break; 97 | } 98 | } 99 | return message; 100 | }, 101 | 102 | fromJSON(object: any): Heartbeat { 103 | return { count: isSet(object.count) ? Number(object.count) : 0 }; 104 | }, 105 | 106 | toJSON(message: Heartbeat): unknown { 107 | const obj: any = {}; 108 | message.count !== undefined && (obj.count = Math.round(message.count)); 109 | return obj; 110 | }, 111 | 112 | create, I>>(base?: I): Heartbeat { 113 | return Heartbeat.fromPartial(base ?? {}); 114 | }, 115 | 116 | fromPartial, I>>(object: I): Heartbeat { 117 | const message = createBaseHeartbeat(); 118 | message.count = object.count ?? 0; 119 | return message; 120 | }, 121 | }; 122 | 123 | function createBaseSocket(): Socket { 124 | return { ip: "", port: 0 }; 125 | } 126 | 127 | export const Socket = { 128 | encode(message: Socket, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 129 | if (message.ip !== "") { 130 | writer.uint32(10).string(message.ip); 131 | } 132 | if (message.port !== 0) { 133 | writer.uint32(16).int64(message.port); 134 | } 135 | return writer; 136 | }, 137 | 138 | decode(input: _m0.Reader | Uint8Array, length?: number): Socket { 139 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 140 | let end = length === undefined ? reader.len : reader.pos + length; 141 | const message = createBaseSocket(); 142 | while (reader.pos < end) { 143 | const tag = reader.uint32(); 144 | switch (tag >>> 3) { 145 | case 1: 146 | message.ip = reader.string(); 147 | break; 148 | case 2: 149 | message.port = longToNumber(reader.int64() as Long); 150 | break; 151 | default: 152 | reader.skipType(tag & 7); 153 | break; 154 | } 155 | } 156 | return message; 157 | }, 158 | 159 | fromJSON(object: any): Socket { 160 | return { ip: isSet(object.ip) ? String(object.ip) : "", port: isSet(object.port) ? Number(object.port) : 0 }; 161 | }, 162 | 163 | toJSON(message: Socket): unknown { 164 | const obj: any = {}; 165 | message.ip !== undefined && (obj.ip = message.ip); 166 | message.port !== undefined && (obj.port = Math.round(message.port)); 167 | return obj; 168 | }, 169 | 170 | create, I>>(base?: I): Socket { 171 | return Socket.fromPartial(base ?? {}); 172 | }, 173 | 174 | fromPartial, I>>(object: I): Socket { 175 | const message = createBaseSocket(); 176 | message.ip = object.ip ?? ""; 177 | message.port = object.port ?? 0; 178 | return message; 179 | }, 180 | }; 181 | 182 | declare var self: any | undefined; 183 | declare var window: any | undefined; 184 | declare var global: any | undefined; 185 | var tsProtoGlobalThis: any = (() => { 186 | if (typeof globalThis !== "undefined") { 187 | return globalThis; 188 | } 189 | if (typeof self !== "undefined") { 190 | return self; 191 | } 192 | if (typeof window !== "undefined") { 193 | return window; 194 | } 195 | if (typeof global !== "undefined") { 196 | return global; 197 | } 198 | throw "Unable to locate global object"; 199 | })(); 200 | 201 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 202 | 203 | export type DeepPartial = T extends Builtin ? T 204 | : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> 205 | : T extends {} ? { [K in keyof T]?: DeepPartial } 206 | : Partial; 207 | 208 | type KeysOfUnion = T extends T ? keyof T : never; 209 | export type Exact = P extends Builtin ? P 210 | : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; 211 | 212 | function toTimestamp(date: Date): Timestamp { 213 | const seconds = date.getTime() / 1_000; 214 | const nanos = (date.getTime() % 1_000) * 1_000_000; 215 | return { seconds, nanos }; 216 | } 217 | 218 | function fromTimestamp(t: Timestamp): Date { 219 | let millis = t.seconds * 1_000; 220 | millis += t.nanos / 1_000_000; 221 | return new Date(millis); 222 | } 223 | 224 | function fromJsonTimestamp(o: any): Date { 225 | if (o instanceof Date) { 226 | return o; 227 | } else if (typeof o === "string") { 228 | return new Date(o); 229 | } else { 230 | return fromTimestamp(Timestamp.fromJSON(o)); 231 | } 232 | } 233 | 234 | function longToNumber(long: Long): number { 235 | if (long.gt(Number.MAX_SAFE_INTEGER)) { 236 | throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); 237 | } 238 | return long.toNumber(); 239 | } 240 | 241 | if (_m0.util.Long !== Long) { 242 | _m0.util.Long = Long as any; 243 | _m0.configure(); 244 | } 245 | 246 | function isSet(value: any): boolean { 247 | return value !== null && value !== undefined; 248 | } -------------------------------------------------------------------------------- /src/jito/google/protobuf/timestamp.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Long from "long"; 3 | import _m0 from "protobufjs/minimal"; 4 | 5 | export const protobufPackage = "google.protobuf"; 6 | 7 | /** 8 | * A Timestamp represents a point in time independent of any time zone or local 9 | * calendar, encoded as a count of seconds and fractions of seconds at 10 | * nanosecond resolution. The count is relative to an epoch at UTC midnight on 11 | * January 1, 1970, in the proleptic Gregorian calendar which extends the 12 | * Gregorian calendar backwards to year one. 13 | * 14 | * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 15 | * second table is needed for interpretation, using a [24-hour linear 16 | * smear](https://developers.google.com/time/smear). 17 | * 18 | * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 19 | * restricting to that range, we ensure that we can convert to and from [RFC 20 | * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 21 | * 22 | * # Examples 23 | * 24 | * Example 1: Compute Timestamp from POSIX `time()`. 25 | * 26 | * Timestamp timestamp; 27 | * timestamp.set_seconds(time(NULL)); 28 | * timestamp.set_nanos(0); 29 | * 30 | * Example 2: Compute Timestamp from POSIX `gettimeofday()`. 31 | * 32 | * struct timeval tv; 33 | * gettimeofday(&tv, NULL); 34 | * 35 | * Timestamp timestamp; 36 | * timestamp.set_seconds(tv.tv_sec); 37 | * timestamp.set_nanos(tv.tv_usec * 1000); 38 | * 39 | * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 40 | * 41 | * FILETIME ft; 42 | * GetSystemTimeAsFileTime(&ft); 43 | * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 44 | * 45 | * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 46 | * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 47 | * Timestamp timestamp; 48 | * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 49 | * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 50 | * 51 | * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 52 | * 53 | * long millis = System.currentTimeMillis(); 54 | * 55 | * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 56 | * .setNanos((int) ((millis % 1000) * 1000000)).build(); 57 | * 58 | * Example 5: Compute Timestamp from Java `Instant.now()`. 59 | * 60 | * Instant now = Instant.now(); 61 | * 62 | * Timestamp timestamp = 63 | * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) 64 | * .setNanos(now.getNano()).build(); 65 | * 66 | * Example 6: Compute Timestamp from current time in Python. 67 | * 68 | * timestamp = Timestamp() 69 | * timestamp.GetCurrentTime() 70 | * 71 | * # JSON Mapping 72 | * 73 | * In JSON format, the Timestamp type is encoded as a string in the 74 | * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 75 | * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 76 | * where {year} is always expressed using four digits while {month}, {day}, 77 | * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 78 | * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 79 | * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 80 | * is required. A proto3 JSON serializer should always use UTC (as indicated by 81 | * "Z") when printing the Timestamp type and a proto3 JSON parser should be 82 | * able to accept both UTC and other timezones (as indicated by an offset). 83 | * 84 | * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 85 | * 01:30 UTC on January 15, 2017. 86 | * 87 | * In JavaScript, one can convert a Date object to this format using the 88 | * standard 89 | * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) 90 | * method. In Python, a standard `datetime.datetime` object can be converted 91 | * to this format using 92 | * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with 93 | * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use 94 | * the Joda Time's [`ISODateTimeFormat.dateTime()`]( 95 | * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D 96 | * ) to obtain a formatter capable of generating timestamps in this format. 97 | */ 98 | export interface Timestamp { 99 | /** 100 | * Represents seconds of UTC time since Unix epoch 101 | * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 102 | * 9999-12-31T23:59:59Z inclusive. 103 | */ 104 | seconds: number; 105 | /** 106 | * Non-negative fractions of a second at nanosecond resolution. Negative 107 | * second values with fractions must still have non-negative nanos values 108 | * that count forward in time. Must be from 0 to 999,999,999 109 | * inclusive. 110 | */ 111 | nanos: number; 112 | } 113 | 114 | function createBaseTimestamp(): Timestamp { 115 | return { seconds: 0, nanos: 0 }; 116 | } 117 | 118 | export const Timestamp = { 119 | encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 120 | if (message.seconds !== 0) { 121 | writer.uint32(8).int64(message.seconds); 122 | } 123 | if (message.nanos !== 0) { 124 | writer.uint32(16).int32(message.nanos); 125 | } 126 | return writer; 127 | }, 128 | 129 | decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { 130 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 131 | let end = length === undefined ? reader.len : reader.pos + length; 132 | const message = createBaseTimestamp(); 133 | while (reader.pos < end) { 134 | const tag = reader.uint32(); 135 | switch (tag >>> 3) { 136 | case 1: 137 | message.seconds = longToNumber(reader.int64() as Long); 138 | break; 139 | case 2: 140 | message.nanos = reader.int32(); 141 | break; 142 | default: 143 | reader.skipType(tag & 7); 144 | break; 145 | } 146 | } 147 | return message; 148 | }, 149 | 150 | fromJSON(object: any): Timestamp { 151 | return { 152 | seconds: isSet(object.seconds) ? Number(object.seconds) : 0, 153 | nanos: isSet(object.nanos) ? Number(object.nanos) : 0, 154 | }; 155 | }, 156 | 157 | toJSON(message: Timestamp): unknown { 158 | const obj: any = {}; 159 | message.seconds !== undefined && (obj.seconds = Math.round(message.seconds)); 160 | message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); 161 | return obj; 162 | }, 163 | 164 | create, I>>(base?: I): Timestamp { 165 | return Timestamp.fromPartial(base ?? {}); 166 | }, 167 | 168 | fromPartial, I>>(object: I): Timestamp { 169 | const message = createBaseTimestamp(); 170 | message.seconds = object.seconds ?? 0; 171 | message.nanos = object.nanos ?? 0; 172 | return message; 173 | }, 174 | }; 175 | 176 | declare var self: any | undefined; 177 | declare var window: any | undefined; 178 | declare var global: any | undefined; 179 | var tsProtoGlobalThis: any = (() => { 180 | if (typeof globalThis !== "undefined") { 181 | return globalThis; 182 | } 183 | if (typeof self !== "undefined") { 184 | return self; 185 | } 186 | if (typeof window !== "undefined") { 187 | return window; 188 | } 189 | if (typeof global !== "undefined") { 190 | return global; 191 | } 192 | throw "Unable to locate global object"; 193 | })(); 194 | 195 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 196 | 197 | export type DeepPartial = T extends Builtin ? T 198 | : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> 199 | : T extends {} ? { [K in keyof T]?: DeepPartial } 200 | : Partial; 201 | 202 | type KeysOfUnion = T extends T ? keyof T : never; 203 | export type Exact = P extends Builtin ? P 204 | : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; 205 | 206 | function longToNumber(long: Long): number { 207 | if (long.gt(Number.MAX_SAFE_INTEGER)) { 208 | throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); 209 | } 210 | return long.toNumber(); 211 | } 212 | 213 | if (_m0.util.Long !== Long) { 214 | _m0.util.Long = Long as any; 215 | _m0.configure(); 216 | } 217 | 218 | function isSet(value: any): boolean { 219 | return value !== null && value !== undefined; 220 | } -------------------------------------------------------------------------------- /src/jito/searcher-client.ts: -------------------------------------------------------------------------------- 1 | import {Keypair} from '@solana/web3.js'; 2 | import { 3 | ChannelCredentials, 4 | ChannelOptions, 5 | ClientReadableStream, 6 | ServiceError, 7 | status, 8 | } from '@grpc/grpc-js'; 9 | 10 | import {BundleResult} from './block-eng-bundle'; 11 | import { 12 | ConnectedLeadersResponse, 13 | GetTipAccountsResponse, 14 | NextScheduledLeaderResponse, 15 | SearcherServiceClient, 16 | SendBundleRequest, 17 | SendBundleResponse, 18 | SlotList, 19 | } from './searcher'; 20 | // import {authInterceptor, AuthProvider} from './auth'; 21 | import {Bundle} from './types'; 22 | 23 | export class SearcherClientError extends Error { 24 | constructor(public code: status, message: string, public details: string) { 25 | super(`${message}${details ? `: ${details}` : ''}`); 26 | this.name = 'SearcherClientError'; 27 | } 28 | } 29 | 30 | export class SearcherClient { 31 | private client: SearcherServiceClient; 32 | private readonly retryOptions: Readonly<{ 33 | maxRetries: number; 34 | baseDelay: number; 35 | maxDelay: number; 36 | factor: number; 37 | }>; 38 | 39 | constructor(client: SearcherServiceClient) { 40 | this.client = client; 41 | this.retryOptions = Object.freeze({ 42 | maxRetries: 3, 43 | baseDelay: 1000, 44 | maxDelay: 10000, 45 | factor: 2, 46 | }); 47 | } 48 | 49 | private handleError(e: ServiceError): never { 50 | const errorDetails = e.details || 'No additional details provided'; 51 | 52 | switch (e.code) { 53 | case status.OK: 54 | throw new SearcherClientError(e.code, 'Unexpected OK status in error', errorDetails); 55 | case status.CANCELLED: 56 | throw new SearcherClientError(e.code, 'The operation was cancelled', errorDetails); 57 | case status.UNKNOWN: 58 | throw new SearcherClientError(e.code, 'Unknown error', errorDetails); 59 | case status.INVALID_ARGUMENT: 60 | throw new SearcherClientError(e.code, 'Invalid argument provided', errorDetails); 61 | case status.DEADLINE_EXCEEDED: 62 | throw new SearcherClientError(e.code, 'Deadline exceeded', errorDetails); 63 | case status.NOT_FOUND: 64 | throw new SearcherClientError(e.code, 'Requested entity not found', errorDetails); 65 | case status.ALREADY_EXISTS: 66 | throw new SearcherClientError(e.code, 'The entity already exists', errorDetails); 67 | case status.PERMISSION_DENIED: 68 | throw new SearcherClientError(e.code, 'Lacking required permission', errorDetails); 69 | case status.RESOURCE_EXHAUSTED: 70 | throw new SearcherClientError(e.code, 'Resource has been exhausted', errorDetails); 71 | case status.FAILED_PRECONDITION: 72 | throw new SearcherClientError(e.code, 'Operation rejected, system not in correct state', errorDetails); 73 | case status.ABORTED: 74 | throw new SearcherClientError(e.code, 'The operation was aborted', errorDetails); 75 | case status.OUT_OF_RANGE: 76 | throw new SearcherClientError(e.code, 'Operation attempted past the valid range', errorDetails); 77 | case status.UNIMPLEMENTED: 78 | throw new SearcherClientError(e.code, 'Operation not implemented or supported', errorDetails); 79 | case status.INTERNAL: 80 | throw new SearcherClientError(e.code, 'Internal error', errorDetails); 81 | case status.UNAVAILABLE: 82 | let unavailableMessage = 'The service is currently unavailable'; 83 | if (errorDetails.includes('upstream connect error or disconnect/reset before headers')) { 84 | unavailableMessage = 'Service unavailable: Envoy overloaded'; 85 | } else if (errorDetails.toLowerCase().includes('dns resolution failed')) { 86 | unavailableMessage = 'Service unavailable: DNS resolution failed'; 87 | } else if (errorDetails.toLowerCase().includes('ssl handshake failed')) { 88 | unavailableMessage = 'Service unavailable: SSL handshake failed'; 89 | } else if (errorDetails.toLowerCase().includes('connection refused')) { 90 | unavailableMessage = 'Service unavailable: Connection refused'; 91 | } else if (errorDetails.toLowerCase().includes('network unreachable')) { 92 | unavailableMessage = 'Service unavailable: Network is unreachable'; 93 | } else if (errorDetails.toLowerCase().includes('timeout')) { 94 | unavailableMessage = 'Service unavailable: Connection timed out'; 95 | } 96 | throw new SearcherClientError(e.code, unavailableMessage, errorDetails); 97 | case status.DATA_LOSS: 98 | throw new SearcherClientError(e.code, 'Unrecoverable data loss or corruption', errorDetails); 99 | case status.UNAUTHENTICATED: 100 | throw new SearcherClientError(e.code, 'Request not authenticated', errorDetails); 101 | default: 102 | throw new SearcherClientError(status.UNKNOWN, `Unexpected error: ${e.message}`, errorDetails); 103 | } 104 | } 105 | 106 | private async retryWithBackoff( 107 | operation: () => Promise, 108 | retries = 0 109 | ): Promise { 110 | try { 111 | return await operation(); 112 | } catch (error) { 113 | if (retries >= this.retryOptions.maxRetries || !this.isRetryableError(error)) { 114 | throw error; 115 | } 116 | 117 | const delay = Math.min( 118 | this.retryOptions.baseDelay * Math.pow(this.retryOptions.factor, retries), 119 | this.retryOptions.maxDelay 120 | ); 121 | console.warn(`Operation failed. Retrying in ${delay}ms... (Attempt ${retries + 1} of ${this.retryOptions.maxRetries})`); 122 | await new Promise(resolve => setTimeout(resolve, delay)); 123 | 124 | return this.retryWithBackoff(operation, retries + 1); 125 | } 126 | } 127 | 128 | private isRetryableError(error: any): boolean { 129 | if (error instanceof SearcherClientError) { 130 | if (error.code === status.UNAVAILABLE) { 131 | // Don't retry certain types of UNAVAILABLE errors 132 | const nonRetryableMessages = [ 133 | 'Service unavailable: DNS resolution failed', 134 | 'Service unavailable: SSL handshake failed' 135 | ]; 136 | return !nonRetryableMessages.some(msg => error.message.includes(msg)); 137 | } 138 | const retryableCodes = [ 139 | status.UNAVAILABLE, 140 | status.RESOURCE_EXHAUSTED, 141 | status.DEADLINE_EXCEEDED, 142 | ]; 143 | return retryableCodes.includes(error.code); 144 | } 145 | return false; 146 | } 147 | 148 | /** 149 | * Submits a bundle to the block-engine. 150 | * 151 | * @param bundle - The Bundle object to be sent. 152 | * @returns A Promise that resolves to the bundle's UUID (string) on successful submission. 153 | * @throws A ServiceError if there's an issue with the server while sending the bundle. 154 | */ 155 | async sendBundle(bundle: Bundle): Promise { 156 | return this.retryWithBackoff(() => { 157 | return new Promise((resolve, reject) => { 158 | this.client.sendBundle( 159 | { bundle } as SendBundleRequest, 160 | (e: ServiceError | null, resp: SendBundleResponse) => { 161 | if (e) { 162 | reject(this.handleError(e)); 163 | } else { 164 | resolve(resp.uuid); 165 | } 166 | } 167 | ); 168 | }); 169 | }); 170 | } 171 | 172 | /** 173 | * Retrieves tip accounts from the server. 174 | * 175 | * @returns A Promise that resolves to an array of account strings (usually public keys). 176 | * @throws A ServiceError if there's an issue with the server while fetching tip accounts. 177 | */ 178 | async getTipAccounts(): Promise { 179 | return this.retryWithBackoff(() => { 180 | return new Promise((resolve, reject) => { 181 | this.client.getTipAccounts( 182 | {}, 183 | (e: ServiceError | null, resp: GetTipAccountsResponse) => { 184 | if (e) { 185 | reject(this.handleError(e)); 186 | } else { 187 | resolve(resp.accounts); 188 | } 189 | } 190 | ); 191 | }); 192 | }); 193 | } 194 | 195 | /** 196 | * Retrieves connected leaders (validators) from the server. 197 | * 198 | * @returns A Promise that resolves to a map, where keys are validator identity keys (usually public keys), and values are SlotList objects. 199 | * @throws A ServiceError if there's an issue with the server while fetching connected leaders. 200 | */ 201 | async getConnectedLeaders(): Promise<{[key: string]: SlotList}> { 202 | return this.retryWithBackoff(() => { 203 | return new Promise((resolve, reject) => { 204 | this.client.getConnectedLeaders( 205 | {}, 206 | async (e: ServiceError | null, resp: ConnectedLeadersResponse) => { 207 | if (e) { 208 | reject(this.handleError(e)); 209 | } else { 210 | resolve(resp.connectedValidators); 211 | } 212 | } 213 | ); 214 | }); 215 | }); 216 | } 217 | 218 | /** 219 | * Returns the next scheduled leader connected to the block-engine. 220 | * 221 | * @returns A Promise that resolves with an object containing: 222 | * - currentSlot: The current slot number the backend is on 223 | * - nextLeaderSlot: The slot number of the next scheduled leader 224 | * - nextLeaderIdentity: The identity of the next scheduled leader 225 | * @throws A ServiceError if there's an issue with the server while fetching the next scheduled leader. 226 | */ 227 | async getNextScheduledLeader(): Promise<{ 228 | currentSlot: number; 229 | nextLeaderSlot: number; 230 | nextLeaderIdentity: string; 231 | }> { 232 | return this.retryWithBackoff(() => { 233 | return new Promise((resolve, reject) => { 234 | this.client.getNextScheduledLeader( 235 | { 236 | regions: [], 237 | }, 238 | async (e: ServiceError | null, resp: NextScheduledLeaderResponse) => { 239 | if (e) { 240 | reject(this.handleError(e)); 241 | } else { 242 | resolve(resp); 243 | } 244 | } 245 | ); 246 | }); 247 | }); 248 | } 249 | 250 | /** 251 | * Triggers the provided callback on BundleResult updates. 252 | * 253 | * @param successCallback - A callback function that receives the BundleResult updates 254 | * @param errorCallback - A callback function that receives the stream error (Error) 255 | * @returns A function to cancel the subscription 256 | */ 257 | onBundleResult( 258 | successCallback: (bundleResult: BundleResult) => void, 259 | errorCallback: (e: Error) => void 260 | ): () => void { 261 | const stream: ClientReadableStream = 262 | this.client.subscribeBundleResults({}); 263 | 264 | stream.on('readable', () => { 265 | const msg = stream.read(1); 266 | if (msg) { 267 | successCallback(msg); 268 | } 269 | }); 270 | stream.on('error', e => { 271 | errorCallback(new Error(`Stream error: ${e.message}`)); 272 | }); 273 | 274 | return () => stream.cancel(); 275 | } 276 | 277 | /** 278 | * Yields on bundle results. 279 | * 280 | * @param onError - A callback function that receives the stream error (Error) 281 | * @returns An async generator that yields BundleResult updates 282 | */ 283 | async *bundleResults( 284 | onError: (e: Error) => void 285 | ): AsyncGenerator { 286 | const stream: ClientReadableStream = 287 | this.client.subscribeBundleResults({}); 288 | 289 | stream.on('error', e => { 290 | onError(e); 291 | }); 292 | 293 | for await (const bundleResult of stream) { 294 | yield bundleResult; 295 | } 296 | } 297 | } 298 | 299 | /** 300 | * Creates and returns a SearcherClient instance. 301 | * 302 | * @param url - The URL of the SearcherService 303 | * @param authKeypair - Optional Keypair authorized for the block engine 304 | * @param grpcOptions - Optional configuration options for the gRPC client 305 | * @returns SearcherClient - An instance of the SearcherClient 306 | */ 307 | // export const searcherClient = ( 308 | // url: string, 309 | // authKeypair?: Keypair, 310 | // grpcOptions?: Partial 311 | // ): SearcherClient => { 312 | // if (authKeypair) { 313 | // const authProvider = new AuthProvider( 314 | // new AuthServiceClient(url, ChannelCredentials.createSsl()), 315 | // authKeypair 316 | // ); 317 | // const client = new SearcherServiceClient( 318 | // url, 319 | // ChannelCredentials.createSsl(), 320 | // {interceptors: [authInterceptor(authProvider)], ...grpcOptions} 321 | // ); 322 | // return new SearcherClient(client); 323 | // } else { 324 | // return new SearcherClient( 325 | // new SearcherServiceClient( 326 | // url, 327 | // ChannelCredentials.createSsl(), 328 | // grpcOptions 329 | // ) 330 | // ); 331 | // } 332 | // }; -------------------------------------------------------------------------------- /src/pumpswap.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Commitment, 3 | Connection, 4 | Finality, 5 | Keypair, 6 | PublicKey, 7 | Transaction, 8 | TransactionInstruction, 9 | SystemProgram, 10 | LAMPORTS_PER_SOL, 11 | ComputeBudgetProgram, 12 | TransactionMessage, 13 | VersionedTransaction 14 | } from "@solana/web3.js"; 15 | import { Program, Provider } from "@coral-xyz/anchor"; 16 | import { 17 | createAssociatedTokenAccountInstruction, 18 | getAccount, 19 | getAssociatedTokenAddress, 20 | getOrCreateAssociatedTokenAccount, 21 | getAssociatedTokenAddressSync, 22 | createAssociatedTokenAccountIdempotentInstruction 23 | } from "@solana/spl-token"; 24 | import { PumpSwap, IDL } from "./IDL/index"; 25 | import { connection, wallet_1 } from './constants'; 26 | import { sendNozomiTx } from './nozomi/tx-submission'; 27 | import { sendBundle } from './jito'; 28 | import {getBuyTokenAmount, 29 | calculateWithSlippageBuy, 30 | getPumpSwapPool} from "./pool"; 31 | import { getSPLBalance, logger } from "./utils"; 32 | 33 | // Define static public keys 34 | const PUMP_AMM_PROGRAM_ID: PublicKey = new PublicKey('pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA'); 35 | const ASSOCIATED_TOKEN_PROGRAM_ID: PublicKey = new PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'); 36 | const TOKEN_PROGRAM_ID: PublicKey = new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'); 37 | const WSOL_TOKEN_ACCOUNT: PublicKey = new PublicKey('So11111111111111111111111111111111111111112'); 38 | const global = new PublicKey('ADyA8hdefvWN2dbGGWFotbzWxrAvLW83WG6QCVXvJKqw'); 39 | const eventAuthority = new PublicKey('GS4CU59F31iL7aR2Q8zVS8DRrcRnXX1yjQ66TqNVQnaR'); 40 | const feeRecipient = new PublicKey('62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV'); 41 | const feeRecipientAta = new PublicKey('94qWNrtmfn42h3ZjUZwWvK1MEo9uVmmrBPd2hpNjYDjb'); 42 | const BUY_DISCRIMINATOR: Uint8Array = new Uint8Array([102,6,61,18,1,218,235,234]); 43 | const SELL_DISCRIMINATOR: Uint8Array = new Uint8Array([51,230,133,164,1,127,131,173]); 44 | 45 | 46 | export const DEFAULT_DECIMALS = 6; 47 | 48 | export class PumpSwapSDK { 49 | public program: Program; 50 | public connection: Connection; 51 | constructor() { 52 | // this.program = new Program(IDL as PumpSwap, provider); 53 | // this.connection = this.program.provider.connection; 54 | } 55 | public async buy(mint:PublicKey, user:PublicKey, solToBuy:number){ 56 | const slippage = 0.3; // Default: 30% 57 | const bought_token_amount = await getBuyTokenAmount(BigInt(solToBuy*LAMPORTS_PER_SOL), mint); 58 | logger.info( 59 | { 60 | status:`finding pumpswap pool for ${mint}` 61 | } 62 | ) 63 | const pool = await getPumpSwapPool(mint) 64 | const pumpswap_buy_tx = await this.createBuyInstruction(pool, user, mint, bought_token_amount, BigInt(Math.floor(solToBuy*(1+slippage)*LAMPORTS_PER_SOL))); 65 | const ata = getAssociatedTokenAddressSync(mint, user); 66 | const ix_list:any[] =[ 67 | ...[ 68 | ComputeBudgetProgram.setComputeUnitLimit({ 69 | units: 300000, 70 | }), 71 | ComputeBudgetProgram.setComputeUnitPrice({ 72 | microLamports: 696969 73 | }) 74 | ], 75 | 76 | createAssociatedTokenAccountIdempotentInstruction( 77 | wallet_1.publicKey, 78 | ata, 79 | wallet_1.publicKey, 80 | mint 81 | ), 82 | pumpswap_buy_tx 83 | ] 84 | 85 | const latestBlockhash = await connection.getLatestBlockhash(); 86 | 87 | const messageV0 = new TransactionMessage({ 88 | payerKey: wallet_1.publicKey, 89 | recentBlockhash: latestBlockhash.blockhash, 90 | instructions: ix_list, 91 | }).compileToV0Message(); 92 | const transaction = new VersionedTransaction(messageV0); 93 | transaction.sign([wallet_1]); 94 | // sendNozomiTx(ix_list, wallet_1, latestBlockhash, "PumpSwap", "buy"); 95 | sendBundle(false, latestBlockhash.blockhash, transaction, pool, wallet_1) 96 | } 97 | 98 | public async sell_exactAmount(mint:PublicKey, user:PublicKey, tokenAmount:number){ 99 | const sell_token_amount = tokenAmount; 100 | logger.info( 101 | { 102 | status:`finding pumpswap pool for ${mint}` 103 | } 104 | ) 105 | const pool = await getPumpSwapPool(mint); 106 | const pumpswap_buy_tx = await this.createSellInstruction(await getPumpSwapPool(mint), user, mint, BigInt(Math.floor(sell_token_amount*10**6)), BigInt(0)); 107 | const ata = getAssociatedTokenAddressSync(mint, user); 108 | const ix_list:any[] =[ 109 | ...[ 110 | ComputeBudgetProgram.setComputeUnitLimit({ 111 | units: 100000, 112 | }), 113 | ComputeBudgetProgram.setComputeUnitPrice({ 114 | microLamports: 696969 115 | }) 116 | ], 117 | 118 | createAssociatedTokenAccountIdempotentInstruction( 119 | wallet_1.publicKey, 120 | ata, 121 | wallet_1.publicKey, 122 | mint 123 | ), 124 | pumpswap_buy_tx 125 | ] 126 | 127 | const latestBlockhash = await connection.getLatestBlockhash(); 128 | const messageV0 = new TransactionMessage({ 129 | payerKey: wallet_1.publicKey, 130 | recentBlockhash: latestBlockhash.blockhash, 131 | instructions: ix_list, 132 | }).compileToV0Message(); 133 | const transaction = new VersionedTransaction(messageV0); 134 | transaction.sign([wallet_1]); 135 | //sendNozomiTx(ix_list, wallet_1, latestBlockhash, "PumpSwap", "sell"); 136 | sendBundle(false, latestBlockhash.blockhash, transaction, pool, wallet_1) 137 | } 138 | public async sell_percentage(mint:PublicKey, user:PublicKey, percentage_to_sell:number){ 139 | const holding_token_amount = await getSPLBalance(connection, mint, user); 140 | const sell_token_amount = percentage_to_sell * holding_token_amount; 141 | logger.info( 142 | { 143 | status:`finding pumpswap pool for ${mint}` 144 | } 145 | ) 146 | const pool = await getPumpSwapPool(mint); 147 | const pumpswap_buy_tx = await this.createSellInstruction(pool, user, mint, BigInt(Math.floor(sell_token_amount*10**6)), BigInt(0)); 148 | const ata = getAssociatedTokenAddressSync(mint, user); 149 | const ix_list:any[] =[ 150 | ...[ 151 | ComputeBudgetProgram.setComputeUnitLimit({ 152 | units: 100000, 153 | }), 154 | ComputeBudgetProgram.setComputeUnitPrice({ 155 | microLamports: 696969 156 | }) 157 | ], 158 | 159 | createAssociatedTokenAccountIdempotentInstruction( 160 | wallet_1.publicKey, 161 | ata, 162 | wallet_1.publicKey, 163 | mint 164 | ), 165 | pumpswap_buy_tx 166 | ] 167 | 168 | const latestBlockhash = await connection.getLatestBlockhash(); 169 | const messageV0 = new TransactionMessage({ 170 | payerKey: wallet_1.publicKey, 171 | recentBlockhash: latestBlockhash.blockhash, 172 | instructions: ix_list, 173 | }).compileToV0Message(); 174 | const transaction = new VersionedTransaction(messageV0); 175 | transaction.sign([wallet_1]); 176 | //sendNozomiTx(ix_list, wallet_1, latestBlockhash, "PumpSwap", "sell"); 177 | sendBundle(false, latestBlockhash.blockhash, transaction, pool, wallet_1) 178 | } 179 | async createBuyInstruction( 180 | poolId: PublicKey, 181 | user: PublicKey, 182 | mint: PublicKey, 183 | baseAmountOut: bigint, // Use bigint for u64 184 | maxQuoteAmountIn: bigint // Use bigint for u64 185 | ): Promise { 186 | 187 | // Compute associated token account addresses 188 | const userBaseTokenAccount = await getAssociatedTokenAddress(mint, user); 189 | const userQuoteTokenAccount = await getAssociatedTokenAddress(WSOL_TOKEN_ACCOUNT, user); 190 | const poolBaseTokenAccount = await getAssociatedTokenAddress(mint, poolId, true); 191 | 192 | const poolQuoteTokenAccount = await getAssociatedTokenAddress(WSOL_TOKEN_ACCOUNT, poolId, true); 193 | 194 | // Define the accounts for the instruction 195 | const accounts = [ 196 | { pubkey: poolId, isSigner: false, isWritable: false }, // pool_id (readonly) 197 | { pubkey: user, isSigner: true, isWritable: true }, // user (signer) 198 | { pubkey: global, isSigner: false, isWritable: false }, // global (readonly) 199 | { pubkey: mint, isSigner: false, isWritable: false }, // mint (readonly) 200 | { pubkey: WSOL_TOKEN_ACCOUNT, isSigner: false, isWritable: false }, // WSOL_TOKEN_ACCOUNT (readonly) 201 | { pubkey: userBaseTokenAccount, isSigner: false, isWritable: true }, // user_base_token_account 202 | { pubkey: userQuoteTokenAccount, isSigner: false, isWritable: true }, // user_quote_token_account 203 | { pubkey: poolBaseTokenAccount, isSigner: false, isWritable: true }, // pool_base_token_account 204 | { pubkey: poolQuoteTokenAccount, isSigner: false, isWritable: true }, // pool_quote_token_account 205 | { pubkey: feeRecipient, isSigner: false, isWritable: false }, // fee_recipient (readonly) 206 | { pubkey: feeRecipientAta, isSigner: false, isWritable: true }, // fee_recipient_ata 207 | { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // TOKEN_PROGRAM_ID (readonly) 208 | { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // TOKEN_PROGRAM_ID (readonly, duplicated as in Rust) 209 | { pubkey: SystemProgram.programId, isSigner: false, isWritable: false }, // System Program (readonly) 210 | { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly) 211 | { pubkey: eventAuthority, isSigner: false, isWritable: false }, // event_authority (readonly) 212 | { pubkey: PUMP_AMM_PROGRAM_ID, isSigner: false, isWritable: false }, // PUMP_AMM_PROGRAM_ID (readonly) 213 | ]; 214 | 215 | // Pack the instruction data: discriminator (8 bytes) + base_amount_in (8 bytes) + min_quote_amount_out (8 bytes) 216 | const data = Buffer.alloc(8 + 8 + 8); // 24 bytes total 217 | data.set(BUY_DISCRIMINATOR, 0); 218 | data.writeBigUInt64LE(BigInt(baseAmountOut), 8); // Write base_amount_out as little-endian u64 219 | data.writeBigUInt64LE(BigInt(maxQuoteAmountIn), 16); // Write max_quote_amount_in as little-endian u64 220 | 221 | // Create the transaction instruction 222 | return new TransactionInstruction({ 223 | keys: accounts, 224 | programId: PUMP_AMM_PROGRAM_ID, 225 | data: data, 226 | }); 227 | } 228 | 229 | async createSellInstruction( 230 | poolId: PublicKey, 231 | user: PublicKey, 232 | mint: PublicKey, 233 | baseAmountIn: bigint, // Use bigint for u64 234 | minQuoteAmountOut: bigint // Use bigint for u64 235 | ): Promise { 236 | // Compute associated token account addresses 237 | const userBaseTokenAccount = await getAssociatedTokenAddress(mint, user); 238 | const userQuoteTokenAccount = await getAssociatedTokenAddress(WSOL_TOKEN_ACCOUNT, user); 239 | const poolBaseTokenAccount = await getAssociatedTokenAddress(mint, poolId, true); 240 | const poolQuoteTokenAccount = await getAssociatedTokenAddress(WSOL_TOKEN_ACCOUNT, poolId, true); 241 | 242 | // Define the accounts for the instruction 243 | const accounts = [ 244 | { pubkey: poolId, isSigner: false, isWritable: false }, // pool_id (readonly) 245 | { pubkey: user, isSigner: true, isWritable: true }, // user (signer) 246 | { pubkey: global, isSigner: false, isWritable: false }, // global (readonly) 247 | { pubkey: mint, isSigner: false, isWritable: false }, // mint (readonly) 248 | { pubkey: WSOL_TOKEN_ACCOUNT, isSigner: false, isWritable: false }, // WSOL_TOKEN_ACCOUNT (readonly) 249 | { pubkey: userBaseTokenAccount, isSigner: false, isWritable: true }, // user_base_token_account 250 | { pubkey: userQuoteTokenAccount, isSigner: false, isWritable: true }, // user_quote_token_account 251 | { pubkey: poolBaseTokenAccount, isSigner: false, isWritable: true }, // pool_base_token_account 252 | { pubkey: poolQuoteTokenAccount, isSigner: false, isWritable: true }, // pool_quote_token_account 253 | { pubkey: feeRecipient, isSigner: false, isWritable: false }, // fee_recipient (readonly) 254 | { pubkey: feeRecipientAta, isSigner: false, isWritable: true }, // fee_recipient_ata 255 | { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // TOKEN_PROGRAM_ID (readonly) 256 | { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // TOKEN_PROGRAM_ID (readonly, duplicated as in Rust) 257 | { pubkey: SystemProgram.programId, isSigner: false, isWritable: false }, // System Program (readonly) 258 | { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly) 259 | { pubkey: eventAuthority, isSigner: false, isWritable: false }, // event_authority (readonly) 260 | { pubkey: PUMP_AMM_PROGRAM_ID, isSigner: false, isWritable: false }, // PUMP_AMM_PROGRAM_ID (readonly) 261 | ]; 262 | 263 | // Pack the instruction data: discriminator (8 bytes) + base_amount_in (8 bytes) + min_quote_amount_out (8 bytes) 264 | const data = Buffer.alloc(8 + 8 + 8); // 24 bytes total 265 | data.set(SELL_DISCRIMINATOR, 0); 266 | data.writeBigUInt64LE(BigInt(baseAmountIn), 8); // Write base_amount_in as little-endian u64 267 | data.writeBigUInt64LE(BigInt(minQuoteAmountOut), 16); // Write min_quote_amount_out as little-endian u64 268 | 269 | // Create the transaction instruction 270 | return new TransactionInstruction({ 271 | keys: accounts, 272 | programId: PUMP_AMM_PROGRAM_ID, 273 | data: data, 274 | }); 275 | } 276 | } -------------------------------------------------------------------------------- /src/jito/packet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Long from "long"; 3 | import _m0 from "protobufjs/minimal"; 4 | 5 | export const protobufPackage = "packet"; 6 | 7 | export interface PacketBatch { 8 | packets: Packet[]; 9 | } 10 | 11 | export interface Packet { 12 | data: Uint8Array; 13 | meta: Meta | undefined; 14 | } 15 | 16 | export interface Meta { 17 | size: number; 18 | addr: string; 19 | port: number; 20 | flags: PacketFlags | undefined; 21 | senderStake: number; 22 | } 23 | 24 | export interface PacketFlags { 25 | discard: boolean; 26 | forwarded: boolean; 27 | repair: boolean; 28 | simpleVoteTx: boolean; 29 | tracerPacket: boolean; 30 | } 31 | 32 | function createBasePacketBatch(): PacketBatch { 33 | return { packets: [] }; 34 | } 35 | 36 | export const PacketBatch = { 37 | encode(message: PacketBatch, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 38 | for (const v of message.packets) { 39 | Packet.encode(v!, writer.uint32(10).fork()).ldelim(); 40 | } 41 | return writer; 42 | }, 43 | 44 | decode(input: _m0.Reader | Uint8Array, length?: number): PacketBatch { 45 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 46 | let end = length === undefined ? reader.len : reader.pos + length; 47 | const message = createBasePacketBatch(); 48 | while (reader.pos < end) { 49 | const tag = reader.uint32(); 50 | switch (tag >>> 3) { 51 | case 1: 52 | message.packets.push(Packet.decode(reader, reader.uint32())); 53 | break; 54 | default: 55 | reader.skipType(tag & 7); 56 | break; 57 | } 58 | } 59 | return message; 60 | }, 61 | 62 | fromJSON(object: any): PacketBatch { 63 | return { packets: Array.isArray(object?.packets) ? object.packets.map((e: any) => Packet.fromJSON(e)) : [] }; 64 | }, 65 | 66 | toJSON(message: PacketBatch): unknown { 67 | const obj: any = {}; 68 | if (message.packets) { 69 | obj.packets = message.packets.map((e) => e ? Packet.toJSON(e) : undefined); 70 | } else { 71 | obj.packets = []; 72 | } 73 | return obj; 74 | }, 75 | 76 | create, I>>(base?: I): PacketBatch { 77 | return PacketBatch.fromPartial(base ?? {}); 78 | }, 79 | 80 | fromPartial, I>>(object: I): PacketBatch { 81 | const message = createBasePacketBatch(); 82 | message.packets = object.packets?.map((e) => Packet.fromPartial(e)) || []; 83 | return message; 84 | }, 85 | }; 86 | 87 | function createBasePacket(): Packet { 88 | return { data: new Uint8Array(), meta: undefined }; 89 | } 90 | 91 | export const Packet = { 92 | encode(message: Packet, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 93 | if (message.data.length !== 0) { 94 | writer.uint32(10).bytes(message.data); 95 | } 96 | if (message.meta !== undefined) { 97 | Meta.encode(message.meta, writer.uint32(18).fork()).ldelim(); 98 | } 99 | return writer; 100 | }, 101 | 102 | decode(input: _m0.Reader | Uint8Array, length?: number): Packet { 103 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 104 | let end = length === undefined ? reader.len : reader.pos + length; 105 | const message = createBasePacket(); 106 | while (reader.pos < end) { 107 | const tag = reader.uint32(); 108 | switch (tag >>> 3) { 109 | case 1: 110 | message.data = reader.bytes(); 111 | break; 112 | case 2: 113 | message.meta = Meta.decode(reader, reader.uint32()); 114 | break; 115 | default: 116 | reader.skipType(tag & 7); 117 | break; 118 | } 119 | } 120 | return message; 121 | }, 122 | 123 | fromJSON(object: any): Packet { 124 | return { 125 | data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), 126 | meta: isSet(object.meta) ? Meta.fromJSON(object.meta) : undefined, 127 | }; 128 | }, 129 | 130 | toJSON(message: Packet): unknown { 131 | const obj: any = {}; 132 | message.data !== undefined && 133 | (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); 134 | message.meta !== undefined && (obj.meta = message.meta ? Meta.toJSON(message.meta) : undefined); 135 | return obj; 136 | }, 137 | 138 | create, I>>(base?: I): Packet { 139 | return Packet.fromPartial(base ?? {}); 140 | }, 141 | 142 | fromPartial, I>>(object: I): Packet { 143 | const message = createBasePacket(); 144 | message.data = object.data ?? new Uint8Array(); 145 | message.meta = (object.meta !== undefined && object.meta !== null) ? Meta.fromPartial(object.meta) : undefined; 146 | return message; 147 | }, 148 | }; 149 | 150 | function createBaseMeta(): Meta { 151 | return { size: 0, addr: "", port: 0, flags: undefined, senderStake: 0 }; 152 | } 153 | 154 | export const Meta = { 155 | encode(message: Meta, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 156 | if (message.size !== 0) { 157 | writer.uint32(8).uint64(message.size); 158 | } 159 | if (message.addr !== "") { 160 | writer.uint32(18).string(message.addr); 161 | } 162 | if (message.port !== 0) { 163 | writer.uint32(24).uint32(message.port); 164 | } 165 | if (message.flags !== undefined) { 166 | PacketFlags.encode(message.flags, writer.uint32(34).fork()).ldelim(); 167 | } 168 | if (message.senderStake !== 0) { 169 | writer.uint32(40).uint64(message.senderStake); 170 | } 171 | return writer; 172 | }, 173 | 174 | decode(input: _m0.Reader | Uint8Array, length?: number): Meta { 175 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 176 | let end = length === undefined ? reader.len : reader.pos + length; 177 | const message = createBaseMeta(); 178 | while (reader.pos < end) { 179 | const tag = reader.uint32(); 180 | switch (tag >>> 3) { 181 | case 1: 182 | message.size = longToNumber(reader.uint64() as Long); 183 | break; 184 | case 2: 185 | message.addr = reader.string(); 186 | break; 187 | case 3: 188 | message.port = reader.uint32(); 189 | break; 190 | case 4: 191 | message.flags = PacketFlags.decode(reader, reader.uint32()); 192 | break; 193 | case 5: 194 | message.senderStake = longToNumber(reader.uint64() as Long); 195 | break; 196 | default: 197 | reader.skipType(tag & 7); 198 | break; 199 | } 200 | } 201 | return message; 202 | }, 203 | 204 | fromJSON(object: any): Meta { 205 | return { 206 | size: isSet(object.size) ? Number(object.size) : 0, 207 | addr: isSet(object.addr) ? String(object.addr) : "", 208 | port: isSet(object.port) ? Number(object.port) : 0, 209 | flags: isSet(object.flags) ? PacketFlags.fromJSON(object.flags) : undefined, 210 | senderStake: isSet(object.senderStake) ? Number(object.senderStake) : 0, 211 | }; 212 | }, 213 | 214 | toJSON(message: Meta): unknown { 215 | const obj: any = {}; 216 | message.size !== undefined && (obj.size = Math.round(message.size)); 217 | message.addr !== undefined && (obj.addr = message.addr); 218 | message.port !== undefined && (obj.port = Math.round(message.port)); 219 | message.flags !== undefined && (obj.flags = message.flags ? PacketFlags.toJSON(message.flags) : undefined); 220 | message.senderStake !== undefined && (obj.senderStake = Math.round(message.senderStake)); 221 | return obj; 222 | }, 223 | 224 | create, I>>(base?: I): Meta { 225 | return Meta.fromPartial(base ?? {}); 226 | }, 227 | 228 | fromPartial, I>>(object: I): Meta { 229 | const message = createBaseMeta(); 230 | message.size = object.size ?? 0; 231 | message.addr = object.addr ?? ""; 232 | message.port = object.port ?? 0; 233 | message.flags = (object.flags !== undefined && object.flags !== null) 234 | ? PacketFlags.fromPartial(object.flags) 235 | : undefined; 236 | message.senderStake = object.senderStake ?? 0; 237 | return message; 238 | }, 239 | }; 240 | 241 | function createBasePacketFlags(): PacketFlags { 242 | return { discard: false, forwarded: false, repair: false, simpleVoteTx: false, tracerPacket: false }; 243 | } 244 | 245 | export const PacketFlags = { 246 | encode(message: PacketFlags, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 247 | if (message.discard === true) { 248 | writer.uint32(8).bool(message.discard); 249 | } 250 | if (message.forwarded === true) { 251 | writer.uint32(16).bool(message.forwarded); 252 | } 253 | if (message.repair === true) { 254 | writer.uint32(24).bool(message.repair); 255 | } 256 | if (message.simpleVoteTx === true) { 257 | writer.uint32(32).bool(message.simpleVoteTx); 258 | } 259 | if (message.tracerPacket === true) { 260 | writer.uint32(40).bool(message.tracerPacket); 261 | } 262 | return writer; 263 | }, 264 | 265 | decode(input: _m0.Reader | Uint8Array, length?: number): PacketFlags { 266 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 267 | let end = length === undefined ? reader.len : reader.pos + length; 268 | const message = createBasePacketFlags(); 269 | while (reader.pos < end) { 270 | const tag = reader.uint32(); 271 | switch (tag >>> 3) { 272 | case 1: 273 | message.discard = reader.bool(); 274 | break; 275 | case 2: 276 | message.forwarded = reader.bool(); 277 | break; 278 | case 3: 279 | message.repair = reader.bool(); 280 | break; 281 | case 4: 282 | message.simpleVoteTx = reader.bool(); 283 | break; 284 | case 5: 285 | message.tracerPacket = reader.bool(); 286 | break; 287 | default: 288 | reader.skipType(tag & 7); 289 | break; 290 | } 291 | } 292 | return message; 293 | }, 294 | 295 | fromJSON(object: any): PacketFlags { 296 | return { 297 | discard: isSet(object.discard) ? Boolean(object.discard) : false, 298 | forwarded: isSet(object.forwarded) ? Boolean(object.forwarded) : false, 299 | repair: isSet(object.repair) ? Boolean(object.repair) : false, 300 | simpleVoteTx: isSet(object.simpleVoteTx) ? Boolean(object.simpleVoteTx) : false, 301 | tracerPacket: isSet(object.tracerPacket) ? Boolean(object.tracerPacket) : false, 302 | }; 303 | }, 304 | 305 | toJSON(message: PacketFlags): unknown { 306 | const obj: any = {}; 307 | message.discard !== undefined && (obj.discard = message.discard); 308 | message.forwarded !== undefined && (obj.forwarded = message.forwarded); 309 | message.repair !== undefined && (obj.repair = message.repair); 310 | message.simpleVoteTx !== undefined && (obj.simpleVoteTx = message.simpleVoteTx); 311 | message.tracerPacket !== undefined && (obj.tracerPacket = message.tracerPacket); 312 | return obj; 313 | }, 314 | 315 | create, I>>(base?: I): PacketFlags { 316 | return PacketFlags.fromPartial(base ?? {}); 317 | }, 318 | 319 | fromPartial, I>>(object: I): PacketFlags { 320 | const message = createBasePacketFlags(); 321 | message.discard = object.discard ?? false; 322 | message.forwarded = object.forwarded ?? false; 323 | message.repair = object.repair ?? false; 324 | message.simpleVoteTx = object.simpleVoteTx ?? false; 325 | message.tracerPacket = object.tracerPacket ?? false; 326 | return message; 327 | }, 328 | }; 329 | 330 | declare var self: any | undefined; 331 | declare var window: any | undefined; 332 | declare var global: any | undefined; 333 | var tsProtoGlobalThis: any = (() => { 334 | if (typeof globalThis !== "undefined") { 335 | return globalThis; 336 | } 337 | if (typeof self !== "undefined") { 338 | return self; 339 | } 340 | if (typeof window !== "undefined") { 341 | return window; 342 | } 343 | if (typeof global !== "undefined") { 344 | return global; 345 | } 346 | throw "Unable to locate global object"; 347 | })(); 348 | 349 | function bytesFromBase64(b64: string): Uint8Array { 350 | if (tsProtoGlobalThis.Buffer) { 351 | return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); 352 | } else { 353 | const bin = tsProtoGlobalThis.atob(b64); 354 | const arr = new Uint8Array(bin.length); 355 | for (let i = 0; i < bin.length; ++i) { 356 | arr[i] = bin.charCodeAt(i); 357 | } 358 | return arr; 359 | } 360 | } 361 | 362 | function base64FromBytes(arr: Uint8Array): string { 363 | if (tsProtoGlobalThis.Buffer) { 364 | return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); 365 | } else { 366 | const bin: string[] = []; 367 | arr.forEach((byte) => { 368 | bin.push(String.fromCharCode(byte)); 369 | }); 370 | return tsProtoGlobalThis.btoa(bin.join("")); 371 | } 372 | } 373 | 374 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 375 | 376 | export type DeepPartial = T extends Builtin ? T 377 | : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> 378 | : T extends {} ? { [K in keyof T]?: DeepPartial } 379 | : Partial; 380 | 381 | type KeysOfUnion = T extends T ? keyof T : never; 382 | export type Exact = P extends Builtin ? P 383 | : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; 384 | 385 | function longToNumber(long: Long): number { 386 | if (long.gt(Number.MAX_SAFE_INTEGER)) { 387 | throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); 388 | } 389 | return long.toNumber(); 390 | } 391 | 392 | if (_m0.util.Long !== Long) { 393 | _m0.util.Long = Long as any; 394 | _m0.configure(); 395 | } 396 | 397 | function isSet(value: any): boolean { 398 | return value !== null && value !== undefined; 399 | } -------------------------------------------------------------------------------- /src/jito/block-eng-bundle.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Long from "long"; 3 | import _m0 from "protobufjs/minimal"; 4 | import { Packet } from "./packet"; 5 | import { Header } from "./shared"; 6 | 7 | export const protobufPackage = "bundle"; 8 | 9 | export enum DroppedReason { 10 | BlockhashExpired = 0, 11 | /** PartiallyProcessed - One or more transactions in the bundle landed on-chain, invalidating the bundle. */ 12 | PartiallyProcessed = 1, 13 | /** NotFinalized - This indicates bundle was processed but not finalized. This could occur during forks. */ 14 | NotFinalized = 2, 15 | UNRECOGNIZED = -1, 16 | } 17 | 18 | export function droppedReasonFromJSON(object: any): DroppedReason { 19 | switch (object) { 20 | case 0: 21 | case "BlockhashExpired": 22 | return DroppedReason.BlockhashExpired; 23 | case 1: 24 | case "PartiallyProcessed": 25 | return DroppedReason.PartiallyProcessed; 26 | case 2: 27 | case "NotFinalized": 28 | return DroppedReason.NotFinalized; 29 | case -1: 30 | case "UNRECOGNIZED": 31 | default: 32 | return DroppedReason.UNRECOGNIZED; 33 | } 34 | } 35 | 36 | export function droppedReasonToJSON(object: DroppedReason): string { 37 | switch (object) { 38 | case DroppedReason.BlockhashExpired: 39 | return "BlockhashExpired"; 40 | case DroppedReason.PartiallyProcessed: 41 | return "PartiallyProcessed"; 42 | case DroppedReason.NotFinalized: 43 | return "NotFinalized"; 44 | case DroppedReason.UNRECOGNIZED: 45 | default: 46 | return "UNRECOGNIZED"; 47 | } 48 | } 49 | 50 | export interface Bundle { 51 | header: Header | undefined; 52 | packets: Packet[]; 53 | } 54 | 55 | export interface BundleUuid { 56 | bundle: Bundle | undefined; 57 | uuid: string; 58 | } 59 | 60 | /** 61 | * Indicates the bundle was accepted and forwarded to a validator. 62 | * NOTE: A single bundle may have multiple events emitted if forwarded to many validators. 63 | */ 64 | export interface Accepted { 65 | /** Slot at which bundle was forwarded. */ 66 | slot: number; 67 | /** Validator identity bundle was forwarded to. */ 68 | validatorIdentity: string; 69 | } 70 | 71 | /** Indicates the bundle was dropped and therefore not forwarded to any validator. */ 72 | export interface Rejected { 73 | stateAuctionBidRejected?: StateAuctionBidRejected | undefined; 74 | winningBatchBidRejected?: WinningBatchBidRejected | undefined; 75 | simulationFailure?: SimulationFailure | undefined; 76 | internalError?: InternalError | undefined; 77 | droppedBundle?: DroppedBundle | undefined; 78 | } 79 | 80 | /** 81 | * Indicates the bundle's bid was high enough to win its state auction. 82 | * However, not high enough relative to other state auction winners and therefore excluded from being forwarded. 83 | */ 84 | export interface WinningBatchBidRejected { 85 | /** Auction's unique identifier. */ 86 | auctionId: string; 87 | /** Bundle's simulated bid. */ 88 | simulatedBidLamports: number; 89 | msg?: string | undefined; 90 | } 91 | 92 | /** Indicates the bundle's bid was __not__ high enough to be included in its state auction's set of winners. */ 93 | export interface StateAuctionBidRejected { 94 | /** Auction's unique identifier. */ 95 | auctionId: string; 96 | /** Bundle's simulated bid. */ 97 | simulatedBidLamports: number; 98 | msg?: string | undefined; 99 | } 100 | 101 | /** Bundle dropped due to simulation failure. */ 102 | export interface SimulationFailure { 103 | /** Signature of the offending transaction. */ 104 | txSignature: string; 105 | msg?: string | undefined; 106 | } 107 | 108 | /** Bundle dropped due to an internal error. */ 109 | export interface InternalError { 110 | msg: string; 111 | } 112 | 113 | /** Bundle dropped (e.g. because no leader upcoming) */ 114 | export interface DroppedBundle { 115 | msg: string; 116 | } 117 | 118 | export interface Finalized { 119 | } 120 | 121 | export interface Processed { 122 | validatorIdentity: string; 123 | slot: number; 124 | /** / Index within the block. */ 125 | bundleIndex: number; 126 | } 127 | 128 | export interface Dropped { 129 | reason: DroppedReason; 130 | } 131 | 132 | export interface BundleResult { 133 | /** Bundle's Uuid. */ 134 | bundleId: string; 135 | /** Indicated accepted by the block-engine and forwarded to a jito-solana validator. */ 136 | accepted?: 137 | | Accepted 138 | | undefined; 139 | /** Rejected by the block-engine. */ 140 | rejected?: 141 | | Rejected 142 | | undefined; 143 | /** Reached finalized commitment level. */ 144 | finalized?: 145 | | Finalized 146 | | undefined; 147 | /** Reached a processed commitment level. */ 148 | processed?: 149 | | Processed 150 | | undefined; 151 | /** Was accepted and forwarded by the block-engine but never landed on-chain. */ 152 | dropped?: Dropped | undefined; 153 | } 154 | 155 | function createBaseBundle(): Bundle { 156 | return { header: undefined, packets: [] }; 157 | } 158 | 159 | export const Bundle = { 160 | encode(message: Bundle, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 161 | if (message.header !== undefined) { 162 | Header.encode(message.header, writer.uint32(18).fork()).ldelim(); 163 | } 164 | for (const v of message.packets) { 165 | Packet.encode(v!, writer.uint32(26).fork()).ldelim(); 166 | } 167 | return writer; 168 | }, 169 | 170 | decode(input: _m0.Reader | Uint8Array, length?: number): Bundle { 171 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 172 | let end = length === undefined ? reader.len : reader.pos + length; 173 | const message = createBaseBundle(); 174 | while (reader.pos < end) { 175 | const tag = reader.uint32(); 176 | switch (tag >>> 3) { 177 | case 2: 178 | message.header = Header.decode(reader, reader.uint32()); 179 | break; 180 | case 3: 181 | message.packets.push(Packet.decode(reader, reader.uint32())); 182 | break; 183 | default: 184 | reader.skipType(tag & 7); 185 | break; 186 | } 187 | } 188 | return message; 189 | }, 190 | 191 | fromJSON(object: any): Bundle { 192 | return { 193 | header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, 194 | packets: Array.isArray(object?.packets) ? object.packets.map((e: any) => Packet.fromJSON(e)) : [], 195 | }; 196 | }, 197 | 198 | toJSON(message: Bundle): unknown { 199 | const obj: any = {}; 200 | message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); 201 | if (message.packets) { 202 | obj.packets = message.packets.map((e) => e ? Packet.toJSON(e) : undefined); 203 | } else { 204 | obj.packets = []; 205 | } 206 | return obj; 207 | }, 208 | 209 | create, I>>(base?: I): Bundle { 210 | return Bundle.fromPartial(base ?? {}); 211 | }, 212 | 213 | fromPartial, I>>(object: I): Bundle { 214 | const message = createBaseBundle(); 215 | message.header = (object.header !== undefined && object.header !== null) 216 | ? Header.fromPartial(object.header) 217 | : undefined; 218 | message.packets = object.packets?.map((e) => Packet.fromPartial(e)) || []; 219 | return message; 220 | }, 221 | }; 222 | 223 | function createBaseBundleUuid(): BundleUuid { 224 | return { bundle: undefined, uuid: "" }; 225 | } 226 | 227 | export const BundleUuid = { 228 | encode(message: BundleUuid, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 229 | if (message.bundle !== undefined) { 230 | Bundle.encode(message.bundle, writer.uint32(10).fork()).ldelim(); 231 | } 232 | if (message.uuid !== "") { 233 | writer.uint32(18).string(message.uuid); 234 | } 235 | return writer; 236 | }, 237 | 238 | decode(input: _m0.Reader | Uint8Array, length?: number): BundleUuid { 239 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 240 | let end = length === undefined ? reader.len : reader.pos + length; 241 | const message = createBaseBundleUuid(); 242 | while (reader.pos < end) { 243 | const tag = reader.uint32(); 244 | switch (tag >>> 3) { 245 | case 1: 246 | message.bundle = Bundle.decode(reader, reader.uint32()); 247 | break; 248 | case 2: 249 | message.uuid = reader.string(); 250 | break; 251 | default: 252 | reader.skipType(tag & 7); 253 | break; 254 | } 255 | } 256 | return message; 257 | }, 258 | 259 | fromJSON(object: any): BundleUuid { 260 | return { 261 | bundle: isSet(object.bundle) ? Bundle.fromJSON(object.bundle) : undefined, 262 | uuid: isSet(object.uuid) ? String(object.uuid) : "", 263 | }; 264 | }, 265 | 266 | toJSON(message: BundleUuid): unknown { 267 | const obj: any = {}; 268 | message.bundle !== undefined && (obj.bundle = message.bundle ? Bundle.toJSON(message.bundle) : undefined); 269 | message.uuid !== undefined && (obj.uuid = message.uuid); 270 | return obj; 271 | }, 272 | 273 | create, I>>(base?: I): BundleUuid { 274 | return BundleUuid.fromPartial(base ?? {}); 275 | }, 276 | 277 | fromPartial, I>>(object: I): BundleUuid { 278 | const message = createBaseBundleUuid(); 279 | message.bundle = (object.bundle !== undefined && object.bundle !== null) 280 | ? Bundle.fromPartial(object.bundle) 281 | : undefined; 282 | message.uuid = object.uuid ?? ""; 283 | return message; 284 | }, 285 | }; 286 | 287 | function createBaseAccepted(): Accepted { 288 | return { slot: 0, validatorIdentity: "" }; 289 | } 290 | 291 | export const Accepted = { 292 | encode(message: Accepted, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 293 | if (message.slot !== 0) { 294 | writer.uint32(8).uint64(message.slot); 295 | } 296 | if (message.validatorIdentity !== "") { 297 | writer.uint32(18).string(message.validatorIdentity); 298 | } 299 | return writer; 300 | }, 301 | 302 | decode(input: _m0.Reader | Uint8Array, length?: number): Accepted { 303 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 304 | let end = length === undefined ? reader.len : reader.pos + length; 305 | const message = createBaseAccepted(); 306 | while (reader.pos < end) { 307 | const tag = reader.uint32(); 308 | switch (tag >>> 3) { 309 | case 1: 310 | message.slot = longToNumber(reader.uint64() as Long); 311 | break; 312 | case 2: 313 | message.validatorIdentity = reader.string(); 314 | break; 315 | default: 316 | reader.skipType(tag & 7); 317 | break; 318 | } 319 | } 320 | return message; 321 | }, 322 | 323 | fromJSON(object: any): Accepted { 324 | return { 325 | slot: isSet(object.slot) ? Number(object.slot) : 0, 326 | validatorIdentity: isSet(object.validatorIdentity) ? String(object.validatorIdentity) : "", 327 | }; 328 | }, 329 | 330 | toJSON(message: Accepted): unknown { 331 | const obj: any = {}; 332 | message.slot !== undefined && (obj.slot = Math.round(message.slot)); 333 | message.validatorIdentity !== undefined && (obj.validatorIdentity = message.validatorIdentity); 334 | return obj; 335 | }, 336 | 337 | create, I>>(base?: I): Accepted { 338 | return Accepted.fromPartial(base ?? {}); 339 | }, 340 | 341 | fromPartial, I>>(object: I): Accepted { 342 | const message = createBaseAccepted(); 343 | message.slot = object.slot ?? 0; 344 | message.validatorIdentity = object.validatorIdentity ?? ""; 345 | return message; 346 | }, 347 | }; 348 | 349 | function createBaseRejected(): Rejected { 350 | return { 351 | stateAuctionBidRejected: undefined, 352 | winningBatchBidRejected: undefined, 353 | simulationFailure: undefined, 354 | internalError: undefined, 355 | droppedBundle: undefined, 356 | }; 357 | } 358 | 359 | export const Rejected = { 360 | encode(message: Rejected, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 361 | if (message.stateAuctionBidRejected !== undefined) { 362 | StateAuctionBidRejected.encode(message.stateAuctionBidRejected, writer.uint32(10).fork()).ldelim(); 363 | } 364 | if (message.winningBatchBidRejected !== undefined) { 365 | WinningBatchBidRejected.encode(message.winningBatchBidRejected, writer.uint32(18).fork()).ldelim(); 366 | } 367 | if (message.simulationFailure !== undefined) { 368 | SimulationFailure.encode(message.simulationFailure, writer.uint32(26).fork()).ldelim(); 369 | } 370 | if (message.internalError !== undefined) { 371 | InternalError.encode(message.internalError, writer.uint32(34).fork()).ldelim(); 372 | } 373 | if (message.droppedBundle !== undefined) { 374 | DroppedBundle.encode(message.droppedBundle, writer.uint32(42).fork()).ldelim(); 375 | } 376 | return writer; 377 | }, 378 | 379 | decode(input: _m0.Reader | Uint8Array, length?: number): Rejected { 380 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 381 | let end = length === undefined ? reader.len : reader.pos + length; 382 | const message = createBaseRejected(); 383 | while (reader.pos < end) { 384 | const tag = reader.uint32(); 385 | switch (tag >>> 3) { 386 | case 1: 387 | message.stateAuctionBidRejected = StateAuctionBidRejected.decode(reader, reader.uint32()); 388 | break; 389 | case 2: 390 | message.winningBatchBidRejected = WinningBatchBidRejected.decode(reader, reader.uint32()); 391 | break; 392 | case 3: 393 | message.simulationFailure = SimulationFailure.decode(reader, reader.uint32()); 394 | break; 395 | case 4: 396 | message.internalError = InternalError.decode(reader, reader.uint32()); 397 | break; 398 | case 5: 399 | message.droppedBundle = DroppedBundle.decode(reader, reader.uint32()); 400 | break; 401 | default: 402 | reader.skipType(tag & 7); 403 | break; 404 | } 405 | } 406 | return message; 407 | }, 408 | 409 | fromJSON(object: any): Rejected { 410 | return { 411 | stateAuctionBidRejected: isSet(object.stateAuctionBidRejected) 412 | ? StateAuctionBidRejected.fromJSON(object.stateAuctionBidRejected) 413 | : undefined, 414 | winningBatchBidRejected: isSet(object.winningBatchBidRejected) 415 | ? WinningBatchBidRejected.fromJSON(object.winningBatchBidRejected) 416 | : undefined, 417 | simulationFailure: isSet(object.simulationFailure) 418 | ? SimulationFailure.fromJSON(object.simulationFailure) 419 | : undefined, 420 | internalError: isSet(object.internalError) ? InternalError.fromJSON(object.internalError) : undefined, 421 | droppedBundle: isSet(object.droppedBundle) ? DroppedBundle.fromJSON(object.droppedBundle) : undefined, 422 | }; 423 | }, 424 | 425 | toJSON(message: Rejected): unknown { 426 | const obj: any = {}; 427 | message.stateAuctionBidRejected !== undefined && (obj.stateAuctionBidRejected = message.stateAuctionBidRejected 428 | ? StateAuctionBidRejected.toJSON(message.stateAuctionBidRejected) 429 | : undefined); 430 | message.winningBatchBidRejected !== undefined && (obj.winningBatchBidRejected = message.winningBatchBidRejected 431 | ? WinningBatchBidRejected.toJSON(message.winningBatchBidRejected) 432 | : undefined); 433 | message.simulationFailure !== undefined && (obj.simulationFailure = message.simulationFailure 434 | ? SimulationFailure.toJSON(message.simulationFailure) 435 | : undefined); 436 | message.internalError !== undefined && 437 | (obj.internalError = message.internalError ? InternalError.toJSON(message.internalError) : undefined); 438 | message.droppedBundle !== undefined && 439 | (obj.droppedBundle = message.droppedBundle ? DroppedBundle.toJSON(message.droppedBundle) : undefined); 440 | return obj; 441 | }, 442 | 443 | create, I>>(base?: I): Rejected { 444 | return Rejected.fromPartial(base ?? {}); 445 | }, 446 | 447 | fromPartial, I>>(object: I): Rejected { 448 | const message = createBaseRejected(); 449 | message.stateAuctionBidRejected = 450 | (object.stateAuctionBidRejected !== undefined && object.stateAuctionBidRejected !== null) 451 | ? StateAuctionBidRejected.fromPartial(object.stateAuctionBidRejected) 452 | : undefined; 453 | message.winningBatchBidRejected = 454 | (object.winningBatchBidRejected !== undefined && object.winningBatchBidRejected !== null) 455 | ? WinningBatchBidRejected.fromPartial(object.winningBatchBidRejected) 456 | : undefined; 457 | message.simulationFailure = (object.simulationFailure !== undefined && object.simulationFailure !== null) 458 | ? SimulationFailure.fromPartial(object.simulationFailure) 459 | : undefined; 460 | message.internalError = (object.internalError !== undefined && object.internalError !== null) 461 | ? InternalError.fromPartial(object.internalError) 462 | : undefined; 463 | message.droppedBundle = (object.droppedBundle !== undefined && object.droppedBundle !== null) 464 | ? DroppedBundle.fromPartial(object.droppedBundle) 465 | : undefined; 466 | return message; 467 | }, 468 | }; 469 | 470 | function createBaseWinningBatchBidRejected(): WinningBatchBidRejected { 471 | return { auctionId: "", simulatedBidLamports: 0, msg: undefined }; 472 | } 473 | 474 | export const WinningBatchBidRejected = { 475 | encode(message: WinningBatchBidRejected, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 476 | if (message.auctionId !== "") { 477 | writer.uint32(10).string(message.auctionId); 478 | } 479 | if (message.simulatedBidLamports !== 0) { 480 | writer.uint32(16).uint64(message.simulatedBidLamports); 481 | } 482 | if (message.msg !== undefined) { 483 | writer.uint32(26).string(message.msg); 484 | } 485 | return writer; 486 | }, 487 | 488 | decode(input: _m0.Reader | Uint8Array, length?: number): WinningBatchBidRejected { 489 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 490 | let end = length === undefined ? reader.len : reader.pos + length; 491 | const message = createBaseWinningBatchBidRejected(); 492 | while (reader.pos < end) { 493 | const tag = reader.uint32(); 494 | switch (tag >>> 3) { 495 | case 1: 496 | message.auctionId = reader.string(); 497 | break; 498 | case 2: 499 | message.simulatedBidLamports = longToNumber(reader.uint64() as Long); 500 | break; 501 | case 3: 502 | message.msg = reader.string(); 503 | break; 504 | default: 505 | reader.skipType(tag & 7); 506 | break; 507 | } 508 | } 509 | return message; 510 | }, 511 | 512 | fromJSON(object: any): WinningBatchBidRejected { 513 | return { 514 | auctionId: isSet(object.auctionId) ? String(object.auctionId) : "", 515 | simulatedBidLamports: isSet(object.simulatedBidLamports) ? Number(object.simulatedBidLamports) : 0, 516 | msg: isSet(object.msg) ? String(object.msg) : undefined, 517 | }; 518 | }, 519 | 520 | toJSON(message: WinningBatchBidRejected): unknown { 521 | const obj: any = {}; 522 | message.auctionId !== undefined && (obj.auctionId = message.auctionId); 523 | message.simulatedBidLamports !== undefined && (obj.simulatedBidLamports = Math.round(message.simulatedBidLamports)); 524 | message.msg !== undefined && (obj.msg = message.msg); 525 | return obj; 526 | }, 527 | 528 | create, I>>(base?: I): WinningBatchBidRejected { 529 | return WinningBatchBidRejected.fromPartial(base ?? {}); 530 | }, 531 | 532 | fromPartial, I>>(object: I): WinningBatchBidRejected { 533 | const message = createBaseWinningBatchBidRejected(); 534 | message.auctionId = object.auctionId ?? ""; 535 | message.simulatedBidLamports = object.simulatedBidLamports ?? 0; 536 | message.msg = object.msg ?? undefined; 537 | return message; 538 | }, 539 | }; 540 | 541 | function createBaseStateAuctionBidRejected(): StateAuctionBidRejected { 542 | return { auctionId: "", simulatedBidLamports: 0, msg: undefined }; 543 | } 544 | 545 | export const StateAuctionBidRejected = { 546 | encode(message: StateAuctionBidRejected, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 547 | if (message.auctionId !== "") { 548 | writer.uint32(10).string(message.auctionId); 549 | } 550 | if (message.simulatedBidLamports !== 0) { 551 | writer.uint32(16).uint64(message.simulatedBidLamports); 552 | } 553 | if (message.msg !== undefined) { 554 | writer.uint32(26).string(message.msg); 555 | } 556 | return writer; 557 | }, 558 | 559 | decode(input: _m0.Reader | Uint8Array, length?: number): StateAuctionBidRejected { 560 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 561 | let end = length === undefined ? reader.len : reader.pos + length; 562 | const message = createBaseStateAuctionBidRejected(); 563 | while (reader.pos < end) { 564 | const tag = reader.uint32(); 565 | switch (tag >>> 3) { 566 | case 1: 567 | message.auctionId = reader.string(); 568 | break; 569 | case 2: 570 | message.simulatedBidLamports = longToNumber(reader.uint64() as Long); 571 | break; 572 | case 3: 573 | message.msg = reader.string(); 574 | break; 575 | default: 576 | reader.skipType(tag & 7); 577 | break; 578 | } 579 | } 580 | return message; 581 | }, 582 | 583 | fromJSON(object: any): StateAuctionBidRejected { 584 | return { 585 | auctionId: isSet(object.auctionId) ? String(object.auctionId) : "", 586 | simulatedBidLamports: isSet(object.simulatedBidLamports) ? Number(object.simulatedBidLamports) : 0, 587 | msg: isSet(object.msg) ? String(object.msg) : undefined, 588 | }; 589 | }, 590 | 591 | toJSON(message: StateAuctionBidRejected): unknown { 592 | const obj: any = {}; 593 | message.auctionId !== undefined && (obj.auctionId = message.auctionId); 594 | message.simulatedBidLamports !== undefined && (obj.simulatedBidLamports = Math.round(message.simulatedBidLamports)); 595 | message.msg !== undefined && (obj.msg = message.msg); 596 | return obj; 597 | }, 598 | 599 | create, I>>(base?: I): StateAuctionBidRejected { 600 | return StateAuctionBidRejected.fromPartial(base ?? {}); 601 | }, 602 | 603 | fromPartial, I>>(object: I): StateAuctionBidRejected { 604 | const message = createBaseStateAuctionBidRejected(); 605 | message.auctionId = object.auctionId ?? ""; 606 | message.simulatedBidLamports = object.simulatedBidLamports ?? 0; 607 | message.msg = object.msg ?? undefined; 608 | return message; 609 | }, 610 | }; 611 | 612 | function createBaseSimulationFailure(): SimulationFailure { 613 | return { txSignature: "", msg: undefined }; 614 | } 615 | 616 | export const SimulationFailure = { 617 | encode(message: SimulationFailure, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 618 | if (message.txSignature !== "") { 619 | writer.uint32(10).string(message.txSignature); 620 | } 621 | if (message.msg !== undefined) { 622 | writer.uint32(18).string(message.msg); 623 | } 624 | return writer; 625 | }, 626 | 627 | decode(input: _m0.Reader | Uint8Array, length?: number): SimulationFailure { 628 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 629 | let end = length === undefined ? reader.len : reader.pos + length; 630 | const message = createBaseSimulationFailure(); 631 | while (reader.pos < end) { 632 | const tag = reader.uint32(); 633 | switch (tag >>> 3) { 634 | case 1: 635 | message.txSignature = reader.string(); 636 | break; 637 | case 2: 638 | message.msg = reader.string(); 639 | break; 640 | default: 641 | reader.skipType(tag & 7); 642 | break; 643 | } 644 | } 645 | return message; 646 | }, 647 | 648 | fromJSON(object: any): SimulationFailure { 649 | return { 650 | txSignature: isSet(object.txSignature) ? String(object.txSignature) : "", 651 | msg: isSet(object.msg) ? String(object.msg) : undefined, 652 | }; 653 | }, 654 | 655 | toJSON(message: SimulationFailure): unknown { 656 | const obj: any = {}; 657 | message.txSignature !== undefined && (obj.txSignature = message.txSignature); 658 | message.msg !== undefined && (obj.msg = message.msg); 659 | return obj; 660 | }, 661 | 662 | create, I>>(base?: I): SimulationFailure { 663 | return SimulationFailure.fromPartial(base ?? {}); 664 | }, 665 | 666 | fromPartial, I>>(object: I): SimulationFailure { 667 | const message = createBaseSimulationFailure(); 668 | message.txSignature = object.txSignature ?? ""; 669 | message.msg = object.msg ?? undefined; 670 | return message; 671 | }, 672 | }; 673 | 674 | function createBaseInternalError(): InternalError { 675 | return { msg: "" }; 676 | } 677 | 678 | export const InternalError = { 679 | encode(message: InternalError, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 680 | if (message.msg !== "") { 681 | writer.uint32(10).string(message.msg); 682 | } 683 | return writer; 684 | }, 685 | 686 | decode(input: _m0.Reader | Uint8Array, length?: number): InternalError { 687 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 688 | let end = length === undefined ? reader.len : reader.pos + length; 689 | const message = createBaseInternalError(); 690 | while (reader.pos < end) { 691 | const tag = reader.uint32(); 692 | switch (tag >>> 3) { 693 | case 1: 694 | message.msg = reader.string(); 695 | break; 696 | default: 697 | reader.skipType(tag & 7); 698 | break; 699 | } 700 | } 701 | return message; 702 | }, 703 | 704 | fromJSON(object: any): InternalError { 705 | return { msg: isSet(object.msg) ? String(object.msg) : "" }; 706 | }, 707 | 708 | toJSON(message: InternalError): unknown { 709 | const obj: any = {}; 710 | message.msg !== undefined && (obj.msg = message.msg); 711 | return obj; 712 | }, 713 | 714 | create, I>>(base?: I): InternalError { 715 | return InternalError.fromPartial(base ?? {}); 716 | }, 717 | 718 | fromPartial, I>>(object: I): InternalError { 719 | const message = createBaseInternalError(); 720 | message.msg = object.msg ?? ""; 721 | return message; 722 | }, 723 | }; 724 | 725 | function createBaseDroppedBundle(): DroppedBundle { 726 | return { msg: "" }; 727 | } 728 | 729 | export const DroppedBundle = { 730 | encode(message: DroppedBundle, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 731 | if (message.msg !== "") { 732 | writer.uint32(10).string(message.msg); 733 | } 734 | return writer; 735 | }, 736 | 737 | decode(input: _m0.Reader | Uint8Array, length?: number): DroppedBundle { 738 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 739 | let end = length === undefined ? reader.len : reader.pos + length; 740 | const message = createBaseDroppedBundle(); 741 | while (reader.pos < end) { 742 | const tag = reader.uint32(); 743 | switch (tag >>> 3) { 744 | case 1: 745 | message.msg = reader.string(); 746 | break; 747 | default: 748 | reader.skipType(tag & 7); 749 | break; 750 | } 751 | } 752 | return message; 753 | }, 754 | 755 | fromJSON(object: any): DroppedBundle { 756 | return { msg: isSet(object.msg) ? String(object.msg) : "" }; 757 | }, 758 | 759 | toJSON(message: DroppedBundle): unknown { 760 | const obj: any = {}; 761 | message.msg !== undefined && (obj.msg = message.msg); 762 | return obj; 763 | }, 764 | 765 | create, I>>(base?: I): DroppedBundle { 766 | return DroppedBundle.fromPartial(base ?? {}); 767 | }, 768 | 769 | fromPartial, I>>(object: I): DroppedBundle { 770 | const message = createBaseDroppedBundle(); 771 | message.msg = object.msg ?? ""; 772 | return message; 773 | }, 774 | }; 775 | 776 | function createBaseFinalized(): Finalized { 777 | return {}; 778 | } 779 | 780 | export const Finalized = { 781 | encode(_: Finalized, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 782 | return writer; 783 | }, 784 | 785 | decode(input: _m0.Reader | Uint8Array, length?: number): Finalized { 786 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 787 | let end = length === undefined ? reader.len : reader.pos + length; 788 | const message = createBaseFinalized(); 789 | while (reader.pos < end) { 790 | const tag = reader.uint32(); 791 | switch (tag >>> 3) { 792 | default: 793 | reader.skipType(tag & 7); 794 | break; 795 | } 796 | } 797 | return message; 798 | }, 799 | 800 | fromJSON(_: any): Finalized { 801 | return {}; 802 | }, 803 | 804 | toJSON(_: Finalized): unknown { 805 | const obj: any = {}; 806 | return obj; 807 | }, 808 | 809 | create, I>>(base?: I): Finalized { 810 | return Finalized.fromPartial(base ?? {}); 811 | }, 812 | 813 | fromPartial, I>>(_: I): Finalized { 814 | const message = createBaseFinalized(); 815 | return message; 816 | }, 817 | }; 818 | 819 | function createBaseProcessed(): Processed { 820 | return { validatorIdentity: "", slot: 0, bundleIndex: 0 }; 821 | } 822 | 823 | export const Processed = { 824 | encode(message: Processed, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 825 | if (message.validatorIdentity !== "") { 826 | writer.uint32(10).string(message.validatorIdentity); 827 | } 828 | if (message.slot !== 0) { 829 | writer.uint32(16).uint64(message.slot); 830 | } 831 | if (message.bundleIndex !== 0) { 832 | writer.uint32(24).uint64(message.bundleIndex); 833 | } 834 | return writer; 835 | }, 836 | 837 | decode(input: _m0.Reader | Uint8Array, length?: number): Processed { 838 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 839 | let end = length === undefined ? reader.len : reader.pos + length; 840 | const message = createBaseProcessed(); 841 | while (reader.pos < end) { 842 | const tag = reader.uint32(); 843 | switch (tag >>> 3) { 844 | case 1: 845 | message.validatorIdentity = reader.string(); 846 | break; 847 | case 2: 848 | message.slot = longToNumber(reader.uint64() as Long); 849 | break; 850 | case 3: 851 | message.bundleIndex = longToNumber(reader.uint64() as Long); 852 | break; 853 | default: 854 | reader.skipType(tag & 7); 855 | break; 856 | } 857 | } 858 | return message; 859 | }, 860 | 861 | fromJSON(object: any): Processed { 862 | return { 863 | validatorIdentity: isSet(object.validatorIdentity) ? String(object.validatorIdentity) : "", 864 | slot: isSet(object.slot) ? Number(object.slot) : 0, 865 | bundleIndex: isSet(object.bundleIndex) ? Number(object.bundleIndex) : 0, 866 | }; 867 | }, 868 | 869 | toJSON(message: Processed): unknown { 870 | const obj: any = {}; 871 | message.validatorIdentity !== undefined && (obj.validatorIdentity = message.validatorIdentity); 872 | message.slot !== undefined && (obj.slot = Math.round(message.slot)); 873 | message.bundleIndex !== undefined && (obj.bundleIndex = Math.round(message.bundleIndex)); 874 | return obj; 875 | }, 876 | 877 | create, I>>(base?: I): Processed { 878 | return Processed.fromPartial(base ?? {}); 879 | }, 880 | 881 | fromPartial, I>>(object: I): Processed { 882 | const message = createBaseProcessed(); 883 | message.validatorIdentity = object.validatorIdentity ?? ""; 884 | message.slot = object.slot ?? 0; 885 | message.bundleIndex = object.bundleIndex ?? 0; 886 | return message; 887 | }, 888 | }; 889 | 890 | function createBaseDropped(): Dropped { 891 | return { reason: 0 }; 892 | } 893 | 894 | export const Dropped = { 895 | encode(message: Dropped, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 896 | if (message.reason !== 0) { 897 | writer.uint32(8).int32(message.reason); 898 | } 899 | return writer; 900 | }, 901 | 902 | decode(input: _m0.Reader | Uint8Array, length?: number): Dropped { 903 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 904 | let end = length === undefined ? reader.len : reader.pos + length; 905 | const message = createBaseDropped(); 906 | while (reader.pos < end) { 907 | const tag = reader.uint32(); 908 | switch (tag >>> 3) { 909 | case 1: 910 | message.reason = reader.int32() as any; 911 | break; 912 | default: 913 | reader.skipType(tag & 7); 914 | break; 915 | } 916 | } 917 | return message; 918 | }, 919 | 920 | fromJSON(object: any): Dropped { 921 | return { reason: isSet(object.reason) ? droppedReasonFromJSON(object.reason) : 0 }; 922 | }, 923 | 924 | toJSON(message: Dropped): unknown { 925 | const obj: any = {}; 926 | message.reason !== undefined && (obj.reason = droppedReasonToJSON(message.reason)); 927 | return obj; 928 | }, 929 | 930 | create, I>>(base?: I): Dropped { 931 | return Dropped.fromPartial(base ?? {}); 932 | }, 933 | 934 | fromPartial, I>>(object: I): Dropped { 935 | const message = createBaseDropped(); 936 | message.reason = object.reason ?? 0; 937 | return message; 938 | }, 939 | }; 940 | 941 | function createBaseBundleResult(): BundleResult { 942 | return { 943 | bundleId: "", 944 | accepted: undefined, 945 | rejected: undefined, 946 | finalized: undefined, 947 | processed: undefined, 948 | dropped: undefined, 949 | }; 950 | } 951 | 952 | export const BundleResult = { 953 | encode(message: BundleResult, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 954 | if (message.bundleId !== "") { 955 | writer.uint32(10).string(message.bundleId); 956 | } 957 | if (message.accepted !== undefined) { 958 | Accepted.encode(message.accepted, writer.uint32(18).fork()).ldelim(); 959 | } 960 | if (message.rejected !== undefined) { 961 | Rejected.encode(message.rejected, writer.uint32(26).fork()).ldelim(); 962 | } 963 | if (message.finalized !== undefined) { 964 | Finalized.encode(message.finalized, writer.uint32(34).fork()).ldelim(); 965 | } 966 | if (message.processed !== undefined) { 967 | Processed.encode(message.processed, writer.uint32(42).fork()).ldelim(); 968 | } 969 | if (message.dropped !== undefined) { 970 | Dropped.encode(message.dropped, writer.uint32(50).fork()).ldelim(); 971 | } 972 | return writer; 973 | }, 974 | 975 | decode(input: _m0.Reader | Uint8Array, length?: number): BundleResult { 976 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 977 | let end = length === undefined ? reader.len : reader.pos + length; 978 | const message = createBaseBundleResult(); 979 | while (reader.pos < end) { 980 | const tag = reader.uint32(); 981 | switch (tag >>> 3) { 982 | case 1: 983 | message.bundleId = reader.string(); 984 | break; 985 | case 2: 986 | message.accepted = Accepted.decode(reader, reader.uint32()); 987 | break; 988 | case 3: 989 | message.rejected = Rejected.decode(reader, reader.uint32()); 990 | break; 991 | case 4: 992 | message.finalized = Finalized.decode(reader, reader.uint32()); 993 | break; 994 | case 5: 995 | message.processed = Processed.decode(reader, reader.uint32()); 996 | break; 997 | case 6: 998 | message.dropped = Dropped.decode(reader, reader.uint32()); 999 | break; 1000 | default: 1001 | reader.skipType(tag & 7); 1002 | break; 1003 | } 1004 | } 1005 | return message; 1006 | }, 1007 | 1008 | fromJSON(object: any): BundleResult { 1009 | return { 1010 | bundleId: isSet(object.bundleId) ? String(object.bundleId) : "", 1011 | accepted: isSet(object.accepted) ? Accepted.fromJSON(object.accepted) : undefined, 1012 | rejected: isSet(object.rejected) ? Rejected.fromJSON(object.rejected) : undefined, 1013 | finalized: isSet(object.finalized) ? Finalized.fromJSON(object.finalized) : undefined, 1014 | processed: isSet(object.processed) ? Processed.fromJSON(object.processed) : undefined, 1015 | dropped: isSet(object.dropped) ? Dropped.fromJSON(object.dropped) : undefined, 1016 | }; 1017 | }, 1018 | 1019 | toJSON(message: BundleResult): unknown { 1020 | const obj: any = {}; 1021 | message.bundleId !== undefined && (obj.bundleId = message.bundleId); 1022 | message.accepted !== undefined && (obj.accepted = message.accepted ? Accepted.toJSON(message.accepted) : undefined); 1023 | message.rejected !== undefined && (obj.rejected = message.rejected ? Rejected.toJSON(message.rejected) : undefined); 1024 | message.finalized !== undefined && 1025 | (obj.finalized = message.finalized ? Finalized.toJSON(message.finalized) : undefined); 1026 | message.processed !== undefined && 1027 | (obj.processed = message.processed ? Processed.toJSON(message.processed) : undefined); 1028 | message.dropped !== undefined && (obj.dropped = message.dropped ? Dropped.toJSON(message.dropped) : undefined); 1029 | return obj; 1030 | }, 1031 | 1032 | create, I>>(base?: I): BundleResult { 1033 | return BundleResult.fromPartial(base ?? {}); 1034 | }, 1035 | 1036 | fromPartial, I>>(object: I): BundleResult { 1037 | const message = createBaseBundleResult(); 1038 | message.bundleId = object.bundleId ?? ""; 1039 | message.accepted = (object.accepted !== undefined && object.accepted !== null) 1040 | ? Accepted.fromPartial(object.accepted) 1041 | : undefined; 1042 | message.rejected = (object.rejected !== undefined && object.rejected !== null) 1043 | ? Rejected.fromPartial(object.rejected) 1044 | : undefined; 1045 | message.finalized = (object.finalized !== undefined && object.finalized !== null) 1046 | ? Finalized.fromPartial(object.finalized) 1047 | : undefined; 1048 | message.processed = (object.processed !== undefined && object.processed !== null) 1049 | ? Processed.fromPartial(object.processed) 1050 | : undefined; 1051 | message.dropped = (object.dropped !== undefined && object.dropped !== null) 1052 | ? Dropped.fromPartial(object.dropped) 1053 | : undefined; 1054 | return message; 1055 | }, 1056 | }; 1057 | 1058 | declare var self: any | undefined; 1059 | declare var window: any | undefined; 1060 | declare var global: any | undefined; 1061 | var tsProtoGlobalThis: any = (() => { 1062 | if (typeof globalThis !== "undefined") { 1063 | return globalThis; 1064 | } 1065 | if (typeof self !== "undefined") { 1066 | return self; 1067 | } 1068 | if (typeof window !== "undefined") { 1069 | return window; 1070 | } 1071 | if (typeof global !== "undefined") { 1072 | return global; 1073 | } 1074 | throw "Unable to locate global object"; 1075 | })(); 1076 | 1077 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 1078 | 1079 | export type DeepPartial = T extends Builtin ? T 1080 | : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> 1081 | : T extends {} ? { [K in keyof T]?: DeepPartial } 1082 | : Partial; 1083 | 1084 | type KeysOfUnion = T extends T ? keyof T : never; 1085 | export type Exact = P extends Builtin ? P 1086 | : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; 1087 | 1088 | function longToNumber(long: Long): number { 1089 | if (long.gt(Number.MAX_SAFE_INTEGER)) { 1090 | throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); 1091 | } 1092 | return long.toNumber(); 1093 | } 1094 | 1095 | if (_m0.util.Long !== Long) { 1096 | _m0.util.Long = Long as any; 1097 | _m0.configure(); 1098 | } 1099 | 1100 | function isSet(value: any): boolean { 1101 | return value !== null && value !== undefined; 1102 | } -------------------------------------------------------------------------------- /src/jito/searcher.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { 3 | CallOptions, 4 | ChannelCredentials, 5 | Client, 6 | ClientOptions, 7 | ClientReadableStream, 8 | ClientUnaryCall, 9 | handleServerStreamingCall, 10 | handleUnaryCall, 11 | makeGenericClientConstructor, 12 | Metadata, 13 | ServiceError, 14 | UntypedServiceImplementation, 15 | } from "@grpc/grpc-js"; 16 | import Long from "long"; 17 | import _m0 from "protobufjs/minimal"; 18 | import { Bundle, BundleResult } from "./block-eng-bundle"; 19 | 20 | export const protobufPackage = "searcher"; 21 | 22 | export interface SlotList { 23 | slots: number[]; 24 | } 25 | 26 | export interface ConnectedLeadersResponse { 27 | /** Mapping of validator pubkey to leader slots for the current epoch. */ 28 | connectedValidators: { [key: string]: SlotList }; 29 | } 30 | 31 | export interface ConnectedLeadersResponse_ConnectedValidatorsEntry { 32 | key: string; 33 | value: SlotList | undefined; 34 | } 35 | 36 | export interface SendBundleRequest { 37 | bundle: Bundle | undefined; 38 | } 39 | 40 | export interface SendBundleResponse { 41 | /** server uuid for the bundle */ 42 | uuid: string; 43 | } 44 | 45 | export interface NextScheduledLeaderRequest { 46 | /** Defaults to the currently connected region if no region provided. */ 47 | regions: string[]; 48 | } 49 | 50 | export interface NextScheduledLeaderResponse { 51 | /** the current slot the backend is on */ 52 | currentSlot: number; 53 | /** the slot of the next leader */ 54 | nextLeaderSlot: number; 55 | /** the identity pubkey (base58) of the next leader */ 56 | nextLeaderIdentity: string; 57 | /** the block engine region of the next leader */ 58 | nextLeaderRegion: string; 59 | } 60 | 61 | export interface ConnectedLeadersRequest { 62 | } 63 | 64 | export interface ConnectedLeadersRegionedRequest { 65 | /** Defaults to the currently connected region if no region provided. */ 66 | regions: string[]; 67 | } 68 | 69 | export interface ConnectedLeadersRegionedResponse { 70 | connectedValidators: { [key: string]: ConnectedLeadersResponse }; 71 | } 72 | 73 | export interface ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 74 | key: string; 75 | value: ConnectedLeadersResponse | undefined; 76 | } 77 | 78 | export interface GetTipAccountsRequest { 79 | } 80 | 81 | export interface GetTipAccountsResponse { 82 | accounts: string[]; 83 | } 84 | 85 | export interface SubscribeBundleResultsRequest { 86 | } 87 | 88 | export interface GetRegionsRequest { 89 | } 90 | 91 | export interface GetRegionsResponse { 92 | /** The region the client is currently connected to */ 93 | currentRegion: string; 94 | /** 95 | * Regions that are online and ready for connections 96 | * All regions: https://jito-labs.gitbook.io/mev/systems/connecting/mainnet 97 | */ 98 | availableRegions: string[]; 99 | } 100 | 101 | function createBaseSlotList(): SlotList { 102 | return { slots: [] }; 103 | } 104 | 105 | export const SlotList = { 106 | encode(message: SlotList, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 107 | writer.uint32(10).fork(); 108 | for (const v of message.slots) { 109 | writer.uint64(v); 110 | } 111 | writer.ldelim(); 112 | return writer; 113 | }, 114 | 115 | decode(input: _m0.Reader | Uint8Array, length?: number): SlotList { 116 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 117 | let end = length === undefined ? reader.len : reader.pos + length; 118 | const message = createBaseSlotList(); 119 | while (reader.pos < end) { 120 | const tag = reader.uint32(); 121 | switch (tag >>> 3) { 122 | case 1: 123 | if ((tag & 7) === 2) { 124 | const end2 = reader.uint32() + reader.pos; 125 | while (reader.pos < end2) { 126 | message.slots.push(longToNumber(reader.uint64() as Long)); 127 | } 128 | } else { 129 | message.slots.push(longToNumber(reader.uint64() as Long)); 130 | } 131 | break; 132 | default: 133 | reader.skipType(tag & 7); 134 | break; 135 | } 136 | } 137 | return message; 138 | }, 139 | 140 | fromJSON(object: any): SlotList { 141 | return { slots: Array.isArray(object?.slots) ? object.slots.map((e: any) => Number(e)) : [] }; 142 | }, 143 | 144 | toJSON(message: SlotList): unknown { 145 | const obj: any = {}; 146 | if (message.slots) { 147 | obj.slots = message.slots.map((e) => Math.round(e)); 148 | } else { 149 | obj.slots = []; 150 | } 151 | return obj; 152 | }, 153 | 154 | create, I>>(base?: I): SlotList { 155 | return SlotList.fromPartial(base ?? {}); 156 | }, 157 | 158 | fromPartial, I>>(object: I): SlotList { 159 | const message = createBaseSlotList(); 160 | message.slots = object.slots?.map((e) => e) || []; 161 | return message; 162 | }, 163 | }; 164 | 165 | function createBaseConnectedLeadersResponse(): ConnectedLeadersResponse { 166 | return { connectedValidators: {} }; 167 | } 168 | 169 | export const ConnectedLeadersResponse = { 170 | encode(message: ConnectedLeadersResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 171 | Object.entries(message.connectedValidators).forEach(([key, value]) => { 172 | ConnectedLeadersResponse_ConnectedValidatorsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()) 173 | .ldelim(); 174 | }); 175 | return writer; 176 | }, 177 | 178 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersResponse { 179 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 180 | let end = length === undefined ? reader.len : reader.pos + length; 181 | const message = createBaseConnectedLeadersResponse(); 182 | while (reader.pos < end) { 183 | const tag = reader.uint32(); 184 | switch (tag >>> 3) { 185 | case 1: 186 | const entry1 = ConnectedLeadersResponse_ConnectedValidatorsEntry.decode(reader, reader.uint32()); 187 | if (entry1.value !== undefined) { 188 | message.connectedValidators[entry1.key] = entry1.value; 189 | } 190 | break; 191 | default: 192 | reader.skipType(tag & 7); 193 | break; 194 | } 195 | } 196 | return message; 197 | }, 198 | 199 | fromJSON(object: any): ConnectedLeadersResponse { 200 | return { 201 | connectedValidators: isObject(object.connectedValidators) 202 | ? Object.entries(object.connectedValidators).reduce<{ [key: string]: SlotList }>((acc, [key, value]) => { 203 | acc[key] = SlotList.fromJSON(value); 204 | return acc; 205 | }, {}) 206 | : {}, 207 | }; 208 | }, 209 | 210 | toJSON(message: ConnectedLeadersResponse): unknown { 211 | const obj: any = {}; 212 | obj.connectedValidators = {}; 213 | if (message.connectedValidators) { 214 | Object.entries(message.connectedValidators).forEach(([k, v]) => { 215 | obj.connectedValidators[k] = SlotList.toJSON(v); 216 | }); 217 | } 218 | return obj; 219 | }, 220 | 221 | create, I>>(base?: I): ConnectedLeadersResponse { 222 | return ConnectedLeadersResponse.fromPartial(base ?? {}); 223 | }, 224 | 225 | fromPartial, I>>(object: I): ConnectedLeadersResponse { 226 | const message = createBaseConnectedLeadersResponse(); 227 | message.connectedValidators = Object.entries(object.connectedValidators ?? {}).reduce<{ [key: string]: SlotList }>( 228 | (acc, [key, value]) => { 229 | if (value !== undefined) { 230 | acc[key] = SlotList.fromPartial(value); 231 | } 232 | return acc; 233 | }, 234 | {}, 235 | ); 236 | return message; 237 | }, 238 | }; 239 | 240 | function createBaseConnectedLeadersResponse_ConnectedValidatorsEntry(): ConnectedLeadersResponse_ConnectedValidatorsEntry { 241 | return { key: "", value: undefined }; 242 | } 243 | 244 | export const ConnectedLeadersResponse_ConnectedValidatorsEntry = { 245 | encode( 246 | message: ConnectedLeadersResponse_ConnectedValidatorsEntry, 247 | writer: _m0.Writer = _m0.Writer.create(), 248 | ): _m0.Writer { 249 | if (message.key !== "") { 250 | writer.uint32(10).string(message.key); 251 | } 252 | if (message.value !== undefined) { 253 | SlotList.encode(message.value, writer.uint32(18).fork()).ldelim(); 254 | } 255 | return writer; 256 | }, 257 | 258 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersResponse_ConnectedValidatorsEntry { 259 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 260 | let end = length === undefined ? reader.len : reader.pos + length; 261 | const message = createBaseConnectedLeadersResponse_ConnectedValidatorsEntry(); 262 | while (reader.pos < end) { 263 | const tag = reader.uint32(); 264 | switch (tag >>> 3) { 265 | case 1: 266 | message.key = reader.string(); 267 | break; 268 | case 2: 269 | message.value = SlotList.decode(reader, reader.uint32()); 270 | break; 271 | default: 272 | reader.skipType(tag & 7); 273 | break; 274 | } 275 | } 276 | return message; 277 | }, 278 | 279 | fromJSON(object: any): ConnectedLeadersResponse_ConnectedValidatorsEntry { 280 | return { 281 | key: isSet(object.key) ? String(object.key) : "", 282 | value: isSet(object.value) ? SlotList.fromJSON(object.value) : undefined, 283 | }; 284 | }, 285 | 286 | toJSON(message: ConnectedLeadersResponse_ConnectedValidatorsEntry): unknown { 287 | const obj: any = {}; 288 | message.key !== undefined && (obj.key = message.key); 289 | message.value !== undefined && (obj.value = message.value ? SlotList.toJSON(message.value) : undefined); 290 | return obj; 291 | }, 292 | 293 | create, I>>( 294 | base?: I, 295 | ): ConnectedLeadersResponse_ConnectedValidatorsEntry { 296 | return ConnectedLeadersResponse_ConnectedValidatorsEntry.fromPartial(base ?? {}); 297 | }, 298 | 299 | fromPartial, I>>( 300 | object: I, 301 | ): ConnectedLeadersResponse_ConnectedValidatorsEntry { 302 | const message = createBaseConnectedLeadersResponse_ConnectedValidatorsEntry(); 303 | message.key = object.key ?? ""; 304 | message.value = (object.value !== undefined && object.value !== null) 305 | ? SlotList.fromPartial(object.value) 306 | : undefined; 307 | return message; 308 | }, 309 | }; 310 | 311 | function createBaseSendBundleRequest(): SendBundleRequest { 312 | return { bundle: undefined }; 313 | } 314 | 315 | export const SendBundleRequest = { 316 | encode(message: SendBundleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 317 | if (message.bundle !== undefined) { 318 | Bundle.encode(message.bundle, writer.uint32(10).fork()).ldelim(); 319 | } 320 | return writer; 321 | }, 322 | 323 | decode(input: _m0.Reader | Uint8Array, length?: number): SendBundleRequest { 324 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 325 | let end = length === undefined ? reader.len : reader.pos + length; 326 | const message = createBaseSendBundleRequest(); 327 | while (reader.pos < end) { 328 | const tag = reader.uint32(); 329 | switch (tag >>> 3) { 330 | case 1: 331 | message.bundle = Bundle.decode(reader, reader.uint32()); 332 | break; 333 | default: 334 | reader.skipType(tag & 7); 335 | break; 336 | } 337 | } 338 | return message; 339 | }, 340 | 341 | fromJSON(object: any): SendBundleRequest { 342 | return { bundle: isSet(object.bundle) ? Bundle.fromJSON(object.bundle) : undefined }; 343 | }, 344 | 345 | toJSON(message: SendBundleRequest): unknown { 346 | const obj: any = {}; 347 | message.bundle !== undefined && (obj.bundle = message.bundle ? Bundle.toJSON(message.bundle) : undefined); 348 | return obj; 349 | }, 350 | 351 | create, I>>(base?: I): SendBundleRequest { 352 | return SendBundleRequest.fromPartial(base ?? {}); 353 | }, 354 | 355 | fromPartial, I>>(object: I): SendBundleRequest { 356 | const message = createBaseSendBundleRequest(); 357 | message.bundle = (object.bundle !== undefined && object.bundle !== null) 358 | ? Bundle.fromPartial(object.bundle) 359 | : undefined; 360 | return message; 361 | }, 362 | }; 363 | 364 | function createBaseSendBundleResponse(): SendBundleResponse { 365 | return { uuid: "" }; 366 | } 367 | 368 | export const SendBundleResponse = { 369 | encode(message: SendBundleResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 370 | if (message.uuid !== "") { 371 | writer.uint32(10).string(message.uuid); 372 | } 373 | return writer; 374 | }, 375 | 376 | decode(input: _m0.Reader | Uint8Array, length?: number): SendBundleResponse { 377 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 378 | let end = length === undefined ? reader.len : reader.pos + length; 379 | const message = createBaseSendBundleResponse(); 380 | while (reader.pos < end) { 381 | const tag = reader.uint32(); 382 | switch (tag >>> 3) { 383 | case 1: 384 | message.uuid = reader.string(); 385 | break; 386 | default: 387 | reader.skipType(tag & 7); 388 | break; 389 | } 390 | } 391 | return message; 392 | }, 393 | 394 | fromJSON(object: any): SendBundleResponse { 395 | return { uuid: isSet(object.uuid) ? String(object.uuid) : "" }; 396 | }, 397 | 398 | toJSON(message: SendBundleResponse): unknown { 399 | const obj: any = {}; 400 | message.uuid !== undefined && (obj.uuid = message.uuid); 401 | return obj; 402 | }, 403 | 404 | create, I>>(base?: I): SendBundleResponse { 405 | return SendBundleResponse.fromPartial(base ?? {}); 406 | }, 407 | 408 | fromPartial, I>>(object: I): SendBundleResponse { 409 | const message = createBaseSendBundleResponse(); 410 | message.uuid = object.uuid ?? ""; 411 | return message; 412 | }, 413 | }; 414 | 415 | function createBaseNextScheduledLeaderRequest(): NextScheduledLeaderRequest { 416 | return { regions: [] }; 417 | } 418 | 419 | export const NextScheduledLeaderRequest = { 420 | encode(message: NextScheduledLeaderRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 421 | for (const v of message.regions) { 422 | writer.uint32(10).string(v!); 423 | } 424 | return writer; 425 | }, 426 | 427 | decode(input: _m0.Reader | Uint8Array, length?: number): NextScheduledLeaderRequest { 428 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 429 | let end = length === undefined ? reader.len : reader.pos + length; 430 | const message = createBaseNextScheduledLeaderRequest(); 431 | while (reader.pos < end) { 432 | const tag = reader.uint32(); 433 | switch (tag >>> 3) { 434 | case 1: 435 | message.regions.push(reader.string()); 436 | break; 437 | default: 438 | reader.skipType(tag & 7); 439 | break; 440 | } 441 | } 442 | return message; 443 | }, 444 | 445 | fromJSON(object: any): NextScheduledLeaderRequest { 446 | return { regions: Array.isArray(object?.regions) ? object.regions.map((e: any) => String(e)) : [] }; 447 | }, 448 | 449 | toJSON(message: NextScheduledLeaderRequest): unknown { 450 | const obj: any = {}; 451 | if (message.regions) { 452 | obj.regions = message.regions.map((e) => e); 453 | } else { 454 | obj.regions = []; 455 | } 456 | return obj; 457 | }, 458 | 459 | create, I>>(base?: I): NextScheduledLeaderRequest { 460 | return NextScheduledLeaderRequest.fromPartial(base ?? {}); 461 | }, 462 | 463 | fromPartial, I>>(object: I): NextScheduledLeaderRequest { 464 | const message = createBaseNextScheduledLeaderRequest(); 465 | message.regions = object.regions?.map((e) => e) || []; 466 | return message; 467 | }, 468 | }; 469 | 470 | function createBaseNextScheduledLeaderResponse(): NextScheduledLeaderResponse { 471 | return { currentSlot: 0, nextLeaderSlot: 0, nextLeaderIdentity: "", nextLeaderRegion: "" }; 472 | } 473 | 474 | export const NextScheduledLeaderResponse = { 475 | encode(message: NextScheduledLeaderResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 476 | if (message.currentSlot !== 0) { 477 | writer.uint32(8).uint64(message.currentSlot); 478 | } 479 | if (message.nextLeaderSlot !== 0) { 480 | writer.uint32(16).uint64(message.nextLeaderSlot); 481 | } 482 | if (message.nextLeaderIdentity !== "") { 483 | writer.uint32(26).string(message.nextLeaderIdentity); 484 | } 485 | if (message.nextLeaderRegion !== "") { 486 | writer.uint32(34).string(message.nextLeaderRegion); 487 | } 488 | return writer; 489 | }, 490 | 491 | decode(input: _m0.Reader | Uint8Array, length?: number): NextScheduledLeaderResponse { 492 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 493 | let end = length === undefined ? reader.len : reader.pos + length; 494 | const message = createBaseNextScheduledLeaderResponse(); 495 | while (reader.pos < end) { 496 | const tag = reader.uint32(); 497 | switch (tag >>> 3) { 498 | case 1: 499 | message.currentSlot = longToNumber(reader.uint64() as Long); 500 | break; 501 | case 2: 502 | message.nextLeaderSlot = longToNumber(reader.uint64() as Long); 503 | break; 504 | case 3: 505 | message.nextLeaderIdentity = reader.string(); 506 | break; 507 | case 4: 508 | message.nextLeaderRegion = reader.string(); 509 | break; 510 | default: 511 | reader.skipType(tag & 7); 512 | break; 513 | } 514 | } 515 | return message; 516 | }, 517 | 518 | fromJSON(object: any): NextScheduledLeaderResponse { 519 | return { 520 | currentSlot: isSet(object.currentSlot) ? Number(object.currentSlot) : 0, 521 | nextLeaderSlot: isSet(object.nextLeaderSlot) ? Number(object.nextLeaderSlot) : 0, 522 | nextLeaderIdentity: isSet(object.nextLeaderIdentity) ? String(object.nextLeaderIdentity) : "", 523 | nextLeaderRegion: isSet(object.nextLeaderRegion) ? String(object.nextLeaderRegion) : "", 524 | }; 525 | }, 526 | 527 | toJSON(message: NextScheduledLeaderResponse): unknown { 528 | const obj: any = {}; 529 | message.currentSlot !== undefined && (obj.currentSlot = Math.round(message.currentSlot)); 530 | message.nextLeaderSlot !== undefined && (obj.nextLeaderSlot = Math.round(message.nextLeaderSlot)); 531 | message.nextLeaderIdentity !== undefined && (obj.nextLeaderIdentity = message.nextLeaderIdentity); 532 | message.nextLeaderRegion !== undefined && (obj.nextLeaderRegion = message.nextLeaderRegion); 533 | return obj; 534 | }, 535 | 536 | create, I>>(base?: I): NextScheduledLeaderResponse { 537 | return NextScheduledLeaderResponse.fromPartial(base ?? {}); 538 | }, 539 | 540 | fromPartial, I>>(object: I): NextScheduledLeaderResponse { 541 | const message = createBaseNextScheduledLeaderResponse(); 542 | message.currentSlot = object.currentSlot ?? 0; 543 | message.nextLeaderSlot = object.nextLeaderSlot ?? 0; 544 | message.nextLeaderIdentity = object.nextLeaderIdentity ?? ""; 545 | message.nextLeaderRegion = object.nextLeaderRegion ?? ""; 546 | return message; 547 | }, 548 | }; 549 | 550 | function createBaseConnectedLeadersRequest(): ConnectedLeadersRequest { 551 | return {}; 552 | } 553 | 554 | export const ConnectedLeadersRequest = { 555 | encode(_: ConnectedLeadersRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 556 | return writer; 557 | }, 558 | 559 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersRequest { 560 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 561 | let end = length === undefined ? reader.len : reader.pos + length; 562 | const message = createBaseConnectedLeadersRequest(); 563 | while (reader.pos < end) { 564 | const tag = reader.uint32(); 565 | switch (tag >>> 3) { 566 | default: 567 | reader.skipType(tag & 7); 568 | break; 569 | } 570 | } 571 | return message; 572 | }, 573 | 574 | fromJSON(_: any): ConnectedLeadersRequest { 575 | return {}; 576 | }, 577 | 578 | toJSON(_: ConnectedLeadersRequest): unknown { 579 | const obj: any = {}; 580 | return obj; 581 | }, 582 | 583 | create, I>>(base?: I): ConnectedLeadersRequest { 584 | return ConnectedLeadersRequest.fromPartial(base ?? {}); 585 | }, 586 | 587 | fromPartial, I>>(_: I): ConnectedLeadersRequest { 588 | const message = createBaseConnectedLeadersRequest(); 589 | return message; 590 | }, 591 | }; 592 | 593 | function createBaseConnectedLeadersRegionedRequest(): ConnectedLeadersRegionedRequest { 594 | return { regions: [] }; 595 | } 596 | 597 | export const ConnectedLeadersRegionedRequest = { 598 | encode(message: ConnectedLeadersRegionedRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 599 | for (const v of message.regions) { 600 | writer.uint32(10).string(v!); 601 | } 602 | return writer; 603 | }, 604 | 605 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersRegionedRequest { 606 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 607 | let end = length === undefined ? reader.len : reader.pos + length; 608 | const message = createBaseConnectedLeadersRegionedRequest(); 609 | while (reader.pos < end) { 610 | const tag = reader.uint32(); 611 | switch (tag >>> 3) { 612 | case 1: 613 | message.regions.push(reader.string()); 614 | break; 615 | default: 616 | reader.skipType(tag & 7); 617 | break; 618 | } 619 | } 620 | return message; 621 | }, 622 | 623 | fromJSON(object: any): ConnectedLeadersRegionedRequest { 624 | return { regions: Array.isArray(object?.regions) ? object.regions.map((e: any) => String(e)) : [] }; 625 | }, 626 | 627 | toJSON(message: ConnectedLeadersRegionedRequest): unknown { 628 | const obj: any = {}; 629 | if (message.regions) { 630 | obj.regions = message.regions.map((e) => e); 631 | } else { 632 | obj.regions = []; 633 | } 634 | return obj; 635 | }, 636 | 637 | create, I>>(base?: I): ConnectedLeadersRegionedRequest { 638 | return ConnectedLeadersRegionedRequest.fromPartial(base ?? {}); 639 | }, 640 | 641 | fromPartial, I>>( 642 | object: I, 643 | ): ConnectedLeadersRegionedRequest { 644 | const message = createBaseConnectedLeadersRegionedRequest(); 645 | message.regions = object.regions?.map((e) => e) || []; 646 | return message; 647 | }, 648 | }; 649 | 650 | function createBaseConnectedLeadersRegionedResponse(): ConnectedLeadersRegionedResponse { 651 | return { connectedValidators: {} }; 652 | } 653 | 654 | export const ConnectedLeadersRegionedResponse = { 655 | encode(message: ConnectedLeadersRegionedResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 656 | Object.entries(message.connectedValidators).forEach(([key, value]) => { 657 | ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry.encode( 658 | { key: key as any, value }, 659 | writer.uint32(10).fork(), 660 | ).ldelim(); 661 | }); 662 | return writer; 663 | }, 664 | 665 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersRegionedResponse { 666 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 667 | let end = length === undefined ? reader.len : reader.pos + length; 668 | const message = createBaseConnectedLeadersRegionedResponse(); 669 | while (reader.pos < end) { 670 | const tag = reader.uint32(); 671 | switch (tag >>> 3) { 672 | case 1: 673 | const entry1 = ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry.decode(reader, reader.uint32()); 674 | if (entry1.value !== undefined) { 675 | message.connectedValidators[entry1.key] = entry1.value; 676 | } 677 | break; 678 | default: 679 | reader.skipType(tag & 7); 680 | break; 681 | } 682 | } 683 | return message; 684 | }, 685 | 686 | fromJSON(object: any): ConnectedLeadersRegionedResponse { 687 | return { 688 | connectedValidators: isObject(object.connectedValidators) 689 | ? Object.entries(object.connectedValidators).reduce<{ [key: string]: ConnectedLeadersResponse }>( 690 | (acc, [key, value]) => { 691 | acc[key] = ConnectedLeadersResponse.fromJSON(value); 692 | return acc; 693 | }, 694 | {}, 695 | ) 696 | : {}, 697 | }; 698 | }, 699 | 700 | toJSON(message: ConnectedLeadersRegionedResponse): unknown { 701 | const obj: any = {}; 702 | obj.connectedValidators = {}; 703 | if (message.connectedValidators) { 704 | Object.entries(message.connectedValidators).forEach(([k, v]) => { 705 | obj.connectedValidators[k] = ConnectedLeadersResponse.toJSON(v); 706 | }); 707 | } 708 | return obj; 709 | }, 710 | 711 | create, I>>( 712 | base?: I, 713 | ): ConnectedLeadersRegionedResponse { 714 | return ConnectedLeadersRegionedResponse.fromPartial(base ?? {}); 715 | }, 716 | 717 | fromPartial, I>>( 718 | object: I, 719 | ): ConnectedLeadersRegionedResponse { 720 | const message = createBaseConnectedLeadersRegionedResponse(); 721 | message.connectedValidators = Object.entries(object.connectedValidators ?? {}).reduce< 722 | { [key: string]: ConnectedLeadersResponse } 723 | >((acc, [key, value]) => { 724 | if (value !== undefined) { 725 | acc[key] = ConnectedLeadersResponse.fromPartial(value); 726 | } 727 | return acc; 728 | }, {}); 729 | return message; 730 | }, 731 | }; 732 | 733 | function createBaseConnectedLeadersRegionedResponse_ConnectedValidatorsEntry(): ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 734 | return { key: "", value: undefined }; 735 | } 736 | 737 | export const ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry = { 738 | encode( 739 | message: ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry, 740 | writer: _m0.Writer = _m0.Writer.create(), 741 | ): _m0.Writer { 742 | if (message.key !== "") { 743 | writer.uint32(10).string(message.key); 744 | } 745 | if (message.value !== undefined) { 746 | ConnectedLeadersResponse.encode(message.value, writer.uint32(18).fork()).ldelim(); 747 | } 748 | return writer; 749 | }, 750 | 751 | decode(input: _m0.Reader | Uint8Array, length?: number): ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 752 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 753 | let end = length === undefined ? reader.len : reader.pos + length; 754 | const message = createBaseConnectedLeadersRegionedResponse_ConnectedValidatorsEntry(); 755 | while (reader.pos < end) { 756 | const tag = reader.uint32(); 757 | switch (tag >>> 3) { 758 | case 1: 759 | message.key = reader.string(); 760 | break; 761 | case 2: 762 | message.value = ConnectedLeadersResponse.decode(reader, reader.uint32()); 763 | break; 764 | default: 765 | reader.skipType(tag & 7); 766 | break; 767 | } 768 | } 769 | return message; 770 | }, 771 | 772 | fromJSON(object: any): ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 773 | return { 774 | key: isSet(object.key) ? String(object.key) : "", 775 | value: isSet(object.value) ? ConnectedLeadersResponse.fromJSON(object.value) : undefined, 776 | }; 777 | }, 778 | 779 | toJSON(message: ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry): unknown { 780 | const obj: any = {}; 781 | message.key !== undefined && (obj.key = message.key); 782 | message.value !== undefined && 783 | (obj.value = message.value ? ConnectedLeadersResponse.toJSON(message.value) : undefined); 784 | return obj; 785 | }, 786 | 787 | create, I>>( 788 | base?: I, 789 | ): ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 790 | return ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry.fromPartial(base ?? {}); 791 | }, 792 | 793 | fromPartial, I>>( 794 | object: I, 795 | ): ConnectedLeadersRegionedResponse_ConnectedValidatorsEntry { 796 | const message = createBaseConnectedLeadersRegionedResponse_ConnectedValidatorsEntry(); 797 | message.key = object.key ?? ""; 798 | message.value = (object.value !== undefined && object.value !== null) 799 | ? ConnectedLeadersResponse.fromPartial(object.value) 800 | : undefined; 801 | return message; 802 | }, 803 | }; 804 | 805 | function createBaseGetTipAccountsRequest(): GetTipAccountsRequest { 806 | return {}; 807 | } 808 | 809 | export const GetTipAccountsRequest = { 810 | encode(_: GetTipAccountsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 811 | return writer; 812 | }, 813 | 814 | decode(input: _m0.Reader | Uint8Array, length?: number): GetTipAccountsRequest { 815 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 816 | let end = length === undefined ? reader.len : reader.pos + length; 817 | const message = createBaseGetTipAccountsRequest(); 818 | while (reader.pos < end) { 819 | const tag = reader.uint32(); 820 | switch (tag >>> 3) { 821 | default: 822 | reader.skipType(tag & 7); 823 | break; 824 | } 825 | } 826 | return message; 827 | }, 828 | 829 | fromJSON(_: any): GetTipAccountsRequest { 830 | return {}; 831 | }, 832 | 833 | toJSON(_: GetTipAccountsRequest): unknown { 834 | const obj: any = {}; 835 | return obj; 836 | }, 837 | 838 | create, I>>(base?: I): GetTipAccountsRequest { 839 | return GetTipAccountsRequest.fromPartial(base ?? {}); 840 | }, 841 | 842 | fromPartial, I>>(_: I): GetTipAccountsRequest { 843 | const message = createBaseGetTipAccountsRequest(); 844 | return message; 845 | }, 846 | }; 847 | 848 | function createBaseGetTipAccountsResponse(): GetTipAccountsResponse { 849 | return { accounts: [] }; 850 | } 851 | 852 | export const GetTipAccountsResponse = { 853 | encode(message: GetTipAccountsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 854 | for (const v of message.accounts) { 855 | writer.uint32(10).string(v!); 856 | } 857 | return writer; 858 | }, 859 | 860 | decode(input: _m0.Reader | Uint8Array, length?: number): GetTipAccountsResponse { 861 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 862 | let end = length === undefined ? reader.len : reader.pos + length; 863 | const message = createBaseGetTipAccountsResponse(); 864 | while (reader.pos < end) { 865 | const tag = reader.uint32(); 866 | switch (tag >>> 3) { 867 | case 1: 868 | message.accounts.push(reader.string()); 869 | break; 870 | default: 871 | reader.skipType(tag & 7); 872 | break; 873 | } 874 | } 875 | return message; 876 | }, 877 | 878 | fromJSON(object: any): GetTipAccountsResponse { 879 | return { accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => String(e)) : [] }; 880 | }, 881 | 882 | toJSON(message: GetTipAccountsResponse): unknown { 883 | const obj: any = {}; 884 | if (message.accounts) { 885 | obj.accounts = message.accounts.map((e) => e); 886 | } else { 887 | obj.accounts = []; 888 | } 889 | return obj; 890 | }, 891 | 892 | create, I>>(base?: I): GetTipAccountsResponse { 893 | return GetTipAccountsResponse.fromPartial(base ?? {}); 894 | }, 895 | 896 | fromPartial, I>>(object: I): GetTipAccountsResponse { 897 | const message = createBaseGetTipAccountsResponse(); 898 | message.accounts = object.accounts?.map((e) => e) || []; 899 | return message; 900 | }, 901 | }; 902 | 903 | function createBaseSubscribeBundleResultsRequest(): SubscribeBundleResultsRequest { 904 | return {}; 905 | } 906 | 907 | export const SubscribeBundleResultsRequest = { 908 | encode(_: SubscribeBundleResultsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 909 | return writer; 910 | }, 911 | 912 | decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeBundleResultsRequest { 913 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 914 | let end = length === undefined ? reader.len : reader.pos + length; 915 | const message = createBaseSubscribeBundleResultsRequest(); 916 | while (reader.pos < end) { 917 | const tag = reader.uint32(); 918 | switch (tag >>> 3) { 919 | default: 920 | reader.skipType(tag & 7); 921 | break; 922 | } 923 | } 924 | return message; 925 | }, 926 | 927 | fromJSON(_: any): SubscribeBundleResultsRequest { 928 | return {}; 929 | }, 930 | 931 | toJSON(_: SubscribeBundleResultsRequest): unknown { 932 | const obj: any = {}; 933 | return obj; 934 | }, 935 | 936 | create, I>>(base?: I): SubscribeBundleResultsRequest { 937 | return SubscribeBundleResultsRequest.fromPartial(base ?? {}); 938 | }, 939 | 940 | fromPartial, I>>(_: I): SubscribeBundleResultsRequest { 941 | const message = createBaseSubscribeBundleResultsRequest(); 942 | return message; 943 | }, 944 | }; 945 | 946 | function createBaseGetRegionsRequest(): GetRegionsRequest { 947 | return {}; 948 | } 949 | 950 | export const GetRegionsRequest = { 951 | encode(_: GetRegionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 952 | return writer; 953 | }, 954 | 955 | decode(input: _m0.Reader | Uint8Array, length?: number): GetRegionsRequest { 956 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 957 | let end = length === undefined ? reader.len : reader.pos + length; 958 | const message = createBaseGetRegionsRequest(); 959 | while (reader.pos < end) { 960 | const tag = reader.uint32(); 961 | switch (tag >>> 3) { 962 | default: 963 | reader.skipType(tag & 7); 964 | break; 965 | } 966 | } 967 | return message; 968 | }, 969 | 970 | fromJSON(_: any): GetRegionsRequest { 971 | return {}; 972 | }, 973 | 974 | toJSON(_: GetRegionsRequest): unknown { 975 | const obj: any = {}; 976 | return obj; 977 | }, 978 | 979 | create, I>>(base?: I): GetRegionsRequest { 980 | return GetRegionsRequest.fromPartial(base ?? {}); 981 | }, 982 | 983 | fromPartial, I>>(_: I): GetRegionsRequest { 984 | const message = createBaseGetRegionsRequest(); 985 | return message; 986 | }, 987 | }; 988 | 989 | function createBaseGetRegionsResponse(): GetRegionsResponse { 990 | return { currentRegion: "", availableRegions: [] }; 991 | } 992 | 993 | export const GetRegionsResponse = { 994 | encode(message: GetRegionsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 995 | if (message.currentRegion !== "") { 996 | writer.uint32(10).string(message.currentRegion); 997 | } 998 | for (const v of message.availableRegions) { 999 | writer.uint32(18).string(v!); 1000 | } 1001 | return writer; 1002 | }, 1003 | 1004 | decode(input: _m0.Reader | Uint8Array, length?: number): GetRegionsResponse { 1005 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 1006 | let end = length === undefined ? reader.len : reader.pos + length; 1007 | const message = createBaseGetRegionsResponse(); 1008 | while (reader.pos < end) { 1009 | const tag = reader.uint32(); 1010 | switch (tag >>> 3) { 1011 | case 1: 1012 | message.currentRegion = reader.string(); 1013 | break; 1014 | case 2: 1015 | message.availableRegions.push(reader.string()); 1016 | break; 1017 | default: 1018 | reader.skipType(tag & 7); 1019 | break; 1020 | } 1021 | } 1022 | return message; 1023 | }, 1024 | 1025 | fromJSON(object: any): GetRegionsResponse { 1026 | return { 1027 | currentRegion: isSet(object.currentRegion) ? String(object.currentRegion) : "", 1028 | availableRegions: Array.isArray(object?.availableRegions) 1029 | ? object.availableRegions.map((e: any) => String(e)) 1030 | : [], 1031 | }; 1032 | }, 1033 | 1034 | toJSON(message: GetRegionsResponse): unknown { 1035 | const obj: any = {}; 1036 | message.currentRegion !== undefined && (obj.currentRegion = message.currentRegion); 1037 | if (message.availableRegions) { 1038 | obj.availableRegions = message.availableRegions.map((e) => e); 1039 | } else { 1040 | obj.availableRegions = []; 1041 | } 1042 | return obj; 1043 | }, 1044 | 1045 | create, I>>(base?: I): GetRegionsResponse { 1046 | return GetRegionsResponse.fromPartial(base ?? {}); 1047 | }, 1048 | 1049 | fromPartial, I>>(object: I): GetRegionsResponse { 1050 | const message = createBaseGetRegionsResponse(); 1051 | message.currentRegion = object.currentRegion ?? ""; 1052 | message.availableRegions = object.availableRegions?.map((e) => e) || []; 1053 | return message; 1054 | }, 1055 | }; 1056 | 1057 | export type SearcherServiceService = typeof SearcherServiceService; 1058 | export const SearcherServiceService = { 1059 | /** 1060 | * Searchers can invoke this endpoint to subscribe to their respective bundle results. 1061 | * A success result would indicate the bundle won its state auction and was submitted to the validator. 1062 | */ 1063 | subscribeBundleResults: { 1064 | path: "/searcher.SearcherService/SubscribeBundleResults", 1065 | requestStream: false, 1066 | responseStream: true, 1067 | requestSerialize: (value: SubscribeBundleResultsRequest) => 1068 | Buffer.from(SubscribeBundleResultsRequest.encode(value).finish()), 1069 | requestDeserialize: (value: Buffer) => SubscribeBundleResultsRequest.decode(value), 1070 | responseSerialize: (value: BundleResult) => Buffer.from(BundleResult.encode(value).finish()), 1071 | responseDeserialize: (value: Buffer) => BundleResult.decode(value), 1072 | }, 1073 | sendBundle: { 1074 | path: "/searcher.SearcherService/SendBundle", 1075 | requestStream: false, 1076 | responseStream: false, 1077 | requestSerialize: (value: SendBundleRequest) => Buffer.from(SendBundleRequest.encode(value).finish()), 1078 | requestDeserialize: (value: Buffer) => SendBundleRequest.decode(value), 1079 | responseSerialize: (value: SendBundleResponse) => Buffer.from(SendBundleResponse.encode(value).finish()), 1080 | responseDeserialize: (value: Buffer) => SendBundleResponse.decode(value), 1081 | }, 1082 | /** Returns the next scheduled leader connected to the block engine. */ 1083 | getNextScheduledLeader: { 1084 | path: "/searcher.SearcherService/GetNextScheduledLeader", 1085 | requestStream: false, 1086 | responseStream: false, 1087 | requestSerialize: (value: NextScheduledLeaderRequest) => 1088 | Buffer.from(NextScheduledLeaderRequest.encode(value).finish()), 1089 | requestDeserialize: (value: Buffer) => NextScheduledLeaderRequest.decode(value), 1090 | responseSerialize: (value: NextScheduledLeaderResponse) => 1091 | Buffer.from(NextScheduledLeaderResponse.encode(value).finish()), 1092 | responseDeserialize: (value: Buffer) => NextScheduledLeaderResponse.decode(value), 1093 | }, 1094 | /** Returns leader slots for connected jito validators during the current epoch. Only returns data for this region. */ 1095 | getConnectedLeaders: { 1096 | path: "/searcher.SearcherService/GetConnectedLeaders", 1097 | requestStream: false, 1098 | responseStream: false, 1099 | requestSerialize: (value: ConnectedLeadersRequest) => Buffer.from(ConnectedLeadersRequest.encode(value).finish()), 1100 | requestDeserialize: (value: Buffer) => ConnectedLeadersRequest.decode(value), 1101 | responseSerialize: (value: ConnectedLeadersResponse) => 1102 | Buffer.from(ConnectedLeadersResponse.encode(value).finish()), 1103 | responseDeserialize: (value: Buffer) => ConnectedLeadersResponse.decode(value), 1104 | }, 1105 | /** Returns leader slots for connected jito validators during the current epoch. */ 1106 | getConnectedLeadersRegioned: { 1107 | path: "/searcher.SearcherService/GetConnectedLeadersRegioned", 1108 | requestStream: false, 1109 | responseStream: false, 1110 | requestSerialize: (value: ConnectedLeadersRegionedRequest) => 1111 | Buffer.from(ConnectedLeadersRegionedRequest.encode(value).finish()), 1112 | requestDeserialize: (value: Buffer) => ConnectedLeadersRegionedRequest.decode(value), 1113 | responseSerialize: (value: ConnectedLeadersRegionedResponse) => 1114 | Buffer.from(ConnectedLeadersRegionedResponse.encode(value).finish()), 1115 | responseDeserialize: (value: Buffer) => ConnectedLeadersRegionedResponse.decode(value), 1116 | }, 1117 | /** Returns the tip accounts searchers shall transfer funds to for the leader to claim. */ 1118 | getTipAccounts: { 1119 | path: "/searcher.SearcherService/GetTipAccounts", 1120 | requestStream: false, 1121 | responseStream: false, 1122 | requestSerialize: (value: GetTipAccountsRequest) => Buffer.from(GetTipAccountsRequest.encode(value).finish()), 1123 | requestDeserialize: (value: Buffer) => GetTipAccountsRequest.decode(value), 1124 | responseSerialize: (value: GetTipAccountsResponse) => Buffer.from(GetTipAccountsResponse.encode(value).finish()), 1125 | responseDeserialize: (value: Buffer) => GetTipAccountsResponse.decode(value), 1126 | }, 1127 | /** Returns region the client is directly connected to, along with all available regions */ 1128 | getRegions: { 1129 | path: "/searcher.SearcherService/GetRegions", 1130 | requestStream: false, 1131 | responseStream: false, 1132 | requestSerialize: (value: GetRegionsRequest) => Buffer.from(GetRegionsRequest.encode(value).finish()), 1133 | requestDeserialize: (value: Buffer) => GetRegionsRequest.decode(value), 1134 | responseSerialize: (value: GetRegionsResponse) => Buffer.from(GetRegionsResponse.encode(value).finish()), 1135 | responseDeserialize: (value: Buffer) => GetRegionsResponse.decode(value), 1136 | }, 1137 | } as const; 1138 | 1139 | export interface SearcherServiceServer extends UntypedServiceImplementation { 1140 | /** 1141 | * Searchers can invoke this endpoint to subscribe to their respective bundle results. 1142 | * A success result would indicate the bundle won its state auction and was submitted to the validator. 1143 | */ 1144 | subscribeBundleResults: handleServerStreamingCall; 1145 | sendBundle: handleUnaryCall; 1146 | /** Returns the next scheduled leader connected to the block engine. */ 1147 | getNextScheduledLeader: handleUnaryCall; 1148 | /** Returns leader slots for connected jito validators during the current epoch. Only returns data for this region. */ 1149 | getConnectedLeaders: handleUnaryCall; 1150 | /** Returns leader slots for connected jito validators during the current epoch. */ 1151 | getConnectedLeadersRegioned: handleUnaryCall; 1152 | /** Returns the tip accounts searchers shall transfer funds to for the leader to claim. */ 1153 | getTipAccounts: handleUnaryCall; 1154 | /** Returns region the client is directly connected to, along with all available regions */ 1155 | getRegions: handleUnaryCall; 1156 | } 1157 | 1158 | export interface SearcherServiceClient extends Client { 1159 | /** 1160 | * Searchers can invoke this endpoint to subscribe to their respective bundle results. 1161 | * A success result would indicate the bundle won its state auction and was submitted to the validator. 1162 | */ 1163 | subscribeBundleResults( 1164 | request: SubscribeBundleResultsRequest, 1165 | options?: Partial, 1166 | ): ClientReadableStream; 1167 | subscribeBundleResults( 1168 | request: SubscribeBundleResultsRequest, 1169 | metadata?: Metadata, 1170 | options?: Partial, 1171 | ): ClientReadableStream; 1172 | sendBundle( 1173 | request: SendBundleRequest, 1174 | callback: (error: ServiceError | null, response: SendBundleResponse) => void, 1175 | ): ClientUnaryCall; 1176 | sendBundle( 1177 | request: SendBundleRequest, 1178 | metadata: Metadata, 1179 | callback: (error: ServiceError | null, response: SendBundleResponse) => void, 1180 | ): ClientUnaryCall; 1181 | sendBundle( 1182 | request: SendBundleRequest, 1183 | metadata: Metadata, 1184 | options: Partial, 1185 | callback: (error: ServiceError | null, response: SendBundleResponse) => void, 1186 | ): ClientUnaryCall; 1187 | /** Returns the next scheduled leader connected to the block engine. */ 1188 | getNextScheduledLeader( 1189 | request: NextScheduledLeaderRequest, 1190 | callback: (error: ServiceError | null, response: NextScheduledLeaderResponse) => void, 1191 | ): ClientUnaryCall; 1192 | getNextScheduledLeader( 1193 | request: NextScheduledLeaderRequest, 1194 | metadata: Metadata, 1195 | callback: (error: ServiceError | null, response: NextScheduledLeaderResponse) => void, 1196 | ): ClientUnaryCall; 1197 | getNextScheduledLeader( 1198 | request: NextScheduledLeaderRequest, 1199 | metadata: Metadata, 1200 | options: Partial, 1201 | callback: (error: ServiceError | null, response: NextScheduledLeaderResponse) => void, 1202 | ): ClientUnaryCall; 1203 | /** Returns leader slots for connected jito validators during the current epoch. Only returns data for this region. */ 1204 | getConnectedLeaders( 1205 | request: ConnectedLeadersRequest, 1206 | callback: (error: ServiceError | null, response: ConnectedLeadersResponse) => void, 1207 | ): ClientUnaryCall; 1208 | getConnectedLeaders( 1209 | request: ConnectedLeadersRequest, 1210 | metadata: Metadata, 1211 | callback: (error: ServiceError | null, response: ConnectedLeadersResponse) => void, 1212 | ): ClientUnaryCall; 1213 | getConnectedLeaders( 1214 | request: ConnectedLeadersRequest, 1215 | metadata: Metadata, 1216 | options: Partial, 1217 | callback: (error: ServiceError | null, response: ConnectedLeadersResponse) => void, 1218 | ): ClientUnaryCall; 1219 | /** Returns leader slots for connected jito validators during the current epoch. */ 1220 | getConnectedLeadersRegioned( 1221 | request: ConnectedLeadersRegionedRequest, 1222 | callback: (error: ServiceError | null, response: ConnectedLeadersRegionedResponse) => void, 1223 | ): ClientUnaryCall; 1224 | getConnectedLeadersRegioned( 1225 | request: ConnectedLeadersRegionedRequest, 1226 | metadata: Metadata, 1227 | callback: (error: ServiceError | null, response: ConnectedLeadersRegionedResponse) => void, 1228 | ): ClientUnaryCall; 1229 | getConnectedLeadersRegioned( 1230 | request: ConnectedLeadersRegionedRequest, 1231 | metadata: Metadata, 1232 | options: Partial, 1233 | callback: (error: ServiceError | null, response: ConnectedLeadersRegionedResponse) => void, 1234 | ): ClientUnaryCall; 1235 | /** Returns the tip accounts searchers shall transfer funds to for the leader to claim. */ 1236 | getTipAccounts( 1237 | request: GetTipAccountsRequest, 1238 | callback: (error: ServiceError | null, response: GetTipAccountsResponse) => void, 1239 | ): ClientUnaryCall; 1240 | getTipAccounts( 1241 | request: GetTipAccountsRequest, 1242 | metadata: Metadata, 1243 | callback: (error: ServiceError | null, response: GetTipAccountsResponse) => void, 1244 | ): ClientUnaryCall; 1245 | getTipAccounts( 1246 | request: GetTipAccountsRequest, 1247 | metadata: Metadata, 1248 | options: Partial, 1249 | callback: (error: ServiceError | null, response: GetTipAccountsResponse) => void, 1250 | ): ClientUnaryCall; 1251 | /** Returns region the client is directly connected to, along with all available regions */ 1252 | getRegions( 1253 | request: GetRegionsRequest, 1254 | callback: (error: ServiceError | null, response: GetRegionsResponse) => void, 1255 | ): ClientUnaryCall; 1256 | getRegions( 1257 | request: GetRegionsRequest, 1258 | metadata: Metadata, 1259 | callback: (error: ServiceError | null, response: GetRegionsResponse) => void, 1260 | ): ClientUnaryCall; 1261 | getRegions( 1262 | request: GetRegionsRequest, 1263 | metadata: Metadata, 1264 | options: Partial, 1265 | callback: (error: ServiceError | null, response: GetRegionsResponse) => void, 1266 | ): ClientUnaryCall; 1267 | } 1268 | 1269 | export const SearcherServiceClient = makeGenericClientConstructor( 1270 | SearcherServiceService, 1271 | "searcher.SearcherService", 1272 | ) as unknown as { 1273 | new (address: string, credentials: ChannelCredentials, options?: Partial): SearcherServiceClient; 1274 | service: typeof SearcherServiceService; 1275 | }; 1276 | 1277 | declare var self: any | undefined; 1278 | declare var window: any | undefined; 1279 | declare var global: any | undefined; 1280 | var tsProtoGlobalThis: any = (() => { 1281 | if (typeof globalThis !== "undefined") { 1282 | return globalThis; 1283 | } 1284 | if (typeof self !== "undefined") { 1285 | return self; 1286 | } 1287 | if (typeof window !== "undefined") { 1288 | return window; 1289 | } 1290 | if (typeof global !== "undefined") { 1291 | return global; 1292 | } 1293 | throw "Unable to locate global object"; 1294 | })(); 1295 | 1296 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 1297 | 1298 | export type DeepPartial = T extends Builtin ? T 1299 | : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> 1300 | : T extends {} ? { [K in keyof T]?: DeepPartial } 1301 | : Partial; 1302 | 1303 | type KeysOfUnion = T extends T ? keyof T : never; 1304 | export type Exact = P extends Builtin ? P 1305 | : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; 1306 | 1307 | function longToNumber(long: Long): number { 1308 | if (long.gt(Number.MAX_SAFE_INTEGER)) { 1309 | throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); 1310 | } 1311 | return long.toNumber(); 1312 | } 1313 | 1314 | if (_m0.util.Long !== Long) { 1315 | _m0.util.Long = Long as any; 1316 | _m0.configure(); 1317 | } 1318 | 1319 | function isObject(value: any): boolean { 1320 | return typeof value === "object" && value !== null; 1321 | } 1322 | 1323 | function isSet(value: any): boolean { 1324 | return value !== null && value !== undefined; 1325 | } --------------------------------------------------------------------------------