From 9fdd5b98138e412cb5f1c3dc9d60edba4bc43245 Mon Sep 17 00:00:00 2001 From: Dharit Tantiviramanond Date: Thu, 15 Feb 2024 17:51:33 -0500 Subject: [PATCH 1/2] Add priority fee ixs to purchase txs --- .../src/typed-routes/solana/solanaRelayChecks.ts | 2 ++ .../libs/src/services/solana/SolanaWeb3Manager.ts | 14 +++++++++++--- 2 files changed, 13 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..8c694f6f700 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,11 @@ 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 PRIORITY_RATE = 100000 // MICRO_LAMPORTS +const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: PRIORITY_RATE +}) + export type SolanaWeb3Config = { // the RPC endpoint to make requests against solanaClusterEndpoint: string @@ -584,8 +590,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 +717,8 @@ export class SolanaWeb3Manager { const instructions = [ transferInstruction, paymentRouterInstruction, - memoInstruction + memoInstruction, + priorityFeeInstruction ] return instructions } From e3498a24ec0282006dfc369f591439f10bb9eb2b Mon Sep 17 00:00:00 2001 From: Dharit Tantiviramanond Date: Thu, 15 Feb 2024 17:55:29 -0500 Subject: [PATCH 2/2] no constant --- packages/libs/src/services/solana/SolanaWeb3Manager.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/libs/src/services/solana/SolanaWeb3Manager.ts b/packages/libs/src/services/solana/SolanaWeb3Manager.ts index 8c694f6f700..e85cea9b245 100644 --- a/packages/libs/src/services/solana/SolanaWeb3Manager.ts +++ b/packages/libs/src/services/solana/SolanaWeb3Manager.ts @@ -85,9 +85,8 @@ 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 PRIORITY_RATE = 100000 // MICRO_LAMPORTS const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: PRIORITY_RATE + microLamports: 100000 // micro lamports }) export type SolanaWeb3Config = {