From 17594a069c1afe9bddcb42186632dc5df3bbc72a Mon Sep 17 00:00:00 2001 From: wphan Date: Thu, 21 Nov 2024 12:47:19 -0500 Subject: [PATCH] switchboard cranker hard code cu limit for --- src/bots/switchboardCranker.ts | 34 ++++++++++++---------------------- src/utils.ts | 2 +- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/bots/switchboardCranker.ts b/src/bots/switchboardCranker.ts index f81fefd5..b4c3b03e 100644 --- a/src/bots/switchboardCranker.ts +++ b/src/bots/switchboardCranker.ts @@ -14,7 +14,7 @@ import { ComputeBudgetProgram, PublicKey, } from '@solana/web3.js'; -import { simulateAndGetTxWithCUs, sleepMs } from '../utils'; +import { getVersionedTransaction, sleepMs } from '../utils'; import { Agent, setGlobalDispatcher } from 'undici'; setGlobalDispatcher( @@ -23,7 +23,8 @@ setGlobalDispatcher( }) ); -const SIM_CU_ESTIMATE_MULTIPLIER = 1.5; +// ref: https://solscan.io/tx/Z5X334CFBmzbzxXHgfa49UVbMdLZf7nJdDCekjaZYinpykVqgTm47VZphazocMjYe1XJtEyeiL6QgrmvLeMesMA +const MIN_CU_LIMIT = 350_000; export class SwitchboardCrankerBot implements Bot { public name: string; @@ -112,7 +113,7 @@ export class SwitchboardCrankerBot implements Bot { ); const ixs = [ ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, + units: MIN_CU_LIMIT, }), ]; @@ -139,38 +140,27 @@ export class SwitchboardCrankerBot implements Bot { } ixs.push(pullIx); - const simResult = await simulateAndGetTxWithCUs({ + const tx = getVersionedTransaction( + this.driftClient.wallet.publicKey, ixs, - connection: this.driftClient.connection, - payerPublicKey: this.driftClient.wallet.publicKey, - lookupTableAccounts: this.lookupTableAccounts, - cuLimitMultiplier: SIM_CU_ESTIMATE_MULTIPLIER, - doSimulation: true, - recentBlockhash: await this.getBlockhashForTx(), - }); - - if (simResult.cuEstimate < 100000) { - logger.info( - `cuEst: ${simResult.cuEstimate}, logs: ${JSON.stringify( - simResult.simTxLogs - )}` - ); - } + this.lookupTableAccounts, + await this.getBlockhashForTx() + ); if (this.globalConfig.useJito) { - simResult.tx.sign([ + tx.sign([ // @ts-ignore; this.driftClient.wallet.payer, ]); this.bundleSender?.sendTransactions( - [simResult.tx], + [tx], undefined, undefined, false ); } else { this.driftClient - .sendTransaction(simResult.tx) + .sendTransaction(tx) .then((txSigAndSlot: TxSigAndSlot) => { logger.info( `Posted update sb atomic tx for ${alias}: ${txSigAndSlot.txSig}` diff --git a/src/utils.ts b/src/utils.ts index ff2ef031..0541ee24 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -447,7 +447,7 @@ export function isSetComputeUnitsIx(ix: TransactionInstruction): boolean { } const PLACEHOLDER_BLOCKHASH = 'Fdum64WVeej6DeL85REV9NvfSxEJNPZ74DBk7A8kTrKP'; -function getVersionedTransaction( +export function getVersionedTransaction( payerKey: PublicKey, ixs: Array, lookupTableAccounts: AddressLookupTableAccount[],