This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Connection, Keypair, VersionedTransaction } = require ('@solana/web3.js'); | |
const bs58 = require ('bs58'); | |
const axios = require('axios'); | |
// It is recommended that you use your own RPC endpoint. | |
// This RPC endpoint is only for demonstration purposes so that this example will run. | |
const connection = new Connection(''); | |
const keypair = Keypair.fromSecretKey(bs58.decode('')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GetProgramAccountsFilter, PublicKey, TransactionMessage, VersionedTransaction } from "@solana/web3.js"; | |
import { connection } from "../src/connection"; | |
import config from "../src/lib/Config"; | |
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, createBurnCheckedInstruction, createCloseAccountInstruction, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from "@solana/spl-token"; | |
// Not really tested more than two but you can probably fit more in. | |
const maxMintsPerTx = 2; | |
// Replace this with your own keypair | |
const owningAccount = config.keypair; | |
// This creates a tx like this: https://solscan.io/tx/5PegaAnFzaEdVWYfzHFVTzJyZr8wHKRhijgtXyGhNzaQj4HfW5U8BqaaHNhGkCbZRDePns5cnFJAb18RCx4cuLqB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PublicKey, Transaction, TransactionMessage, VersionedTransaction } from "@solana/web3.js"; | |
import config from "../src/lib/Config"; | |
import BigNumber from "bignumber.js"; | |
import { createAssociatedTokenAccountIdempotentInstruction, createTransferCheckedInstruction, getAssociatedTokenAddress, getAssociatedTokenAddressSync } from "@solana/spl-token"; | |
import { connection } from "../src/connection"; | |
import { createComputeBudgetInstruction } from "../src/lib/TransactionBuilder"; | |
/** | |
* Distributes rewards based on a a token amount a user has, e.g. staked or LP tokens. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Account, Mint, TOKEN_PROGRAM_ID, getAssociatedTokenAddress, unpackAccount, unpackMint } from "@solana/spl-token"; | |
import { AccountChangeCallback, AccountInfo, Connection, Keypair, PublicKey } from "@solana/web3.js"; | |
import { WellKnownTokenMint } from "../../const"; | |
import { ToDecimal } from "../../utils"; | |
import { BigNumber } from "bignumber.js"; | |
import { TradeQueueItem, TradeExecutor } from "./trade"; | |
import BalanceQueue from "../queues/balance"; | |
export type BalanceChangeCallback = (queue: BalanceQueue<TradeQueueItem, TradeExecutor>) => Promise<TradeExecutor>; | |
export type BalanceChangeParams = [callback: BalanceChangeCallback, args: BalanceQueue<TradeQueueItem, TradeExecutor>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Connection, | |
CreateNonceAccountParams, | |
Keypair, | |
NONCE_ACCOUNT_LENGTH, | |
PublicKey, | |
SystemProgram, | |
Transaction, | |
TransactionMessage, | |
VersionedTransaction, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { RootDatabaseOptionsWithPath, open } from 'lmdb'; | |
import { addressLookupTableDBPath } from '../const'; | |
const _dbOptions: RootDatabaseOptionsWithPath = { | |
path: addressLookupTableDBPath, | |
cache: { // https://github.com/kriszyp/weak-lru-cache#weaklrucacheoptions-constructor | |
cacheSize: 16777216, // 16MB - maximum | |
clearKeptInterval: 100, | |
txnStartThreshold: 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as nodeFetch from 'node-fetch'; | |
import fetch from 'fetch-retry' | |
import https from 'https'; | |
const _fetch = fetch(nodeFetch.default); | |
type FetchFn = typeof nodeFetch.default; | |
export type Fetcher = (...args: Parameters<FetchFn>) => ReturnType<FetchFn>; | |
export type RetryFetcherWithCustomAgent = (agent: https.Agent) => Fetcher; | |
export const RetryFetcher: Fetcher = (...args) => { | |
const [url, init] = args; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here is a portion of the code used in sexbot.sol that handles errors when sending txs | |
/** | |
* Anchor can't handle all errors for some reason, so this exists to handle those cases | |
* @param logs | |
* @returns | |
*/ | |
export const extractErrorDetailFromLogs = ( | |
logs: string[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By Pyro @ www.sexonsol.com | |
import { Console } from "node:console"; | |
type LogLevel = "INFO" | "ERROR" | "WARN" | "DEBUG" | "TRACE"; | |
/** Asynchronous Promise-based logger */ | |
export default class AsyncLogger extends Console { | |
public name: string; | |
constructor(name: string) { | |
super({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By Pyro @ www.sexonsol.com | |
// Price class, basic types and interface for PriceManager provided for you: | |
import { QuoteResponse } from '@jup-ag/api'; | |
import { BigNumber } from 'bignumber.js'; | |
enum WellKnownTokenMint { | |
USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | |
USDCet = "A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM", |