Skip to content

Commit

Permalink
Merge pull request #420 from elsoul/usePriorityFeeAndLimit
Browse files Browse the repository at this point in the history
use Priority Fee and ComputeUnitLimit
  • Loading branch information
KishiTheMechanic committed Apr 24, 2024
2 parents 540840f + 85b26ec commit f5ee6b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/solana-utils/src/lib/confirmTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const confirmTransaction = async (
)
const versionedTx = new VersionedTransaction(
new TransactionMessage({
instructions,
instructions: testVersionedTx.instructionsForFinalTx,
payerKey: fromWallet.publicKey,
recentBlockhash:
testVersionedTx.latestBlockhashAndContext.value.blockhash,
Expand Down
13 changes: 13 additions & 0 deletions packages/solana-utils/src/lib/getTestVersionedTxResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,21 @@ export const getTestVersionedTxResult = async (
priorityFee,
)
console.log('estimatedFee:', estimatedFee)

const instructionsForFinalTx: TransactionInstruction[] = [
...instructions,
ComputeBudgetProgram.setComputeUnitLimit({
units: simulationResult.value.unitsConsumed
? Math.trunc(simulationResult.value.unitsConsumed * 1.2)
: 200_000,
}),
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: Math.ceil(estimatedFee.priorityFeeEstimate),
}),
]
const result = {
testVersionedTx,
instructionsForFinalTx,
estimatedFee: estimatedFee.priorityFeeEstimate,
simulationResult,
latestBlockhashAndContext,
Expand Down

0 comments on commit f5ee6b5

Please sign in to comment.