diff --git a/example.config.yaml b/example.config.yaml index 85750c26..3e2c557a 100644 --- a/example.config.yaml +++ b/example.config.yaml @@ -4,9 +4,23 @@ global: # RPC endpoint to use endpoint: https://api.mainnet-beta.solana.com - # custom websocket endpoint to use (if null will be determined from rpc endpoint) + + # Custom websocket endpoint to use (if null will be determined from `endpoint``) + # Note: the default wsEndpoint value simply replaces http(s) with ws(s), so if + # your RPC provider requires a special path (i.e. /ws) for websocket connections + # you must set this. wsEndpoint: + # optional if you want to use helius' global priority fee method AND `endpoint` is not + # already a helius url. + heliusEndpoint: + + # `solana` or `helius`. If `helius` `endpoint` must be a helius RPC, or `heliusEndpoint` + # must be set + # solana: uses https://solana.com/docs/rpc/http/getrecentprioritizationfees + # helius: uses https://docs.helius.dev/solana-rpc-nodes/alpha-priority-fee-api + priorityFeeMethod: solana + # Private key to use to sign transactions. # will load from KEEPER_PRIVATE_KEY env var if null keeperPrivateKey: diff --git a/src/bots/filler.ts b/src/bots/filler.ts index f73dda0b..0b8610c3 100644 --- a/src/bots/filler.ts +++ b/src/bots/filler.ts @@ -267,6 +267,7 @@ export class FillerBot implements Bot { eventSubscriber: EventSubscriber | undefined, runtimeSpec: RuntimeSpec, config: FillerConfig, + priorityFeeSubscriber: PriorityFeeSubscriber, jitoSearcherClient?: SearcherClient, jitoAuthKeypair?: Keypair, tipPayerKeypair?: Keypair @@ -350,13 +351,11 @@ export class FillerBot implements Bot { }` ); - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: 5000, - addresses: [ - new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC is good indicator of fees - ], - }); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC + new PublicKey('8UJgxaiQx5nTrdDgph5FiahMmzduuLTLf5WmsPegYA6W'), // sol-perp + ]); } protected initializeMetrics() { @@ -575,8 +574,6 @@ export class FillerBot implements Bot { this.lookupTableAccount = await this.driftClient.fetchMarketLookupTableAccount(); - await this.priorityFeeSubscriber.subscribe(); - await webhookMessage(`[${this.name}]: started`); } diff --git a/src/bots/fillerLite.ts b/src/bots/fillerLite.ts index 3b330c95..eab5beb4 100644 --- a/src/bots/fillerLite.ts +++ b/src/bots/fillerLite.ts @@ -6,6 +6,7 @@ import { OrderSubscriber, UserAccount, User, + PriorityFeeSubscriber, } from '@drift-labs/sdk'; import { Keypair, PublicKey } from '@solana/web3.js'; @@ -28,6 +29,7 @@ export class FillerLiteBot extends FillerBot { driftClient: DriftClient, runtimeSpec: RuntimeSpec, config: FillerConfig, + priorityFeeSubscriber: PriorityFeeSubscriber, jitoSearcherClient?: SearcherClient, jitoAuthKeypair?: Keypair, tipPayerKeypair?: Keypair @@ -40,6 +42,7 @@ export class FillerLiteBot extends FillerBot { undefined, runtimeSpec, config, + priorityFeeSubscriber, jitoSearcherClient, jitoAuthKeypair, tipPayerKeypair diff --git a/src/bots/jitMaker.ts b/src/bots/jitMaker.ts index 829e3cd7..8d2260c3 100644 --- a/src/bots/jitMaker.ts +++ b/src/bots/jitMaker.ts @@ -68,7 +68,8 @@ export class JitMaker implements Bot { driftClient: DriftClient, // driftClient needs to have correct number of subaccounts listed jitter: JitterSniper | JitterShotgun, config: JitMakerConfig, - driftEnv: DriftEnv + driftEnv: DriftEnv, + priorityFeeSubscriber: PriorityFeeSubscriber ) { this.subAccountIds = config.subaccounts ?? [0]; this.marketIndexes = config.perpMarketIndicies ?? [0]; @@ -107,13 +108,10 @@ export class JitMaker implements Bot { driftClient: this.driftClient, }); - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: 5000, - addresses: [ - new PublicKey('8UJgxaiQx5nTrdDgph5FiahMmzduuLTLf5WmsPegYA6W'), // sol-perp - ], - }); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + new PublicKey('8UJgxaiQx5nTrdDgph5FiahMmzduuLTLf5WmsPegYA6W'), // sol-perp + ]); } /** @@ -125,7 +123,6 @@ export class JitMaker implements Bot { // do stuff that takes some time await this.slotSubscriber.subscribe(); await this.dlobSubscriber.subscribe(); - await this.priorityFeeSubscriber.subscribe(); logger.info(`${this.name} init done`); } diff --git a/src/bots/liquidator.ts b/src/bots/liquidator.ts index 88870a7f..f39e707d 100644 --- a/src/bots/liquidator.ts +++ b/src/bots/liquidator.ts @@ -330,6 +330,7 @@ export class LiquidatorBot implements Bot { runtimeSpec: RuntimeSpec, config: LiquidatorConfig, defaultSubaccountId: number, + priorityFeeSubscriber: PriorityFeeSubscriber, SERUM_LOOKUP_TABLE?: PublicKey ) { this.liquidatorConfig = config; @@ -521,14 +522,10 @@ export class LiquidatorBot implements Bot { connection: this.driftClient.connection, }); } - - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: 5000, - addresses: [ - new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC is good indicator of fees - ], - }); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC + ]); if (!config.maxPositionTakeoverPctOfCollateral) { // spend 50% of collateral by default @@ -640,8 +637,6 @@ export class LiquidatorBot implements Bot { } } - await this.priorityFeeSubscriber.subscribe(); - await webhookMessage(`[${this.name}]: started`); } diff --git a/src/bots/spotFiller.ts b/src/bots/spotFiller.ts index 0055db31..791ec6c4 100644 --- a/src/bots/spotFiller.ts +++ b/src/bots/spotFiller.ts @@ -252,6 +252,7 @@ export class SpotFillerBot implements Bot { userMap: UserMap, runtimeSpec: RuntimeSpec, config: FillerConfig, + priorityFeeSubscriber: PriorityFeeSubscriber, eventSubscriber?: EventSubscriber ) { this.name = config.botId; @@ -275,13 +276,11 @@ export class SpotFillerBot implements Bot { this.initializeMetrics(); } - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: 5000, - addresses: [ - new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC is good indicator of fees - ], - }); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + new PublicKey('8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'), // Openbook SOL/USDC + ]); + this.revertOnFailure = config.revertOnFailure ?? true; this.simulateTxForCUEstimate = config.simulateTxForCUEstimate ?? true; logger.info( @@ -613,8 +612,6 @@ export class SpotFillerBot implements Bot { } } - await this.priorityFeeSubscriber.subscribe(); - await webhookMessage(`[${this.name}]: started`); } diff --git a/src/bots/uncrossArbBot.ts b/src/bots/uncrossArbBot.ts index 47ac6a22..1a44bef3 100644 --- a/src/bots/uncrossArbBot.ts +++ b/src/bots/uncrossArbBot.ts @@ -91,7 +91,8 @@ export class UncrossArbBot implements Bot { jitProxyClient: JitProxyClient, slotSubscriber: SlotSubscriber, config: BaseBotConfig, - driftEnv: DriftEnv + driftEnv: DriftEnv, + priorityFeeSubscriber: PriorityFeeSubscriber ) { this.jitProxyClient = jitProxyClient; this.driftClient = driftClient; @@ -144,13 +145,10 @@ export class UncrossArbBot implements Bot { driftClient: this.driftClient, }); - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: 5000, - addresses: [ - new PublicKey('8UJgxaiQx5nTrdDgph5FiahMmzduuLTLf5WmsPegYA6W'), // sol-perp - ], - }); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + new PublicKey('8UJgxaiQx5nTrdDgph5FiahMmzduuLTLf5WmsPegYA6W'), // sol-perp + ]); } /** @@ -161,7 +159,6 @@ export class UncrossArbBot implements Bot { await this.orderSubscriber.subscribe(); await this.dlobSubscriber.subscribe(); - await this.priorityFeeSubscriber.subscribe(); this.lookupTableAccount = await this.driftClient.fetchMarketLookupTableAccount(); diff --git a/src/bots/userLpSettler.ts b/src/bots/userLpSettler.ts index 4d8d0dfb..58af74e9 100644 --- a/src/bots/userLpSettler.ts +++ b/src/bots/userLpSettler.ts @@ -25,7 +25,6 @@ import { const SETTLE_LP_CHUNKS = 4; const SLEEP_MS = 500; -const PRIORITY_FEE_SUBSCRIBER_FREQ_MS = 1000; const MAX_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = 10000; // cap the computeUnitPrice to pay for settlePnl txs const errorCodesToSuppress = [ @@ -50,7 +49,11 @@ export class UserLpSettlerBot implements Bot { private watchdogTimerMutex = new Mutex(); private watchdogTimerLastPatTime = Date.now(); - constructor(driftClientConfigs: DriftClientConfig, config: BaseBotConfig) { + constructor( + driftClientConfigs: DriftClientConfig, + config: BaseBotConfig, + priorityFeeSubscriber: PriorityFeeSubscriber + ) { this.name = config.botId; this.dryRun = config.dryRun; this.runOnce = config.runOnce || false; @@ -85,6 +88,17 @@ export class UserLpSettlerBot implements Bot { includeIdle: false, disableSyncOnTotalAccountsChange: true, }); + + const perpMarkets = this.driftClient + .getPerpMarketAccounts() + .map((m) => m.pubkey); + + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([...perpMarkets]); + + logger.info( + `Lp settler looking at ${perpMarkets.length} perp markets to determine priority fee` + ); } public async init() { @@ -99,22 +113,6 @@ export class UserLpSettlerBot implements Bot { this.lookupTableAccount = await this.driftClient.fetchMarketLookupTableAccount(); - const perpMarkets = this.driftClient - .getPerpMarketAccounts() - .map((m) => m.pubkey); - - logger.info( - `Lp settler looking at ${perpMarkets.length} perp markets to determine priority fee` - ); - - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: PRIORITY_FEE_SUBSCRIBER_FREQ_MS, - addresses: [...perpMarkets], - }); - await this.priorityFeeSubscriber.subscribe(); - await sleepMs(PRIORITY_FEE_SUBSCRIBER_FREQ_MS); - // logger.info(`Initializing UserMap`); // const startUserMapSub = Date.now(); // await this.userMap.subscribe(); diff --git a/src/bots/userPnlSettler.ts b/src/bots/userPnlSettler.ts index 2a48589a..f545bf16 100644 --- a/src/bots/userPnlSettler.ts +++ b/src/bots/userPnlSettler.ts @@ -52,7 +52,6 @@ const MIN_PNL_TO_SETTLE = new BN(-10).mul(QUOTE_PRECISION); const SETTLE_USER_CHUNKS = 4; const CU_PER_SETTLE_PNL = 500_000; // annecdotal: https://explorer.solana.com/tx/fLoSxBpBkowozkPMem9s3KLGQYt3KDHemTRzZPWFe48sZc1VJsgRTiYJUGXZGYRWQTwF42PjpgFLe6fpH9aCLh1#ix-1 const SLEEP_MS = 500; -const PRIORITY_FEE_SUBSCRIBER_FREQ_MS = 1000; const MAX_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = 50000; // cap the computeUnitPrice to pay for settlePnl txs const errorCodesToSuppress = [ @@ -78,7 +77,11 @@ export class UserPnlSettlerBot implements Bot { private watchdogTimerMutex = new Mutex(); private watchdogTimerLastPatTime = Date.now(); - constructor(driftClientConfigs: DriftClientConfig, config: BaseBotConfig) { + constructor( + driftClientConfigs: DriftClientConfig, + config: BaseBotConfig, + priorityFeeSubscriber: PriorityFeeSubscriber + ) { this.name = config.botId; this.dryRun = config.dryRun; this.runOnce = config.runOnce || false; @@ -113,6 +116,22 @@ export class UserPnlSettlerBot implements Bot { skipInitialLoad: false, includeIdle: false, }); + + const spotMarkets = this.driftClient + .getSpotMarketAccounts() + .map((m) => m.pubkey); + const perpMarkets = this.driftClient + .getPerpMarketAccounts() + .map((m) => m.pubkey); + this.priorityFeeSubscriber = priorityFeeSubscriber; + this.priorityFeeSubscriber.updateAddresses([ + ...spotMarkets, + ...perpMarkets, + ]); + + logger.info( + `Pnl settler looking at ${spotMarkets.length} spot markets and ${perpMarkets.length} perp markets to determine priority fee` + ); } public async init() { @@ -127,25 +146,6 @@ export class UserPnlSettlerBot implements Bot { this.lookupTableAccount = await this.driftClient.fetchMarketLookupTableAccount(); - const spotMarkets = this.driftClient - .getSpotMarketAccounts() - .map((m) => m.pubkey); - const perpMarkets = this.driftClient - .getPerpMarketAccounts() - .map((m) => m.pubkey); - - logger.info( - `Pnl settler looking at ${spotMarkets.length} spot markets and ${perpMarkets.length} perp markets to determine priority fee` - ); - - this.priorityFeeSubscriber = new PriorityFeeSubscriber({ - connection: this.driftClient.connection, - frequencyMs: PRIORITY_FEE_SUBSCRIBER_FREQ_MS, - addresses: [...spotMarkets, ...perpMarkets], - }); - await this.priorityFeeSubscriber.subscribe(); - await sleepMs(PRIORITY_FEE_SUBSCRIBER_FREQ_MS); - logger.info(`${this.name} init'd!`); } diff --git a/src/config.ts b/src/config.ts index 4cad33c3..45ddb182 100644 --- a/src/config.ts +++ b/src/config.ts @@ -76,6 +76,8 @@ export interface GlobalConfig { driftEnv?: DriftEnv; endpoint?: string; wsEndpoint?: string; + heliusEndpoint?: string; + priorityFeeMethod?: string; resubTimeoutMs?: number; keeperPrivateKey?: string; initUser?: boolean; @@ -124,6 +126,8 @@ const defaultConfig: Partial = { endpoint: process.env.ENDPOINT, wsEndpoint: process.env.WS_ENDPOINT, + heliusEndpoint: process.env.HELIUS_ENDPOINT, + priorityFeeMethod: process.env.PRIORITY_FEE_METHOD ?? 'solana', keeperPrivateKey: process.env.KEEPER_PRIVATE_KEY, useJito: false, @@ -195,6 +199,9 @@ export function loadConfigFromOpts(opts: any): Config { driftEnv: (process.env.ENV ?? 'devnet') as DriftEnv, endpoint: opts.endpoint ?? process.env.ENDPOINT, wsEndpoint: opts.wsEndpoint ?? process.env.WS_ENDPOINT, + heliusEndpoint: opts.heliusEndpoint ?? process.env.HELIUS_ENDPOINT, + priorityFeeMethod: + opts.priorityFeeMethod ?? process.env.PRIORITY_FEE_METHOD, keeperPrivateKey: opts.privateKey ?? process.env.KEEPER_PRIVATE_KEY, eventSubscriberPollingInterval: parseInt( process.env.BULK_ACCOUNT_LOADER_POLLING_INTERVAL ?? '5000' diff --git a/src/index.ts b/src/index.ts index 54871f13..8e930ea5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,8 @@ import { Wallet, RetryTxSender, ConfirmationStrategy, + PriorityFeeSubscriber, + PriorityFeeMethod, } from '@drift-labs/sdk'; import { promiseTimeout } from '@drift-labs/sdk/lib/util/promiseTimeout'; @@ -193,8 +195,10 @@ setLogLevel(config.global.debug ? 'debug' : 'info'); const endpoint = config.global.endpoint!; const wsEndpoint = config.global.wsEndpoint; +const heliusEndpoint = config.global.heliusEndpoint; logger.info(`RPC endpoint: ${endpoint}`); logger.info(`WS endpoint: ${wsEndpoint}`); +logger.info(`Helius endpoint: ${heliusEndpoint}`); logger.info(`DriftEnv: ${config.global.driftEnv}`); logger.info(`Commit: ${commitHash}`); @@ -415,9 +419,27 @@ const runBot = async () => { skipInitialLoad: false, includeIdle: false, }); + let needPriorityFeeSubscriber = false; + + const priorityFeeMethod = + (config.global.priorityFeeMethod as PriorityFeeMethod) ?? + PriorityFeeMethod.SOLANA; + logger.info(`priorityFeeMethod: ${priorityFeeMethod}`); + const priorityFeeSubscriber = new PriorityFeeSubscriber({ + connection: driftClient.connection, + frequencyMs: 5000, + + // the specific bot will update this, if multiple bots are using this, + // the last one to update it will determine the addresses to use... + addresses: [], + heliusRpcUrl: heliusEndpoint, + priorityFeeMethod, + }); + if (configHasBot(config, 'filler')) { needCheckDriftUser = true; needUserMapSubscribe = true; + needPriorityFeeSubscriber = true; bots.push( new FillerBot( slotSubscriber, @@ -433,6 +455,7 @@ const runBot = async () => { walletAuthority: wallet.publicKey.toBase58(), }, config.botConfigs!.filler!, + priorityFeeSubscriber, jitoSearcherClient, jitoAuthKeypair, keypair @@ -442,6 +465,8 @@ const runBot = async () => { if (configHasBot(config, 'fillerLite')) { needCheckDriftUser = true; + needPriorityFeeSubscriber = true; + logger.info(`Starting filler lite bot`); bots.push( new FillerLiteBot( @@ -455,6 +480,7 @@ const runBot = async () => { walletAuthority: wallet.publicKey.toBase58(), }, config.botConfigs!.fillerLite!, + priorityFeeSubscriber, jitoSearcherClient, jitoAuthKeypair, keypair @@ -464,7 +490,10 @@ const runBot = async () => { if (configHasBot(config, 'fillerBulk')) { needCheckDriftUser = true; + needPriorityFeeSubscriber = true; + logger.info(`Starting filler bulk bot`); + bots.push( new FillerBulkBot( slotSubscriber, @@ -477,6 +506,7 @@ const runBot = async () => { walletAuthority: wallet.publicKey.toBase58(), }, config.botConfigs!.fillerBulk!, + priorityFeeSubscriber, jitoSearcherClient, jitoAuthKeypair, keypair @@ -488,6 +518,8 @@ const runBot = async () => { needCheckDriftUser = true; // to avoid long startup, spotFiller will fetch userAccounts as needed and build the map over time needUserMapSubscribe = false; + needPriorityFeeSubscriber = true; + bots.push( new SpotFillerBot( driftClient, @@ -500,6 +532,7 @@ const runBot = async () => { walletAuthority: wallet.publicKey.toBase58(), }, config.botConfigs!.spotFiller!, + priorityFeeSubscriber, eventSubscriber ) ); @@ -529,7 +562,10 @@ const runBot = async () => { if (configHasBot(config, 'jitMaker')) { // Subscribe to drift client - needForceCollateral; + needCheckDriftUser = true; + needForceCollateral = true; + needPriorityFeeSubscriber = true; + const jitProxyClient = new JitProxyClient({ driftClient, programId: new PublicKey(sdkConfig.JIT_PROXY_PROGRAM_ID!), @@ -569,7 +605,8 @@ const runBot = async () => { driftClient, jitter, config.botConfigs!.jitMaker!, - config.global.driftEnv! + config.global.driftEnv!, + priorityFeeSubscriber ) ); } @@ -593,6 +630,7 @@ const runBot = async () => { needCheckDriftUser = true; needUserMapSubscribe = true; needForceCollateral = true; + needPriorityFeeSubscriber = true; bots.push( new LiquidatorBot( driftClient, @@ -606,6 +644,7 @@ const runBot = async () => { }, config.botConfigs!.liquidator!, config.global.subaccounts![0], + priorityFeeSubscriber, sdkConfig.SERUM_LOOKUP_TABLE ? new PublicKey(sdkConfig.SERUM_LOOKUP_TABLE as string) : undefined @@ -632,17 +671,24 @@ const runBot = async () => { } if (configHasBot(config, 'userPnlSettler')) { + needPriorityFeeSubscriber = true; bots.push( new UserPnlSettlerBot( driftClientConfig, - config.botConfigs!.userPnlSettler! + config.botConfigs!.userPnlSettler!, + priorityFeeSubscriber ) ); } if (configHasBot(config, 'userLpSettler')) { + needPriorityFeeSubscriber = true; bots.push( - new UserLpSettlerBot(driftClientConfig, config.botConfigs!.userLpSettler!) + new UserLpSettlerBot( + driftClientConfig, + config.botConfigs!.userLpSettler!, + priorityFeeSubscriber + ) ); } @@ -677,17 +723,20 @@ const runBot = async () => { if (configHasBot(config, 'uncrossArb')) { needCheckDriftUser = true; + needPriorityFeeSubscriber = true; const jitProxyClient = new JitProxyClient({ driftClient, programId: new PublicKey(sdkConfig.JIT_PROXY_PROGRAM_ID!), }); + bots.push( new UncrossArbBot( driftClient, jitProxyClient, slotSubscriber, config.botConfigs!.uncrossArb!, - config.global.driftEnv! + config.global.driftEnv!, + priorityFeeSubscriber ) ); } @@ -701,22 +750,43 @@ const runBot = async () => { jitter || needUserMapSubscribe ) { + const hrStart = process.hrtime(); while (!(await driftClient.subscribe())) { - logger.info('waiting to subscribe to DriftClient'); + logger.info('retrying driftClient.subscribe in 1s...'); await sleepMs(1000); } + const hrEnd = process.hrtime(hrStart); + logger.info(`driftClient.subscribe took: ${hrEnd[0]}s ${hrEnd[1] / 1e6}ms`); } + logger.info(`Checking user exists: ${needCheckDriftUser}`); if (needCheckDriftUser) await checkUserExists(config, driftClient, wallet); + logger.info(`Checking if bot needs collateral: ${needForceCollateral}`); if (needForceCollateral) await checkAndForceCollateral(config, driftClient, wallet); + logger.info(`Checking if need eventSubscriber: ${eventSubscriber}`); if (eventSubscriber) await eventSubscriber.subscribe(); + logger.info(`Checking if need usermap: ${needUserMapSubscribe}`); - if (needUserMapSubscribe) await userMap.subscribe(); + if (needUserMapSubscribe) { + const hrStart = process.hrtime(); + await userMap.subscribe(); + const hrEnd = process.hrtime(hrStart); + logger.info(`userMap.subscribe took: ${hrEnd[0]}s ${hrEnd[1] / 1e6}ms`); + } + logger.info(`Checking if need auctionSubscriber: ${auctionSubscriber}`); - if (auctionSubscriber) await auctionSubscriber.subscribe(); + if (auctionSubscriber) { + const hrStart = process.hrtime(); + await auctionSubscriber.subscribe(); + const hrEnd = process.hrtime(hrStart); + logger.info( + `auctionSubscriber.subscribe took: ${hrEnd[0]}s ${hrEnd[1] / 1e6}ms` + ); + } + logger.info(`Checking if need jitter: ${jitter}`); if (jitter) { const freeCollateral = driftClient @@ -727,7 +797,23 @@ const runBot = async () => { `No collateral in account, collateral is required to run JitMakerBot, run with --force-deposit flag to deposit collateral` ); } + + const hrStart = process.hrtime(); await jitter.subscribe(); + const hrEnd = process.hrtime(hrStart); + logger.info(`jitter.subscribe took: ${hrEnd[0]}s ${hrEnd[1] / 1e6}ms`); + } + + logger.info( + `Checking if need PriorityFeeSubscriber: ${needPriorityFeeSubscriber}` + ); + if (needPriorityFeeSubscriber) { + const hrStart = process.hrtime(); + await priorityFeeSubscriber.subscribe(); + const hrEnd = process.hrtime(hrStart); + logger.info( + `priorityFeeSubscriber.subscribe() took: ${hrEnd[0]}s ${hrEnd[1] / 1e6}ms` + ); } if (bots.length === 0) {