├── .gitignore ├── README.md ├── cancelAndPost.ts ├── closeOpenOrdersAcc.ts ├── close_market.ts ├── createMarket.ts ├── createOpenOrders.ts ├── createPermissionedMarket.ts ├── create_ltu.ts ├── getMarkets.ts ├── getTotalAmounts.ts ├── mint_utils.ts ├── package-lock.json ├── package.json ├── parseEvent.ts ├── postOrder.ts ├── postOrderUI.ts ├── solana_utils.ts ├── takeOrder.ts ├── tsconfig.json ├── update_ltu.ts └── utils.ts /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | node_modules 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenBook V2 scripts 2 | 3 | Different script with examples showcasing @openbook-dex/openbook-v2 -------------------------------------------------------------------------------- /cancelAndPost.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { PublicKey, Connection, Transaction } from "@solana/web3.js"; 3 | import { authority } from "./utils"; 4 | import { RPC, programId } from "./utils"; 5 | import { 6 | OpenBookV2Client, 7 | PlaceOrderArgs, 8 | Side, 9 | OrderType, 10 | SelfTradeBehavior, 11 | PlaceMultipleOrdersArgs, 12 | } from "@openbook-dex/openbook-v2"; 13 | import { MintUtils } from "./mint_utils"; 14 | 15 | async function main() { 16 | const wallet = new Wallet(authority); 17 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 18 | commitment: "confirmed", 19 | }); 20 | const client = new OpenBookV2Client(provider); 21 | 22 | const marketPublicKey = new PublicKey( 23 | "C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q" 24 | ); 25 | const ooa = await client.findOpenOrdersForMarket( 26 | wallet.publicKey, 27 | marketPublicKey 28 | ); 29 | 30 | if (ooa === null || ooa.length < 1) { 31 | throw "No ooa"; 32 | } 33 | const openOrdersPublicKey = ooa[0]; 34 | 35 | const market = await client.deserializeMarketAccount(marketPublicKey); 36 | if (!market) { 37 | throw "No market"; 38 | } 39 | 40 | let mintUtils = new MintUtils(provider.connection, authority); 41 | 42 | const userQuoteAcc = await mintUtils.getOrCreateTokenAccount( 43 | market?.quoteMint, 44 | authority, 45 | client.walletPk 46 | ); 47 | 48 | const userBaseAcc = await mintUtils.getOrCreateTokenAccount( 49 | market?.baseMint, 50 | authority, 51 | client.walletPk 52 | ); 53 | 54 | const nbOrders: number = 14; 55 | let bids: PlaceMultipleOrdersArgs[] = []; 56 | for (let i = 0; i < nbOrders; ++i) { 57 | bids.push({ 58 | priceLots: new BN(100 - 1 - i), 59 | maxQuoteLotsIncludingFees: new BN(1000), 60 | expiryTimestamp: new BN(0), 61 | }); 62 | } 63 | let asks: PlaceMultipleOrdersArgs[] = []; 64 | for (let i = 0; i < nbOrders; ++i) { 65 | asks.push({ 66 | priceLots: new BN(100 + 1 + i), 67 | maxQuoteLotsIncludingFees: new BN(1000), 68 | expiryTimestamp: new BN(0), 69 | }); 70 | } 71 | 72 | const [ix, signers] = await client.cancelAllAndPlaceOrdersIx( 73 | openOrdersPublicKey, 74 | marketPublicKey, 75 | market, 76 | userBaseAcc.address, 77 | userQuoteAcc.address, 78 | null, 79 | OrderType.ImmediateOrCancel, 80 | bids, 81 | asks 82 | ); 83 | const tx = await client.sendAndConfirmTransaction([ix], { 84 | additionalSigners: [signers], 85 | }); 86 | 87 | console.log("Cancel and place order ", tx); 88 | } 89 | 90 | main(); 91 | -------------------------------------------------------------------------------- /closeOpenOrdersAcc.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { Connection, PublicKey } from "@solana/web3.js"; 3 | import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; 4 | import { OpenBookV2Client } from "@openbook-dex/openbook-v2"; 5 | import { RPC, authority, programId } from "./utils"; 6 | 7 | async function main() { 8 | const wallet = new Wallet(authority); 9 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 10 | commitment: "confirmed", 11 | }); 12 | const client = new OpenBookV2Client(provider); 13 | 14 | const openOrdersPublicKey = new PublicKey( 15 | "6ERLqk3FTiDanviaeCQichY4ntEoDXABGrX99pcji6Hs" 16 | ); 17 | 18 | const [ix, signers] = await client.closeOpenOrdersAccountIx( 19 | wallet.payer, 20 | openOrdersPublicKey 21 | ); 22 | 23 | const tx = await client.sendAndConfirmTransaction([ix], { 24 | additionalSigners: signers, 25 | }); 26 | console.log("close open orders acc", tx); 27 | } 28 | main(); 29 | -------------------------------------------------------------------------------- /close_market.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { PublicKey, Connection } from "@solana/web3.js"; 3 | import { authority } from "./utils"; 4 | import { RPC, programId } from "./utils"; 5 | import { 6 | OpenBookV2Client, 7 | PlaceOrderArgs, 8 | Side, 9 | } from "@openbook-dex/openbook-v2"; 10 | import { MintUtils } from "./mint_utils"; 11 | 12 | async function main() { 13 | const wallet = new Wallet(authority); 14 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 15 | commitment: "confirmed", 16 | }); 17 | const client = new OpenBookV2Client(provider); 18 | 19 | const marketPublicKey = new PublicKey( 20 | "BLr5UmvkfoVC4yth5CX2jBT5X75Z61gkLPMbJRNxiRqa" 21 | ); 22 | const market = await client.deserializeMarketAccount(marketPublicKey); 23 | if (!market) { 24 | throw "No market"; 25 | } 26 | 27 | const eventHeap = await client.deserializeEventHeapAccount(market.eventHeap); 28 | if (!eventHeap) { 29 | throw "No event heap"; 30 | } 31 | console.log("event heap length", eventHeap.header.count); 32 | 33 | if (eventHeap.header.count > 0) { 34 | const accounts = await client.getAccountsToConsume(market); 35 | if (accounts) { 36 | console.log("accounts lenght", accounts.length); 37 | 38 | const ix = await client.consumeEventsIx( 39 | marketPublicKey, 40 | market, 41 | new BN(8), 42 | accounts 43 | ); 44 | const tx = await client.sendAndConfirmTransaction([ix], { 45 | additionalSigners: [], 46 | }); 47 | console.log("Consumed events ", tx); 48 | } 49 | } 50 | 51 | // // const tx2= await client.pruneOrders(marketPublicKey, market, openOrdersPublicKey, 5, wallet.payer) 52 | 53 | const [ix, signers] = await client.closeMarketIx( 54 | marketPublicKey, 55 | market, 56 | wallet.publicKey, 57 | wallet.payer 58 | ); 59 | const tx = await client.sendAndConfirmTransaction([ix], { 60 | additionalSigners: [signers], 61 | }); 62 | console.log("Closed market ", tx); 63 | } 64 | 65 | main(); 66 | -------------------------------------------------------------------------------- /createMarket.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | PublicKey, 4 | ComputeBudgetProgram, 5 | SystemProgram, 6 | Transaction, 7 | Connection, 8 | } from "@solana/web3.js"; 9 | import { 10 | AnchorProvider, 11 | BN, 12 | Program, 13 | Wallet, 14 | getProvider, 15 | } from "@coral-xyz/anchor"; 16 | 17 | import { createAccount } from "./solana_utils"; 18 | import { MintUtils } from "./mint_utils"; 19 | import { OpenBookV2Client } from "@openbook-dex/openbook-v2"; 20 | import { RPC, authority, connection, programId } from "./utils"; 21 | 22 | function delay(ms: number) { 23 | return new Promise((resolve) => setTimeout(resolve, ms)); 24 | } 25 | 26 | async function main() { 27 | const wallet = new Wallet(authority); 28 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 29 | commitment: "confirmed", 30 | }); 31 | const client = new OpenBookV2Client(provider, programId); 32 | 33 | console.log( 34 | "starting with balance: ", 35 | await provider.connection.getBalance(authority.publicKey) 36 | ); 37 | 38 | // const nbMints = 2; 39 | // let mintUtils = new MintUtils(provider.connection, authority); 40 | // let mints = await mintUtils.createMints(nbMints); 41 | // console.log("Mints created"); 42 | // console.log("Mint 0", mints[0].toString()); 43 | // console.log("Mint 1", mints[1].toString()); 44 | // await delay(300); 45 | // const baseMint = mints[1]; 46 | // const quoteMint = mints[0]; 47 | 48 | // In devent 49 | // const baseMint = new PublicKey("DEPipWZkmZcr1sL6pVwj8amRjr9kw91UkFR7tvqdvMy2"); 50 | // const quoteMint = new PublicKey("BfvE9DViu6SkSMBz4TYVftd5DNp7bafemMujXBdVwFYN"); 51 | 52 | // Mainnet acounts for SOL-USDC 53 | // WSOL 54 | const baseMint = new PublicKey("METADDFL6wWMWEoKTFJwcThTbUmtarRJZjRpzUvkxhr"); 55 | // USDC 56 | const quoteMint = new PublicKey( 57 | "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" 58 | ); 59 | 60 | // // Sol/USD 61 | // const oracleAId = new PublicKey( 62 | // "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG" 63 | // ); 64 | // // USDC/USD 65 | // const oracleBId = new PublicKey( 66 | // "Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD" 67 | // ); 68 | const oracleAId = null; 69 | const oracleBId = null; 70 | 71 | // let [oracleAId, _tmp1] = PublicKey.findProgramAddressSync( 72 | // [ 73 | // Buffer.from("StubOracle"), 74 | // adminKp.publicKey.toBytes(), 75 | // baseMint.toBytes(), 76 | // ], 77 | // programId 78 | // ); 79 | 80 | // let [oracleBId, _tmp3] = PublicKey.findProgramAddressSync( 81 | // [ 82 | // Buffer.from("StubOracle"), 83 | // adminKp.publicKey.toBytes(), 84 | // quoteMint.toBytes(), 85 | // ], 86 | // programId 87 | // ); 88 | 89 | // let price = getRandomInt(1000); 90 | 91 | // if ((await anchorProvider.connection.getAccountInfo(oracleAId)) == null) { 92 | // await program.methods 93 | // .stubOracleCreate({ val: new BN(1) }) 94 | // .accounts({ 95 | // payer: adminKp.publicKey, 96 | // oracle: oracleAId, 97 | // mint: baseMint, 98 | // systemProgram: SystemProgram.programId, 99 | // }) 100 | // .signers([adminKp]) 101 | // .rpc(); 102 | // } 103 | // if ((await anchorProvider.connection.getAccountInfo(oracleBId)) == null) { 104 | // await program.methods 105 | // .stubOracleCreate({ val: new BN(1) }) 106 | // .accounts({ 107 | // payer: adminKp.publicKey, 108 | // oracle: oracleBId, 109 | // mint: quoteMint, 110 | // systemProgram: SystemProgram.programId, 111 | // }) 112 | // .signers([adminKp]) 113 | // .rpc(); 114 | // } 115 | 116 | // await program.methods 117 | // .stubOracleSet({ 118 | // val: new BN(price), 119 | // }) 120 | // .accounts({ 121 | // owner: adminKp.publicKey, 122 | // oracle: oracleAId, 123 | // }) 124 | // .signers([adminKp]) 125 | // .rpc(); 126 | 127 | // await program.methods 128 | // .stubOracleSet({ 129 | // val: new BN(price), 130 | // }) 131 | // .accounts({ 132 | // owner: adminKp.publicKey, 133 | // oracle: oracleBId, 134 | // }) 135 | // .signers([adminKp]) 136 | // .rpc(); 137 | 138 | const name = "SOL-USDC"; 139 | 140 | const [ixs, signers] = await client.createMarketIx( 141 | authority.publicKey, 142 | name, 143 | quoteMint, 144 | baseMint, 145 | new BN(1), 146 | new BN(1000000), 147 | new BN(1000), 148 | new BN(1000), 149 | new BN(0), 150 | oracleAId, 151 | oracleBId, 152 | null, 153 | null, 154 | null 155 | ); 156 | 157 | const tx = await client.sendAndConfirmTransaction(ixs, { 158 | additionalSigners: signers, 159 | }); 160 | 161 | console.log("created market", tx); 162 | console.log( 163 | "finished with balance: ", 164 | await connection.getBalance(authority.publicKey) 165 | ); 166 | } 167 | 168 | main(); 169 | -------------------------------------------------------------------------------- /createOpenOrders.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { 3 | Connection, 4 | PublicKey, 5 | SystemProgram, 6 | Transaction, 7 | } from "@solana/web3.js"; 8 | import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; 9 | import { OpenBookV2Client } from "@openbook-dex/openbook-v2"; 10 | import { RPC, authority, programId } from "./utils"; 11 | 12 | const createIndexer = true; 13 | async function main() { 14 | const wallet = new Wallet(authority); 15 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 16 | commitment: "confirmed", 17 | }); 18 | const client = new OpenBookV2Client(provider); 19 | 20 | const market = new PublicKey("C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q"); 21 | const accountIndex = new BN(1); 22 | const openOrdersIndexer = new PublicKey( 23 | "3zfApGWevn9t5Bu46WHQm8KNHCd8VwXfzeEmY1ANhEAB" 24 | ); 25 | 26 | const tx = await client.createOpenOrders(wallet.payer, market, "name"); 27 | console.log("created open orders acc", tx); 28 | } 29 | main(); 30 | -------------------------------------------------------------------------------- /createPermissionedMarket.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | PublicKey, 4 | ComputeBudgetProgram, 5 | SystemProgram, 6 | Transaction, 7 | Connection, 8 | } from "@solana/web3.js"; 9 | import { 10 | AnchorProvider, 11 | BN, 12 | Program, 13 | Wallet, 14 | getProvider, 15 | } from "@coral-xyz/anchor"; 16 | 17 | import { createAccount } from "./solana_utils"; 18 | import { MintUtils } from "./mint_utils"; 19 | import { 20 | OpenBookV2Client, 21 | type OracleConfigParams, 22 | } from "@openbook-dex/openbook-v2"; 23 | import { RPC, authority, connection, programId } from "./utils"; 24 | 25 | function delay(ms: number) { 26 | return new Promise((resolve) => setTimeout(resolve, ms)); 27 | } 28 | 29 | async function main() { 30 | const wallet = new Wallet(authority); 31 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 32 | commitment: "confirmed", 33 | }); 34 | const client = new OpenBookV2Client(provider, programId); 35 | 36 | console.log( 37 | "starting with balance: ", 38 | await provider.connection.getBalance(authority.publicKey) 39 | ); 40 | 41 | // WSOL 42 | const baseMint = new PublicKey("So11111111111111111111111111111111111111112"); 43 | // USDC 44 | const quoteMint = new PublicKey( 45 | "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" 46 | ); 47 | 48 | // Sol/USD 49 | const oracleAId = new PublicKey( 50 | "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG" 51 | ); 52 | // USDC/USD 53 | const oracleBId = new PublicKey( 54 | "Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD" 55 | ); 56 | 57 | const name = "SOL-USDC"; 58 | 59 | // expiricy in 10 days 60 | const expiry = Math.floor(Date.now() / 1000) + 10 * 86400; 61 | 62 | const oracleConfigParams: OracleConfigParams = { 63 | confFilter: 0.1, 64 | maxStalenessSlots: 100, 65 | }; 66 | const [ixs, signers] = await client.createMarketIx( 67 | authority.publicKey, 68 | name, 69 | quoteMint, 70 | baseMint, 71 | new BN(1), 72 | new BN(1000000), 73 | new BN(0), 74 | new BN(0), 75 | new BN(expiry), 76 | oracleAId, 77 | oracleBId, 78 | null, 79 | null, 80 | wallet.publicKey, 81 | oracleConfigParams 82 | ); 83 | const tx = await client.sendAndConfirmTransaction(ixs, { 84 | additionalSigners: [signers], 85 | }); 86 | console.log("created market", tx); 87 | console.log( 88 | "finished with balance: ", 89 | await connection.getBalance(authority.publicKey) 90 | ); 91 | } 92 | 93 | main(); 94 | -------------------------------------------------------------------------------- /create_ltu.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { 3 | Connection, 4 | AddressLookupTableProgram, 5 | TransactionMessage, 6 | VersionedTransaction, 7 | } from "@solana/web3.js"; 8 | import { authority } from "./utils"; 9 | import { RPC } from "./utils"; 10 | import { OpenBookV2Client } from "@openbook-dex/openbook-v2"; 11 | 12 | async function main() { 13 | const wallet = new Wallet(authority); 14 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 15 | commitment: "confirmed", 16 | }); 17 | const client = new OpenBookV2Client(provider); 18 | 19 | // Step 1 - Get a lookup table address and create lookup table instruction 20 | const [txInstructions, lookupTableAddress] = 21 | AddressLookupTableProgram.createLookupTable({ 22 | authority: wallet.publicKey, 23 | payer: wallet.publicKey, 24 | recentSlot: await client.connection.getSlot(), 25 | }); 26 | 27 | // Step 2 - Log Lookup Table Address 28 | console.log("Lookup Table Address:", lookupTableAddress.toBase58()); 29 | 30 | let latestBlockhash = await client.connection.getLatestBlockhash("finalized"); 31 | 32 | const messageV0 = new TransactionMessage({ 33 | payerKey: wallet.publicKey, 34 | recentBlockhash: latestBlockhash.blockhash, 35 | instructions: [txInstructions], 36 | }).compileToV0Message(); 37 | 38 | const transaction = new VersionedTransaction(messageV0); 39 | transaction.sign([wallet.payer]); 40 | 41 | const txid = await client.connection.sendTransaction(transaction, { 42 | maxRetries: 5, 43 | }); 44 | 45 | const confirmation = await client.connection.confirmTransaction({ 46 | signature: txid, 47 | blockhash: latestBlockhash.blockhash, 48 | lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, 49 | }); 50 | if (confirmation.value.err) { 51 | throw new Error(" ❌ - Transaction not confirmed."); 52 | } 53 | console.log( 54 | "🎉 Transaction succesfully confirmed!", 55 | "\n", 56 | `https://explorer.solana.com/tx/${txid}?cluster=devnet` 57 | ); 58 | } 59 | 60 | main(); 61 | -------------------------------------------------------------------------------- /getMarkets.ts: -------------------------------------------------------------------------------- 1 | import { Connection, PublicKey } from "@solana/web3.js"; 2 | import { getProvider, Program } from "@coral-xyz/anchor"; 3 | import { RPC, getKeypairFromFile, programId } from "./utils"; 4 | import * as os from "os"; 5 | import { 6 | OpenBookV2Client, 7 | IDL, 8 | type OpenbookV2, 9 | findAllMarkets, 10 | } from "@openbook-dex/openbook-v2"; 11 | 12 | async function main() { 13 | const connection = new Connection(RPC, "confirmed"); 14 | 15 | let markets = await findAllMarkets(connection, programId); 16 | 17 | console.log(markets); 18 | } 19 | 20 | main(); 21 | -------------------------------------------------------------------------------- /getTotalAmounts.ts: -------------------------------------------------------------------------------- 1 | import { PublicKey, Connection } from "@solana/web3.js"; 2 | import { AnchorProvider, BN, Wallet, BorshCoder } from "@coral-xyz/anchor"; 3 | import { RPC, programId } from "./utils"; 4 | 5 | import { authority } from "./utils"; 6 | import { 7 | OpenBookV2Client, 8 | PlaceOrderArgs, 9 | Side, 10 | IDL, 11 | } from "@openbook-dex/openbook-v2"; 12 | import { toUiDecimals } from "@openbook-dex/openbook-v2"; 13 | import { quoteLotsToUi } from "@openbook-dex/openbook-v2"; 14 | 15 | async function main() { 16 | const wallet = new Wallet(authority); 17 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 18 | commitment: "confirmed", 19 | }); 20 | const client = new OpenBookV2Client(provider); 21 | 22 | const marketPubkey = new PublicKey( 23 | "C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q" 24 | ); 25 | const owner = new PublicKey("J9zjCmmGBfv6wDSwmRW43vVJ6vooCftXjQYtc7uhETdr"); 26 | 27 | const market = await client.deserializeMarketAccount(marketPubkey); 28 | 29 | if (market === null) { 30 | throw "No market"; 31 | } 32 | const openorders = await client.findOpenOrdersForMarket(owner, marketPubkey); 33 | let totalQuoteBids = 0; 34 | 35 | for (const openOrderPubkey of openorders) { 36 | const openOrder = await client.deserializeOpenOrderAccount(openOrderPubkey); 37 | 38 | if (openOrder) { 39 | if (openOrder.version != 1){ 40 | throw "using an old open orders account, please close it" 41 | } 42 | console.log("bidsQuoteLots", openOrder.position.bidsQuoteLots.toNumber()); 43 | console.log("asksBaseLots", openOrder.position.asksBaseLots.toNumber()); 44 | } 45 | } 46 | 47 | console.log("totalQuoteBidsNative", totalQuoteBids); 48 | } 49 | 50 | function priceData(key: BN) { 51 | const shiftedValue = key.shrn(64); // Shift right by 64 bits 52 | return shiftedValue.toNumber(); // Convert BN to a regular number 53 | } 54 | 55 | main(); 56 | -------------------------------------------------------------------------------- /mint_utils.ts: -------------------------------------------------------------------------------- 1 | import * as splToken from "@solana/spl-token"; 2 | import { PublicKey, Connection, Keypair } from "@solana/web3.js"; 3 | 4 | export interface TokenData { 5 | mint: PublicKey; 6 | startingPrice: number; 7 | nbDecimals: number; 8 | priceOracle: Keypair | undefined; 9 | } 10 | 11 | export class MintUtils { 12 | private conn: Connection; 13 | private authority: Keypair; 14 | 15 | constructor(conn: Connection, authority: Keypair) { 16 | this.conn = conn; 17 | this.authority = authority; 18 | } 19 | 20 | async createMint(nb_decimals = 6): Promise { 21 | const kp = Keypair.generate(); 22 | return await splToken.createMint( 23 | this.conn, 24 | this.authority, 25 | this.authority.publicKey, 26 | this.authority.publicKey, 27 | nb_decimals, 28 | kp 29 | ); 30 | } 31 | 32 | public async createMints(nbMints: number): Promise { 33 | return await Promise.all( 34 | Array.from(Array(nbMints).keys()).map((_) => { 35 | return this.createMint(); 36 | }) 37 | ); 38 | } 39 | 40 | public async createNewToken(nbDecimals = 6, startingPrice = 1_000_000) { 41 | const mint = await this.createMint(nbDecimals); 42 | const tokenData: TokenData = { 43 | mint: mint, 44 | startingPrice: startingPrice, 45 | nbDecimals: nbDecimals, 46 | priceOracle: undefined, 47 | }; 48 | return tokenData; 49 | } 50 | 51 | public async createTokenAccount( 52 | mint: PublicKey, 53 | payer: Keypair, 54 | owner: PublicKey 55 | ) { 56 | const account = Keypair.generate(); 57 | return splToken.createAccount(this.conn, payer, mint, owner, account); 58 | } 59 | 60 | public async getOrCreateTokenAccount( 61 | mint: PublicKey, 62 | payer: Keypair, 63 | owner: PublicKey 64 | ) { 65 | return await splToken.getOrCreateAssociatedTokenAccount( 66 | this.conn, 67 | payer, 68 | mint, 69 | owner, 70 | false 71 | ); 72 | } 73 | 74 | public async mintTo(mint: PublicKey, tokenAccount: PublicKey) { 75 | await splToken.mintTo( 76 | this.conn, 77 | this.authority, 78 | mint, 79 | tokenAccount, 80 | this.authority, 81 | 1000000000000 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yolodolo", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "yolodolo", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@coral-xyz/anchor": "^0.28.1-beta.1", 13 | "@openbook-dex/openbook-v2": "^0.1.5", 14 | "@solana/spl-token": "^0.3.8", 15 | "@solana/web3.js": "^1.78.3" 16 | }, 17 | "devDependencies": { 18 | "@types/node": "^20.5.0", 19 | "ts-node": "^10.9.1", 20 | "typescript": "^5.1.6" 21 | } 22 | }, 23 | "node_modules/@babel/runtime": { 24 | "version": "7.22.6", 25 | "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz", 26 | "integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==", 27 | "dependencies": { 28 | "regenerator-runtime": "^0.13.11" 29 | }, 30 | "engines": { 31 | "node": ">=6.9.0" 32 | } 33 | }, 34 | "node_modules/@coral-xyz/anchor": { 35 | "version": "0.28.1-beta.2", 36 | "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.28.1-beta.2.tgz", 37 | "integrity": "sha512-xreUcOFF8+IQKWOBUrDKJbIw2ftpRVybFlEPVrbSlOBCbreCWrQ5754Gt9cHIcuBDAzearCDiBqzsGQdNgPJiw==", 38 | "dependencies": { 39 | "@coral-xyz/borsh": "^0.28.0", 40 | "@noble/hashes": "^1.3.1", 41 | "@solana/web3.js": "^1.68.0", 42 | "base64-js": "^1.5.1", 43 | "bn.js": "^5.1.2", 44 | "bs58": "^4.0.1", 45 | "buffer-layout": "^1.2.2", 46 | "camelcase": "^6.3.0", 47 | "cross-fetch": "^3.1.5", 48 | "crypto-hash": "^1.3.0", 49 | "eventemitter3": "^4.0.7", 50 | "pako": "^2.0.3", 51 | "snake-case": "^3.0.4", 52 | "superstruct": "^0.15.4", 53 | "toml": "^3.0.0" 54 | }, 55 | "engines": { 56 | "node": ">=11" 57 | } 58 | }, 59 | "node_modules/@coral-xyz/anchor/node_modules/superstruct": { 60 | "version": "0.15.5", 61 | "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", 62 | "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==" 63 | }, 64 | "node_modules/@coral-xyz/borsh": { 65 | "version": "0.28.0", 66 | "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.28.0.tgz", 67 | "integrity": "sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ==", 68 | "dependencies": { 69 | "bn.js": "^5.1.2", 70 | "buffer-layout": "^1.2.0" 71 | }, 72 | "engines": { 73 | "node": ">=10" 74 | }, 75 | "peerDependencies": { 76 | "@solana/web3.js": "^1.68.0" 77 | } 78 | }, 79 | "node_modules/@cspotcode/source-map-support": { 80 | "version": "0.8.1", 81 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 82 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 83 | "dev": true, 84 | "dependencies": { 85 | "@jridgewell/trace-mapping": "0.3.9" 86 | }, 87 | "engines": { 88 | "node": ">=12" 89 | } 90 | }, 91 | "node_modules/@jridgewell/resolve-uri": { 92 | "version": "3.1.1", 93 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", 94 | "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", 95 | "dev": true, 96 | "engines": { 97 | "node": ">=6.0.0" 98 | } 99 | }, 100 | "node_modules/@jridgewell/sourcemap-codec": { 101 | "version": "1.4.15", 102 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 103 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 104 | "dev": true 105 | }, 106 | "node_modules/@jridgewell/trace-mapping": { 107 | "version": "0.3.9", 108 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 109 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 110 | "dev": true, 111 | "dependencies": { 112 | "@jridgewell/resolve-uri": "^3.0.3", 113 | "@jridgewell/sourcemap-codec": "^1.4.10" 114 | } 115 | }, 116 | "node_modules/@noble/curves": { 117 | "version": "1.1.0", 118 | "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", 119 | "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", 120 | "dependencies": { 121 | "@noble/hashes": "1.3.1" 122 | }, 123 | "funding": { 124 | "url": "https://paulmillr.com/funding/" 125 | } 126 | }, 127 | "node_modules/@noble/hashes": { 128 | "version": "1.3.1", 129 | "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", 130 | "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", 131 | "engines": { 132 | "node": ">= 16" 133 | }, 134 | "funding": { 135 | "url": "https://paulmillr.com/funding/" 136 | } 137 | }, 138 | "node_modules/@openbook-dex/openbook-v2": { 139 | "version": "0.1.5", 140 | "resolved": "https://registry.npmjs.org/@openbook-dex/openbook-v2/-/openbook-v2-0.1.5.tgz", 141 | "integrity": "sha512-ndeWAUETtxDdAjptUJKcI4w+ZLPjF7ehfbYj4twTTz+St3i/sZV3te4R5CWRGH6nqRU4jyAWuuNYebcx+w+WSw==", 142 | "dependencies": { 143 | "@coral-xyz/anchor": "^0.28.1-beta.2", 144 | "@solana/spl-token": "0.3.8", 145 | "@solana/web3.js": "^1.77.3", 146 | "big.js": "^6.2.1" 147 | } 148 | }, 149 | "node_modules/@solana/buffer-layout": { 150 | "version": "4.0.1", 151 | "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", 152 | "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", 153 | "dependencies": { 154 | "buffer": "~6.0.3" 155 | }, 156 | "engines": { 157 | "node": ">=5.10" 158 | } 159 | }, 160 | "node_modules/@solana/buffer-layout-utils": { 161 | "version": "0.2.0", 162 | "resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz", 163 | "integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==", 164 | "dependencies": { 165 | "@solana/buffer-layout": "^4.0.0", 166 | "@solana/web3.js": "^1.32.0", 167 | "bigint-buffer": "^1.1.5", 168 | "bignumber.js": "^9.0.1" 169 | }, 170 | "engines": { 171 | "node": ">= 10" 172 | } 173 | }, 174 | "node_modules/@solana/spl-token": { 175 | "version": "0.3.8", 176 | "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.8.tgz", 177 | "integrity": "sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg==", 178 | "dependencies": { 179 | "@solana/buffer-layout": "^4.0.0", 180 | "@solana/buffer-layout-utils": "^0.2.0", 181 | "buffer": "^6.0.3" 182 | }, 183 | "engines": { 184 | "node": ">=16" 185 | }, 186 | "peerDependencies": { 187 | "@solana/web3.js": "^1.47.4" 188 | } 189 | }, 190 | "node_modules/@solana/web3.js": { 191 | "version": "1.78.3", 192 | "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.78.3.tgz", 193 | "integrity": "sha512-qhpnyIlrj/4Czw1dBFZK6KgZBk5FwuJhvMl0C7m94jhl90yDC8b6w4svKwPjhB+OOrdQAzHyRp0+ocEs/Liw7w==", 194 | "dependencies": { 195 | "@babel/runtime": "^7.22.6", 196 | "@noble/curves": "^1.0.0", 197 | "@noble/hashes": "^1.3.0", 198 | "@solana/buffer-layout": "^4.0.0", 199 | "agentkeepalive": "^4.3.0", 200 | "bigint-buffer": "^1.1.5", 201 | "bn.js": "^5.2.1", 202 | "borsh": "^0.7.0", 203 | "bs58": "^4.0.1", 204 | "buffer": "6.0.3", 205 | "fast-stable-stringify": "^1.0.0", 206 | "jayson": "^4.1.0", 207 | "node-fetch": "^2.6.12", 208 | "rpc-websockets": "^7.5.1", 209 | "superstruct": "^0.14.2" 210 | } 211 | }, 212 | "node_modules/@tsconfig/node10": { 213 | "version": "1.0.9", 214 | "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", 215 | "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", 216 | "dev": true 217 | }, 218 | "node_modules/@tsconfig/node12": { 219 | "version": "1.0.11", 220 | "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", 221 | "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", 222 | "dev": true 223 | }, 224 | "node_modules/@tsconfig/node14": { 225 | "version": "1.0.3", 226 | "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", 227 | "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", 228 | "dev": true 229 | }, 230 | "node_modules/@tsconfig/node16": { 231 | "version": "1.0.4", 232 | "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", 233 | "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", 234 | "dev": true 235 | }, 236 | "node_modules/@types/connect": { 237 | "version": "3.4.35", 238 | "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", 239 | "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", 240 | "dependencies": { 241 | "@types/node": "*" 242 | } 243 | }, 244 | "node_modules/@types/node": { 245 | "version": "20.5.0", 246 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", 247 | "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==" 248 | }, 249 | "node_modules/@types/ws": { 250 | "version": "7.4.7", 251 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", 252 | "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", 253 | "dependencies": { 254 | "@types/node": "*" 255 | } 256 | }, 257 | "node_modules/acorn": { 258 | "version": "8.10.0", 259 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", 260 | "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", 261 | "dev": true, 262 | "bin": { 263 | "acorn": "bin/acorn" 264 | }, 265 | "engines": { 266 | "node": ">=0.4.0" 267 | } 268 | }, 269 | "node_modules/acorn-walk": { 270 | "version": "8.2.0", 271 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", 272 | "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", 273 | "dev": true, 274 | "engines": { 275 | "node": ">=0.4.0" 276 | } 277 | }, 278 | "node_modules/agentkeepalive": { 279 | "version": "4.5.0", 280 | "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", 281 | "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", 282 | "dependencies": { 283 | "humanize-ms": "^1.2.1" 284 | }, 285 | "engines": { 286 | "node": ">= 8.0.0" 287 | } 288 | }, 289 | "node_modules/arg": { 290 | "version": "4.1.3", 291 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", 292 | "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", 293 | "dev": true 294 | }, 295 | "node_modules/base-x": { 296 | "version": "3.0.9", 297 | "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", 298 | "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", 299 | "dependencies": { 300 | "safe-buffer": "^5.0.1" 301 | } 302 | }, 303 | "node_modules/base64-js": { 304 | "version": "1.5.1", 305 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 306 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", 307 | "funding": [ 308 | { 309 | "type": "github", 310 | "url": "https://github.com/sponsors/feross" 311 | }, 312 | { 313 | "type": "patreon", 314 | "url": "https://www.patreon.com/feross" 315 | }, 316 | { 317 | "type": "consulting", 318 | "url": "https://feross.org/support" 319 | } 320 | ] 321 | }, 322 | "node_modules/big.js": { 323 | "version": "6.2.1", 324 | "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.2.1.tgz", 325 | "integrity": "sha512-bCtHMwL9LeDIozFn+oNhhFoq+yQ3BNdnsLSASUxLciOb1vgvpHsIO1dsENiGMgbb4SkP5TrzWzRiLddn8ahVOQ==", 326 | "engines": { 327 | "node": "*" 328 | }, 329 | "funding": { 330 | "type": "opencollective", 331 | "url": "https://opencollective.com/bigjs" 332 | } 333 | }, 334 | "node_modules/bigint-buffer": { 335 | "version": "1.1.5", 336 | "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", 337 | "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", 338 | "hasInstallScript": true, 339 | "dependencies": { 340 | "bindings": "^1.3.0" 341 | }, 342 | "engines": { 343 | "node": ">= 10.0.0" 344 | } 345 | }, 346 | "node_modules/bignumber.js": { 347 | "version": "9.1.1", 348 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", 349 | "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", 350 | "engines": { 351 | "node": "*" 352 | } 353 | }, 354 | "node_modules/bindings": { 355 | "version": "1.5.0", 356 | "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", 357 | "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", 358 | "dependencies": { 359 | "file-uri-to-path": "1.0.0" 360 | } 361 | }, 362 | "node_modules/bn.js": { 363 | "version": "5.2.1", 364 | "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", 365 | "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" 366 | }, 367 | "node_modules/borsh": { 368 | "version": "0.7.0", 369 | "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", 370 | "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", 371 | "dependencies": { 372 | "bn.js": "^5.2.0", 373 | "bs58": "^4.0.0", 374 | "text-encoding-utf-8": "^1.0.2" 375 | } 376 | }, 377 | "node_modules/bs58": { 378 | "version": "4.0.1", 379 | "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", 380 | "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", 381 | "dependencies": { 382 | "base-x": "^3.0.2" 383 | } 384 | }, 385 | "node_modules/buffer": { 386 | "version": "6.0.3", 387 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", 388 | "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", 389 | "funding": [ 390 | { 391 | "type": "github", 392 | "url": "https://github.com/sponsors/feross" 393 | }, 394 | { 395 | "type": "patreon", 396 | "url": "https://www.patreon.com/feross" 397 | }, 398 | { 399 | "type": "consulting", 400 | "url": "https://feross.org/support" 401 | } 402 | ], 403 | "dependencies": { 404 | "base64-js": "^1.3.1", 405 | "ieee754": "^1.2.1" 406 | } 407 | }, 408 | "node_modules/buffer-layout": { 409 | "version": "1.2.2", 410 | "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", 411 | "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", 412 | "engines": { 413 | "node": ">=4.5" 414 | } 415 | }, 416 | "node_modules/bufferutil": { 417 | "version": "4.0.7", 418 | "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", 419 | "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", 420 | "hasInstallScript": true, 421 | "optional": true, 422 | "dependencies": { 423 | "node-gyp-build": "^4.3.0" 424 | }, 425 | "engines": { 426 | "node": ">=6.14.2" 427 | } 428 | }, 429 | "node_modules/camelcase": { 430 | "version": "6.3.0", 431 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", 432 | "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", 433 | "engines": { 434 | "node": ">=10" 435 | }, 436 | "funding": { 437 | "url": "https://github.com/sponsors/sindresorhus" 438 | } 439 | }, 440 | "node_modules/commander": { 441 | "version": "2.20.3", 442 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", 443 | "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" 444 | }, 445 | "node_modules/create-require": { 446 | "version": "1.1.1", 447 | "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", 448 | "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", 449 | "dev": true 450 | }, 451 | "node_modules/cross-fetch": { 452 | "version": "3.1.8", 453 | "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", 454 | "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", 455 | "dependencies": { 456 | "node-fetch": "^2.6.12" 457 | } 458 | }, 459 | "node_modules/crypto-hash": { 460 | "version": "1.3.0", 461 | "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", 462 | "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==", 463 | "engines": { 464 | "node": ">=8" 465 | }, 466 | "funding": { 467 | "url": "https://github.com/sponsors/sindresorhus" 468 | } 469 | }, 470 | "node_modules/delay": { 471 | "version": "5.0.0", 472 | "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", 473 | "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", 474 | "engines": { 475 | "node": ">=10" 476 | }, 477 | "funding": { 478 | "url": "https://github.com/sponsors/sindresorhus" 479 | } 480 | }, 481 | "node_modules/diff": { 482 | "version": "4.0.2", 483 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 484 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 485 | "dev": true, 486 | "engines": { 487 | "node": ">=0.3.1" 488 | } 489 | }, 490 | "node_modules/dot-case": { 491 | "version": "3.0.4", 492 | "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", 493 | "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", 494 | "dependencies": { 495 | "no-case": "^3.0.4", 496 | "tslib": "^2.0.3" 497 | } 498 | }, 499 | "node_modules/es6-promise": { 500 | "version": "4.2.8", 501 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", 502 | "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" 503 | }, 504 | "node_modules/es6-promisify": { 505 | "version": "5.0.0", 506 | "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", 507 | "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", 508 | "dependencies": { 509 | "es6-promise": "^4.0.3" 510 | } 511 | }, 512 | "node_modules/eventemitter3": { 513 | "version": "4.0.7", 514 | "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", 515 | "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" 516 | }, 517 | "node_modules/eyes": { 518 | "version": "0.1.8", 519 | "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", 520 | "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", 521 | "engines": { 522 | "node": "> 0.1.90" 523 | } 524 | }, 525 | "node_modules/fast-stable-stringify": { 526 | "version": "1.0.0", 527 | "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", 528 | "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" 529 | }, 530 | "node_modules/file-uri-to-path": { 531 | "version": "1.0.0", 532 | "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", 533 | "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" 534 | }, 535 | "node_modules/humanize-ms": { 536 | "version": "1.2.1", 537 | "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", 538 | "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", 539 | "dependencies": { 540 | "ms": "^2.0.0" 541 | } 542 | }, 543 | "node_modules/ieee754": { 544 | "version": "1.2.1", 545 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", 546 | "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", 547 | "funding": [ 548 | { 549 | "type": "github", 550 | "url": "https://github.com/sponsors/feross" 551 | }, 552 | { 553 | "type": "patreon", 554 | "url": "https://www.patreon.com/feross" 555 | }, 556 | { 557 | "type": "consulting", 558 | "url": "https://feross.org/support" 559 | } 560 | ] 561 | }, 562 | "node_modules/isomorphic-ws": { 563 | "version": "4.0.1", 564 | "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", 565 | "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", 566 | "peerDependencies": { 567 | "ws": "*" 568 | } 569 | }, 570 | "node_modules/jayson": { 571 | "version": "4.1.0", 572 | "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.0.tgz", 573 | "integrity": "sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==", 574 | "dependencies": { 575 | "@types/connect": "^3.4.33", 576 | "@types/node": "^12.12.54", 577 | "@types/ws": "^7.4.4", 578 | "commander": "^2.20.3", 579 | "delay": "^5.0.0", 580 | "es6-promisify": "^5.0.0", 581 | "eyes": "^0.1.8", 582 | "isomorphic-ws": "^4.0.1", 583 | "json-stringify-safe": "^5.0.1", 584 | "JSONStream": "^1.3.5", 585 | "uuid": "^8.3.2", 586 | "ws": "^7.4.5" 587 | }, 588 | "bin": { 589 | "jayson": "bin/jayson.js" 590 | }, 591 | "engines": { 592 | "node": ">=8" 593 | } 594 | }, 595 | "node_modules/jayson/node_modules/@types/node": { 596 | "version": "12.20.55", 597 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", 598 | "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" 599 | }, 600 | "node_modules/json-stringify-safe": { 601 | "version": "5.0.1", 602 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 603 | "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" 604 | }, 605 | "node_modules/jsonparse": { 606 | "version": "1.3.1", 607 | "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", 608 | "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", 609 | "engines": [ 610 | "node >= 0.2.0" 611 | ] 612 | }, 613 | "node_modules/JSONStream": { 614 | "version": "1.3.5", 615 | "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", 616 | "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", 617 | "dependencies": { 618 | "jsonparse": "^1.2.0", 619 | "through": ">=2.2.7 <3" 620 | }, 621 | "bin": { 622 | "JSONStream": "bin.js" 623 | }, 624 | "engines": { 625 | "node": "*" 626 | } 627 | }, 628 | "node_modules/lower-case": { 629 | "version": "2.0.2", 630 | "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", 631 | "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", 632 | "dependencies": { 633 | "tslib": "^2.0.3" 634 | } 635 | }, 636 | "node_modules/make-error": { 637 | "version": "1.3.6", 638 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", 639 | "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", 640 | "dev": true 641 | }, 642 | "node_modules/ms": { 643 | "version": "2.1.3", 644 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 645 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 646 | }, 647 | "node_modules/no-case": { 648 | "version": "3.0.4", 649 | "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", 650 | "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", 651 | "dependencies": { 652 | "lower-case": "^2.0.2", 653 | "tslib": "^2.0.3" 654 | } 655 | }, 656 | "node_modules/node-fetch": { 657 | "version": "2.6.12", 658 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", 659 | "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", 660 | "dependencies": { 661 | "whatwg-url": "^5.0.0" 662 | }, 663 | "engines": { 664 | "node": "4.x || >=6.0.0" 665 | }, 666 | "peerDependencies": { 667 | "encoding": "^0.1.0" 668 | }, 669 | "peerDependenciesMeta": { 670 | "encoding": { 671 | "optional": true 672 | } 673 | } 674 | }, 675 | "node_modules/node-gyp-build": { 676 | "version": "4.6.0", 677 | "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", 678 | "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", 679 | "optional": true, 680 | "bin": { 681 | "node-gyp-build": "bin.js", 682 | "node-gyp-build-optional": "optional.js", 683 | "node-gyp-build-test": "build-test.js" 684 | } 685 | }, 686 | "node_modules/pako": { 687 | "version": "2.1.0", 688 | "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", 689 | "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" 690 | }, 691 | "node_modules/regenerator-runtime": { 692 | "version": "0.13.11", 693 | "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", 694 | "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" 695 | }, 696 | "node_modules/rpc-websockets": { 697 | "version": "7.5.1", 698 | "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.1.tgz", 699 | "integrity": "sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==", 700 | "dependencies": { 701 | "@babel/runtime": "^7.17.2", 702 | "eventemitter3": "^4.0.7", 703 | "uuid": "^8.3.2", 704 | "ws": "^8.5.0" 705 | }, 706 | "funding": { 707 | "type": "paypal", 708 | "url": "https://paypal.me/kozjak" 709 | }, 710 | "optionalDependencies": { 711 | "bufferutil": "^4.0.1", 712 | "utf-8-validate": "^5.0.2" 713 | } 714 | }, 715 | "node_modules/rpc-websockets/node_modules/ws": { 716 | "version": "8.13.0", 717 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", 718 | "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", 719 | "engines": { 720 | "node": ">=10.0.0" 721 | }, 722 | "peerDependencies": { 723 | "bufferutil": "^4.0.1", 724 | "utf-8-validate": ">=5.0.2" 725 | }, 726 | "peerDependenciesMeta": { 727 | "bufferutil": { 728 | "optional": true 729 | }, 730 | "utf-8-validate": { 731 | "optional": true 732 | } 733 | } 734 | }, 735 | "node_modules/safe-buffer": { 736 | "version": "5.2.1", 737 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 738 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 739 | "funding": [ 740 | { 741 | "type": "github", 742 | "url": "https://github.com/sponsors/feross" 743 | }, 744 | { 745 | "type": "patreon", 746 | "url": "https://www.patreon.com/feross" 747 | }, 748 | { 749 | "type": "consulting", 750 | "url": "https://feross.org/support" 751 | } 752 | ] 753 | }, 754 | "node_modules/snake-case": { 755 | "version": "3.0.4", 756 | "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", 757 | "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", 758 | "dependencies": { 759 | "dot-case": "^3.0.4", 760 | "tslib": "^2.0.3" 761 | } 762 | }, 763 | "node_modules/superstruct": { 764 | "version": "0.14.2", 765 | "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", 766 | "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" 767 | }, 768 | "node_modules/text-encoding-utf-8": { 769 | "version": "1.0.2", 770 | "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", 771 | "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" 772 | }, 773 | "node_modules/through": { 774 | "version": "2.3.8", 775 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", 776 | "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" 777 | }, 778 | "node_modules/toml": { 779 | "version": "3.0.0", 780 | "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", 781 | "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" 782 | }, 783 | "node_modules/tr46": { 784 | "version": "0.0.3", 785 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 786 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 787 | }, 788 | "node_modules/ts-node": { 789 | "version": "10.9.1", 790 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", 791 | "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", 792 | "dev": true, 793 | "dependencies": { 794 | "@cspotcode/source-map-support": "^0.8.0", 795 | "@tsconfig/node10": "^1.0.7", 796 | "@tsconfig/node12": "^1.0.7", 797 | "@tsconfig/node14": "^1.0.0", 798 | "@tsconfig/node16": "^1.0.2", 799 | "acorn": "^8.4.1", 800 | "acorn-walk": "^8.1.1", 801 | "arg": "^4.1.0", 802 | "create-require": "^1.1.0", 803 | "diff": "^4.0.1", 804 | "make-error": "^1.1.1", 805 | "v8-compile-cache-lib": "^3.0.1", 806 | "yn": "3.1.1" 807 | }, 808 | "bin": { 809 | "ts-node": "dist/bin.js", 810 | "ts-node-cwd": "dist/bin-cwd.js", 811 | "ts-node-esm": "dist/bin-esm.js", 812 | "ts-node-script": "dist/bin-script.js", 813 | "ts-node-transpile-only": "dist/bin-transpile.js", 814 | "ts-script": "dist/bin-script-deprecated.js" 815 | }, 816 | "peerDependencies": { 817 | "@swc/core": ">=1.2.50", 818 | "@swc/wasm": ">=1.2.50", 819 | "@types/node": "*", 820 | "typescript": ">=2.7" 821 | }, 822 | "peerDependenciesMeta": { 823 | "@swc/core": { 824 | "optional": true 825 | }, 826 | "@swc/wasm": { 827 | "optional": true 828 | } 829 | } 830 | }, 831 | "node_modules/tslib": { 832 | "version": "2.6.1", 833 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", 834 | "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==" 835 | }, 836 | "node_modules/typescript": { 837 | "version": "5.1.6", 838 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", 839 | "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", 840 | "dev": true, 841 | "bin": { 842 | "tsc": "bin/tsc", 843 | "tsserver": "bin/tsserver" 844 | }, 845 | "engines": { 846 | "node": ">=14.17" 847 | } 848 | }, 849 | "node_modules/utf-8-validate": { 850 | "version": "5.0.10", 851 | "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", 852 | "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", 853 | "hasInstallScript": true, 854 | "optional": true, 855 | "dependencies": { 856 | "node-gyp-build": "^4.3.0" 857 | }, 858 | "engines": { 859 | "node": ">=6.14.2" 860 | } 861 | }, 862 | "node_modules/uuid": { 863 | "version": "8.3.2", 864 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", 865 | "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", 866 | "bin": { 867 | "uuid": "dist/bin/uuid" 868 | } 869 | }, 870 | "node_modules/v8-compile-cache-lib": { 871 | "version": "3.0.1", 872 | "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", 873 | "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", 874 | "dev": true 875 | }, 876 | "node_modules/webidl-conversions": { 877 | "version": "3.0.1", 878 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 879 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 880 | }, 881 | "node_modules/whatwg-url": { 882 | "version": "5.0.0", 883 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 884 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 885 | "dependencies": { 886 | "tr46": "~0.0.3", 887 | "webidl-conversions": "^3.0.0" 888 | } 889 | }, 890 | "node_modules/ws": { 891 | "version": "7.5.9", 892 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", 893 | "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", 894 | "engines": { 895 | "node": ">=8.3.0" 896 | }, 897 | "peerDependencies": { 898 | "bufferutil": "^4.0.1", 899 | "utf-8-validate": "^5.0.2" 900 | }, 901 | "peerDependenciesMeta": { 902 | "bufferutil": { 903 | "optional": true 904 | }, 905 | "utf-8-validate": { 906 | "optional": true 907 | } 908 | } 909 | }, 910 | "node_modules/yn": { 911 | "version": "3.1.1", 912 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 913 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 914 | "dev": true, 915 | "engines": { 916 | "node": ">=6" 917 | } 918 | } 919 | } 920 | } 921 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yolodolo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "main": "ts-node main.ts", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@coral-xyz/anchor": "^0.28.1-beta.1", 14 | "@openbook-dex/openbook-v2": "^0.1.5", 15 | "@solana/spl-token": "^0.3.8", 16 | "@solana/web3.js": "^1.78.3" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^20.5.0", 20 | "ts-node": "^10.9.1", 21 | "typescript": "^5.1.6" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /parseEvent.ts: -------------------------------------------------------------------------------- 1 | import { PublicKey, Connection } from "@solana/web3.js"; 2 | import { 3 | AnchorProvider, 4 | BN, 5 | Wallet, 6 | BorshCoder, 7 | } from "@coral-xyz/anchor"; 8 | import { RPC, programId } from "./utils"; 9 | 10 | import { authority } from "./utils"; 11 | import { 12 | OpenBookV2Client, 13 | PlaceOrderArgs, 14 | Side, 15 | IDL, 16 | } from "@openbook-dex/openbook-v2"; 17 | 18 | async function main() { 19 | const wallet = new Wallet(authority); 20 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 21 | commitment: "confirmed", 22 | }); 23 | const client = new OpenBookV2Client(provider); 24 | 25 | const txId = 26 | "64uAnfXqUHTrTPYTPzyU11bu38dqDPj1owXvLH3j6WRK35dRBvVwaD5S2KoqSQwNCxpapdvzPNyT9MN79TSP7QLD"; 27 | // Get transaction from its signature 28 | const tx = await client.connection.getTransaction(txId, { 29 | commitment: "confirmed", 30 | }); 31 | let borshCoder = new BorshCoder(IDL); 32 | 33 | if (tx && tx.meta?.logMessages) { 34 | for (const logs of tx.meta?.logMessages) { 35 | const event = extractEventData(logs.toString()); 36 | if (event) { 37 | console.log(borshCoder.events.decode(event)); 38 | } 39 | } 40 | } 41 | } 42 | function extractEventData(input: string): string | null { 43 | const prefix = "Program data: "; 44 | 45 | if (input.startsWith(prefix)) { 46 | return input.substring(prefix.length); 47 | } 48 | 49 | return null; 50 | } 51 | 52 | main(); 53 | -------------------------------------------------------------------------------- /postOrder.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { PublicKey, Connection } from "@solana/web3.js"; 3 | import { authority } from "./utils"; 4 | import { RPC, programId } from "./utils"; 5 | import { 6 | OpenBookV2Client, 7 | PlaceOrderArgs, 8 | Side, 9 | } from "@openbook-dex/openbook-v2"; 10 | import { MintUtils } from "./mint_utils"; 11 | 12 | async function main() { 13 | const wallet = new Wallet(authority); 14 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 15 | commitment: "confirmed", 16 | }); 17 | const client = new OpenBookV2Client(provider); 18 | 19 | const openOrdersPublicKey = new PublicKey( 20 | "EuaUfzypbyh5xtKD2nfHEfpQiTr8QSqu4VeRtLrfTF1c" 21 | ); 22 | const marketPublicKey = new PublicKey( 23 | "CwHc9CZ9UCZFayz4eBekuhhKsHapLDPYfX4tGFJrnTRt" 24 | ); 25 | const market = await client.deserializeMarketAccount(marketPublicKey); 26 | if (!market) { 27 | throw "No market"; 28 | } 29 | 30 | let mintUtils = new MintUtils(provider.connection, authority); 31 | const userQuoteAcc = await mintUtils.getOrCreateTokenAccount( 32 | market?.quoteMint, 33 | authority, 34 | client.walletPk 35 | ); 36 | const userBaseAcc = await mintUtils.getOrCreateTokenAccount( 37 | market?.baseMint, 38 | authority, 39 | client.walletPk 40 | ); 41 | mintUtils.mintTo(market?.quoteMint, userQuoteAcc.address); 42 | mintUtils.mintTo(market?.baseMint, userBaseAcc.address); 43 | 44 | const nbOrders: number = 10; 45 | for (let i = 0; i < nbOrders; ++i) { 46 | let side = Side.Bid; 47 | let placeOrder = { limit: {} }; 48 | let selfTradeBehavior = { decrementTake: {} }; 49 | 50 | let args: PlaceOrderArgs = { 51 | side, 52 | priceLots: new BN(1000 - 1 - i), 53 | maxBaseLots: new BN(10), 54 | maxQuoteLotsIncludingFees: new BN(1000000), 55 | clientOrderId: new BN(i), 56 | orderType: placeOrder, 57 | expiryTimestamp: new BN(0), 58 | selfTradeBehavior: selfTradeBehavior, 59 | limit: 255, 60 | }; 61 | 62 | const [ix, signers] = await client.placeOrderIx( 63 | openOrdersPublicKey, 64 | marketPublicKey, 65 | market, 66 | userQuoteAcc.address, 67 | null, 68 | args, 69 | [] 70 | ); 71 | const tx = await client.sendAndConfirmTransaction([ix], { 72 | additionalSigners: [signers], 73 | }); 74 | console.log("Placed order ", tx); 75 | } 76 | 77 | for (let i = 0; i < nbOrders; ++i) { 78 | let side = Side.Ask; 79 | let placeOrder = { limit: {} }; 80 | let selfTradeBehavior = { decrementTake: {} }; 81 | 82 | let args: PlaceOrderArgs = { 83 | side, 84 | priceLots: new BN(1000 + 1 + i), 85 | maxBaseLots: new BN(10000), 86 | maxQuoteLotsIncludingFees: new BN(1000000), 87 | clientOrderId: new BN(i + nbOrders + 1), 88 | orderType: placeOrder, 89 | expiryTimestamp: new BN(0), 90 | selfTradeBehavior: selfTradeBehavior, 91 | limit: 255, 92 | }; 93 | let remainings = new Array(); 94 | 95 | const [ix, signers] = await client.placeOrderIx( 96 | openOrdersPublicKey, 97 | marketPublicKey, 98 | market, 99 | userBaseAcc.address, 100 | null, 101 | args, 102 | remainings 103 | ); 104 | const tx = await client.sendAndConfirmTransaction([ix], { 105 | additionalSigners: [signers], 106 | }); 107 | console.log("Placed order ", tx); 108 | } 109 | } 110 | 111 | main(); 112 | -------------------------------------------------------------------------------- /postOrderUI.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { PublicKey, Connection } from "@solana/web3.js"; 3 | import { authority } from "./utils"; 4 | import { RPC, programId } from "./utils"; 5 | import { 6 | OpenBookV2Client, 7 | PlaceOrderArgs, 8 | Side, 9 | uiBaseToLots, 10 | uiPriceToLots, 11 | uiQuoteToLots, 12 | } from "@openbook-dex/openbook-v2"; 13 | import { MintUtils } from "./mint_utils"; 14 | 15 | async function main() { 16 | const wallet = new Wallet(authority); 17 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 18 | commitment: "confirmed", 19 | }); 20 | const client = new OpenBookV2Client(provider); 21 | 22 | const openOrdersPublicKey = new PublicKey( 23 | "EuaUfzypbyh5xtKD2nfHEfpQiTr8QSqu4VeRtLrfTF1c" 24 | ); 25 | const marketPublicKey = new PublicKey( 26 | "CwHc9CZ9UCZFayz4eBekuhhKsHapLDPYfX4tGFJrnTRt" 27 | ); 28 | const market = await client.deserializeMarketAccount(marketPublicKey); 29 | if (!market) { 30 | throw "No market"; 31 | } 32 | 33 | let mintUtils = new MintUtils(provider.connection, authority); 34 | const userQuoteAcc = await mintUtils.getOrCreateTokenAccount( 35 | market?.quoteMint, 36 | authority, 37 | client.walletPk 38 | ); 39 | const userBaseAcc = await mintUtils.getOrCreateTokenAccount( 40 | market?.baseMint, 41 | authority, 42 | client.walletPk 43 | ); 44 | mintUtils.mintTo(market?.quoteMint, userQuoteAcc.address); 45 | mintUtils.mintTo(market?.baseMint, userBaseAcc.address); 46 | 47 | let side = Side.Bid; 48 | let placeOrder = { limit: {} }; 49 | let selfTradeBehavior = { decrementTake: {} }; 50 | 51 | // Buy Sol at $20 with $100. Remember SBF was buying all at $3 52 | // We set the maxBaseLots to maximum or big number to not restrict 53 | const priceLots = uiPriceToLots(market, 20); 54 | const maxQuoteLotsIncludingFees = uiQuoteToLots(market, 100); 55 | 56 | const maxBaseLots = uiBaseToLots(market, 1000000); 57 | 58 | let args: PlaceOrderArgs = { 59 | side, 60 | priceLots, 61 | maxBaseLots, 62 | maxQuoteLotsIncludingFees, 63 | clientOrderId: new BN(123), 64 | orderType: placeOrder, 65 | expiryTimestamp: new BN(0), 66 | selfTradeBehavior: selfTradeBehavior, 67 | limit: 255, 68 | }; 69 | 70 | const [ix, signers] = await client.placeOrderIx( 71 | openOrdersPublicKey, 72 | marketPublicKey, 73 | market, 74 | userQuoteAcc.address, 75 | null, 76 | args, 77 | [] 78 | ); 79 | const tx = await client.sendAndConfirmTransaction([ix], signers); 80 | 81 | console.log("Placed order ", tx); 82 | } 83 | 84 | main(); 85 | -------------------------------------------------------------------------------- /solana_utils.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Connection, 3 | Keypair, 4 | PublicKey, 5 | SystemProgram, 6 | Transaction, 7 | sendAndConfirmTransaction, 8 | } from "@solana/web3.js"; 9 | 10 | export async function createAccount( 11 | connection: Connection, 12 | authority: Keypair, 13 | size: number, 14 | owner: PublicKey 15 | ): Promise { 16 | const lamports = await connection.getMinimumBalanceForRentExemption(size); 17 | let address = Keypair.generate(); 18 | 19 | const transaction = new Transaction().add( 20 | SystemProgram.createAccount({ 21 | fromPubkey: authority.publicKey, 22 | newAccountPubkey: address.publicKey, 23 | lamports, 24 | space: size, 25 | programId: owner, 26 | }) 27 | ); 28 | 29 | transaction.feePayer = authority.publicKey; 30 | let hash = await connection.getRecentBlockhash(); 31 | transaction.recentBlockhash = hash.blockhash; 32 | // Sign transaction, broadcast, and confirm 33 | await sendAndConfirmTransaction( 34 | connection, 35 | transaction, 36 | [authority, address], 37 | { commitment: "confirmed" } 38 | ); 39 | return address.publicKey; 40 | } 41 | -------------------------------------------------------------------------------- /takeOrder.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, BN, Wallet } from "@coral-xyz/anchor"; 2 | import { PublicKey, Connection } from "@solana/web3.js"; 3 | import { authority } from "./utils"; 4 | import { RPC, programId } from "./utils"; 5 | import { 6 | OpenBookV2Client, 7 | PlaceOrderArgs, 8 | Side, 9 | OrderType, 10 | SelfTradeBehavior, 11 | } from "@openbook-dex/openbook-v2"; 12 | import { MintUtils } from "./mint_utils"; 13 | 14 | async function main() { 15 | const wallet = new Wallet(authority); 16 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 17 | commitment: "confirmed", 18 | }); 19 | const client = new OpenBookV2Client(provider); 20 | 21 | const marketPublicKey = new PublicKey( 22 | "2Hj72s8LRTs532YBDSU7R95DgHw2bSSN5nmwzeYwgJr3" 23 | ); 24 | 25 | const market = await client.deserializeMarketAccount(marketPublicKey); 26 | if (!market) { 27 | throw "No market"; 28 | } 29 | 30 | let mintUtils = new MintUtils(provider.connection, authority); 31 | 32 | const userQuoteAcc = await mintUtils.getOrCreateTokenAccount( 33 | market?.quoteMint, 34 | authority, 35 | client.walletPk 36 | ); 37 | 38 | const userBaseAcc = await mintUtils.getOrCreateTokenAccount( 39 | market?.baseMint, 40 | authority, 41 | client.walletPk 42 | ); 43 | mintUtils.mintTo(market?.quoteMint, userQuoteAcc.address); 44 | mintUtils.mintTo(market?.baseMint, userBaseAcc.address); 45 | 46 | let args: PlaceOrderArgs = { 47 | side: Side.Bid, 48 | priceLots: new BN(1000 + 1000), 49 | maxBaseLots: new BN(1000), 50 | maxQuoteLotsIncludingFees: new BN(100000000), 51 | clientOrderId: new BN(105), 52 | orderType: OrderType.Market, 53 | expiryTimestamp: new BN(0), 54 | selfTradeBehavior: SelfTradeBehavior.DecrementTake, 55 | limit: 255, 56 | }; 57 | let remainings = new Array(); 58 | const [ix, signers] = await client.placeTakeOrderIx( 59 | marketPublicKey, 60 | market, 61 | userBaseAcc.address, 62 | userQuoteAcc.address, 63 | null, 64 | args, 65 | remainings 66 | ); 67 | const tx = await client.sendAndConfirmTransaction([ix], { 68 | additionalSigners: [signers], 69 | }); 70 | console.log("Take order ", tx); 71 | } 72 | 73 | main(); 74 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "lib": ["es6"], 6 | "allowJs": true, 7 | "outDir": "build", 8 | "rootDir": "./", 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "esModuleInterop": true, 12 | "resolveJsonModule": true 13 | } 14 | } -------------------------------------------------------------------------------- /update_ltu.ts: -------------------------------------------------------------------------------- 1 | import { AnchorProvider, Wallet } from "@coral-xyz/anchor"; 2 | import { 3 | PublicKey, 4 | Connection, 5 | AddressLookupTableProgram, 6 | TransactionMessage, 7 | VersionedTransaction, 8 | } from "@solana/web3.js"; 9 | import { authority } from "./utils"; 10 | import { RPC } from "./utils"; 11 | import { OpenBookV2Client } from "@openbook-dex/openbook-v2"; 12 | 13 | const LOOKUP_TABLE_ADDRESS = new PublicKey("89PiVrPT2LRdQncErZxPSAKfB6WXqZdX9Hx8UBTzbfN8"); 14 | 15 | const addressesToAdd = [new PublicKey("")]; 16 | 17 | async function main() { 18 | const wallet = new Wallet(authority); 19 | const provider = new AnchorProvider(new Connection(RPC), wallet, { 20 | commitment: "confirmed", 21 | }); 22 | const client = new OpenBookV2Client(provider); 23 | 24 | const addAddressesInstruction = AddressLookupTableProgram.extendLookupTable({ 25 | payer: wallet.publicKey, 26 | authority: wallet.publicKey, 27 | lookupTable: LOOKUP_TABLE_ADDRESS, 28 | addresses: addressesToAdd, 29 | }); 30 | 31 | let latestBlockhash = await client.connection.getLatestBlockhash("finalized"); 32 | console.log( 33 | " ✅ - Fetched latest blockhash. Last valid height:", 34 | latestBlockhash.lastValidBlockHeight 35 | ); 36 | const messageV0 = new TransactionMessage({ 37 | payerKey: wallet.publicKey, 38 | recentBlockhash: latestBlockhash.blockhash, 39 | instructions: [addAddressesInstruction], 40 | }).compileToV0Message(); 41 | const transaction = new VersionedTransaction(messageV0); 42 | transaction.sign([wallet.payer]); 43 | const txid = await client.connection.sendTransaction(transaction, { 44 | maxRetries: 5, 45 | }); 46 | const confirmation = await client.connection.confirmTransaction({ 47 | signature: txid, 48 | blockhash: latestBlockhash.blockhash, 49 | lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, 50 | }); 51 | if (confirmation.value.err) { 52 | throw new Error(" ❌ - Transaction not confirmed."); 53 | } 54 | console.log( 55 | "🎉 Transaction succesfully confirmed!", 56 | "\n", 57 | `https://explorer.solana.com/tx/${txid}?cluster=devnet` 58 | ); 59 | console.log( 60 | `Lookup Table Entries: `, 61 | `https://explorer.solana.com/address/${LOOKUP_TABLE_ADDRESS.toString()}/entries?cluster=devnet` 62 | ); 63 | } 64 | 65 | main(); 66 | -------------------------------------------------------------------------------- /utils.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import { 3 | OpenBookV2Client, 4 | IDL, 5 | type OpenbookV2, 6 | } from "@openbook-dex/openbook-v2"; 7 | 8 | import { 9 | Connection, 10 | Keypair, 11 | PublicKey, 12 | ComputeBudgetProgram, 13 | SystemProgram, 14 | Transaction, 15 | } from "@solana/web3.js"; 16 | import { AnchorProvider, BN, Program, getProvider } from "@coral-xyz/anchor"; 17 | import * as os from "os"; 18 | import { createAccount } from "./solana_utils"; 19 | import { MintUtils } from "./mint_utils"; 20 | 21 | // export const RPC = "http://127.0.0.1:8899"; 22 | // export const RPC = "https://api.devnet.solana.com"; 23 | // export const RPC= "https://api.testnet.solana.com"; 24 | export const RPC= "https://api.mainnet-beta.solana.com"; 25 | 26 | export const programId = new PublicKey( 27 | "opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb" 28 | ); 29 | 30 | export const authorityFile = `${os.homedir()}/.config/solana/id.json`; 31 | export const authority = getKeypairFromFile(authorityFile); 32 | export const connection = new Connection(RPC, { 33 | commitment: "finalized", 34 | confirmTransactionInitialTimeout: 30000, 35 | }); 36 | export const program = new Program(IDL, programId, getProvider()); 37 | 38 | export function getKeypairFromFile(filePath: String): Keypair { 39 | return Keypair.fromSecretKey( 40 | Uint8Array.from( 41 | JSON.parse( 42 | process.env.KEYPAIR || fs.readFileSync(filePath.toString(), "utf-8") 43 | ) 44 | ) 45 | ); 46 | } 47 | --------------------------------------------------------------------------------