Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add priority fee ixs to purchase txs #7613

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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