Skip to content

Commit

Permalink
Merge pull request #112 from drift-labs/master
Browse files Browse the repository at this point in the history
configurable tx sender
  • Loading branch information
NourAlharithi authored Dec 27, 2023
2 parents fca9c86 + eaf6ddd commit 79b5fca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "lib/index.js",
"license": "Apache-2.0",
"dependencies": {
"@drift-labs/jit-proxy": "0.10.154",
"@drift-labs/sdk": "2.53.0-beta.1",
"@drift-labs/jit-proxy": "0.10.155",
"@drift-labs/sdk": "2.53.0-beta.2",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
"@opentelemetry/exporter-prometheus": "^0.31.0",
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface GlobalConfig {
jitoBlockEngineUrl?: string;
jitoAuthPrivateKey?: string;
txRetryTimeoutMs?: number;
txSenderType?: 'fast' | 'retry';
}

export interface Config {
Expand Down
34 changes: 22 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ program
'--event-susbcriber',
'Explicitly intialize an eventSubscriber (RPC heavy'
)
.option(
'--tx-sender-type <string>',
'Choose tx sender type, options are: fast, retry'
)
.parse();

const opts = program.opts();
Expand Down Expand Up @@ -263,18 +267,24 @@ const runBot = async () => {
commitment: stateCommitment,
disableRetryOnRateLimit: true,
});
// const txSender = new FastSingleTxSender({
// connection: sendTxConnection,
// blockhashRefreshInterval: 10_000,
// wallet,
// opts,
// });
const txSender = new RetryTxSender({
connection: sendTxConnection,
wallet,
opts,
timeout: 3000,
});

const txSenderType = config.global.txSenderType || 'retry';
let txSender;
if (txSenderType === 'retry') {
txSender = new RetryTxSender({
connection: sendTxConnection,
wallet,
opts,
timeout: 3000,
});
} else {
txSender = new FastSingleTxSender({
connection: sendTxConnection,
blockhashRefreshInterval: 1000,
wallet,
opts,
});
}

/**
* Creating and subscribing to the drift client
Expand Down

0 comments on commit 79b5fca

Please sign in to comment.