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

configurable tx sender #112

Merged
merged 6 commits into from
Dec 27, 2023
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
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
Loading