| 54 | |
| 55 | |
| 56 | async function build_bundle( |
| 57 | search: SearcherClient, |
| 58 | bundleTransactionLimit: number, |
| 59 | txs: VersionedTransaction[], |
| 60 | keypair: Keypair |
| 61 | ) { |
| 62 | |
| 63 | const accounts = await search.getTipAccounts() |
| 64 | const _tipAccount = accounts[Math.min(Math.floor(Math.random() * accounts.length), 3)] |
| 65 | const tipAccount = new PublicKey(_tipAccount) |
| 66 | |
| 67 | const bund = new Bundle([], bundleTransactionLimit) |
| 68 | const resp = await solanaConnection.getLatestBlockhash("processed") |
| 69 | bund.addTransactions(...txs) |
| 70 | |
| 71 | let maybeBundle = bund.addTipTx( |
| 72 | keypair, |
| 73 | JITO_FEE, |
| 74 | tipAccount, |
| 75 | resp.blockhash |
| 76 | ) |
| 77 | |
| 78 | if (isError(maybeBundle)) { |
| 79 | throw maybeBundle |
| 80 | } |
| 81 | try { |
| 82 | await search.sendBundle(maybeBundle) |
| 83 | } catch (e) { } |
| 84 | return maybeBundle |
| 85 | } |
| 86 | |
| 87 | export const onBundleResult = (c: SearcherClient): Promise<number> => { |
| 88 | let first = 0 |