From fa33251d0b93ca2ff6a2ad6d3d1605852857dca4 Mon Sep 17 00:00:00 2001 From: Reed <3893871+dharit-tan@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:27:35 -0500 Subject: [PATCH] Add priority fee ixs to purchase txs (#7613) --- .../src/typed-routes/solana/solanaRelayChecks.ts | 2 ++ .../libs/src/services/solana/SolanaWeb3Manager.ts | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/identity-service/src/typed-routes/solana/solanaRelayChecks.ts b/packages/identity-service/src/typed-routes/solana/solanaRelayChecks.ts index 32a68e4470f..47feba7e982 100644 --- a/packages/identity-service/src/typed-routes/solana/solanaRelayChecks.ts +++ b/packages/identity-service/src/typed-routes/solana/solanaRelayChecks.ts @@ -39,6 +39,7 @@ const PAYMENT_ROUTER_PROGRAM_ID: string = config.get( ) const JUPITER_AGGREGATOR_V6_PROGRAM_ID = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4' +const COMPUTE_BUDGET_PROGRAM_ID = 'ComputeBudget111111111111111111111111111111' const audioMintAddress: string = config.get('solanaMintAddress') const usdcMintAddress: string = config.get('solanaUSDCMintAddress') @@ -440,6 +441,7 @@ export const assertRelayAllowedInstructions = async ( case PAYMENT_ROUTER_PROGRAM_ID: case MEMO_PROGRAM_ID: case MEMO_V2_PROGRAM_ID: + case COMPUTE_BUDGET_PROGRAM_ID: // All instructions of these programs are allowed break default: diff --git a/packages/libs/src/services/solana/SolanaWeb3Manager.ts b/packages/libs/src/services/solana/SolanaWeb3Manager.ts index 85916214927..e85cea9b245 100644 --- a/packages/libs/src/services/solana/SolanaWeb3Manager.ts +++ b/packages/libs/src/services/solana/SolanaWeb3Manager.ts @@ -10,7 +10,8 @@ import { PublicKey, LAMPORTS_PER_SOL, TransactionInstruction, - Transaction + Transaction, + ComputeBudgetProgram } from '@solana/web3.js' import * as solanaWeb3 from '@solana/web3.js' import BN from 'bn.js' @@ -84,6 +85,10 @@ const SOL_PER_LAMPORT = 0.000000001 // Generous default connection confirmation timeout to better cope with RPC congestion const DEFAULT_CONNECTION_CONFIRMATION_TIMEOUT_MS = 180 * 1000 +const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: 100000 // micro lamports +}) + export type SolanaWeb3Config = { // the RPC endpoint to make requests against solanaClusterEndpoint: string @@ -584,8 +589,9 @@ export class SolanaWeb3Manager { programId: MEMO_PROGRAM_ID, data: Buffer.from(data) }) + return await this.transactionHandler.handleTransaction({ - instructions: [...instructions, memoInstruction], + instructions: [...instructions, memoInstruction, priorityFeeInstruction], skipPreflight: true, feePayerOverride: this.feePayerKey }) @@ -710,7 +716,8 @@ export class SolanaWeb3Manager { const instructions = [ transferInstruction, paymentRouterInstruction, - memoInstruction + memoInstruction, + priorityFeeInstruction ] return instructions }