Skip to content

Commit

Permalink
Add priority fee ixs to purchase txs (#7613)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Feb 16, 2024
1 parent b6a58ab commit fa33251
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions packages/libs/src/services/solana/SolanaWeb3Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -710,7 +716,8 @@ export class SolanaWeb3Manager {
const instructions = [
transferInstruction,
paymentRouterInstruction,
memoInstruction
memoInstruction,
priorityFeeInstruction
]
return instructions
}
Expand Down

0 comments on commit fa33251

Please sign in to comment.