Skip to content

Commit 5155b17

Browse files
authored
Merge pull request #332 from drift-labs/master
mainnet
2 parents 7203e6b + f92e25a commit 5155b17

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

src/experimental-bots/filler-common/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,13 @@ export const getPriorityFeeInstruction = (priorityFeeMicroLamports: number) => {
472472
microLamports,
473473
});
474474
};
475+
476+
export const isTsRuntime = (): boolean => {
477+
// @ts-ignore - This is how to check for tsx unfortunately https://github.com/privatenumber/tsx/issues/49
478+
const isTsx: boolean = process._preload_modules.some((m: string) =>
479+
m.includes('tsx')
480+
);
481+
const isTsNode = process.argv.some((arg) => arg.includes('ts-node'));
482+
const isBun = process.versions.bun !== undefined;
483+
return isTsNode || isTsx || isBun;
484+
};

src/experimental-bots/filler/fillerMultithreaded.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
deserializeNodeToFill,
7676
deserializeOrder,
7777
getPriorityFeeInstruction,
78+
isTsRuntime,
7879
} from '../filler-common/utils';
7980
import {
8081
CounterValue,
@@ -109,6 +110,8 @@ import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes';
109110
import { ChildProcess } from 'child_process';
110111
import { PythPriceFeedSubscriber } from 'src/pythPriceFeedSubscriber';
111112
import { PythLazerClient } from '@pythnetwork/pyth-lazer-sdk';
113+
import path from 'path';
114+
112115

113116
const logPrefix = '[Filler]';
114117
export type MakerNodeMap = Map<string, DLOBNode[]>;
@@ -504,8 +507,9 @@ export class FillerMultithreaded {
504507
`--market-type=${this.config.marketType}`,
505508
`--market-indexes=${marketIndexes.map(String)}`,
506509
];
510+
const dlobBuilderFileName = 'dlobBuilder' + isTsRuntime() ? '.ts' : '.js';
507511
const dlobBuilderProcess = spawnChild(
508-
'./src/experimental-bots/filler-common/dlobBuilder.ts',
512+
path.join(__dirname, '../filler-common', dlobBuilderFileName),
509513
dlobBuilderArgs,
510514
'dlobBuilder',
511515
(msg: any) => {
@@ -596,8 +600,10 @@ export class FillerMultithreaded {
596600
}
597601
};
598602

603+
const orderSubscriberFileName =
604+
'orderSubscriberFiltered' + isTsRuntime() ? '.ts' : '.js';
599605
const orderSubscriberProcess = spawnChild(
600-
'./src/experimental-bots/filler-common/orderSubscriberFiltered.ts',
606+
path.join(__dirname, '../filler-common', orderSubscriberFileName),
601607
orderSubscriberArgs,
602608
'orderSubscriber',
603609
(msg: any) => {
@@ -623,8 +629,10 @@ export class FillerMultithreaded {
623629
);
624630

625631
// Swift Subscriber process
632+
const swiftOrderSubscriberFileName =
633+
'swiftOrderSubscriber' + isTsRuntime() ? '.ts' : '.js';
626634
const swiftOrderSubscriberProcess = spawnChild(
627-
'./src/experimental-bots/filler-common/swiftOrderSubscriber.ts',
635+
path.join(__dirname, '../filler-common', swiftOrderSubscriberFileName),
628636
orderSubscriberArgs,
629637
'swiftOrderSubscriber',
630638
(msg: any) => {

src/experimental-bots/spotFiller/spotFillerMultithreaded.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
deserializeOrder,
7474
serializeNodeToFill,
7575
spawnChild,
76+
isTsRuntime,
7677
} from '../filler-common/utils';
7778
import {
7879
CACHED_BLOCKHASH_OFFSET,
@@ -98,6 +99,7 @@ import { getErrorCode } from '../../error';
9899
import { webhookMessage } from '../../webhook';
99100
import { selectMakers } from '../../makerSelection';
100101
import { PythPriceFeedSubscriber } from 'src/pythPriceFeedSubscriber';
102+
import path from 'path';
101103

102104
enum METRIC_TYPES {
103105
try_fill_duration_histogram = 'try_fill_duration_histogram',
@@ -457,8 +459,10 @@ export class SpotFillerMultithreaded {
457459
`--market-type=${this.config.marketType}`,
458460
`--market-indexes=${marketIndexes.map(String)}`,
459461
];
462+
463+
const dlobBuilderFileName = 'dlobBuilder' + isTsRuntime() ? '.ts' : '.js';
460464
const dlobBuilderProcess = spawnChild(
461-
'./src/experimental-bots/filler-common/dlobBuilder.ts',
465+
path.join(__dirname, '../filler-common', dlobBuilderFileName),
462466
dlobBuilderArgs,
463467
'dlobBuilder',
464468
(msg: any) => {
@@ -549,8 +553,10 @@ export class SpotFillerMultithreaded {
549553
}
550554
};
551555

556+
const orderSubscriberFileName =
557+
'orderSubscriberFiltered' + isTsRuntime() ? '.ts' : '.js';
552558
const orderSubscriberProcess = spawnChild(
553-
'./src/experimental-bots/filler-common/orderSubscriberFiltered.ts',
559+
path.join(__dirname, '../filler-common', orderSubscriberFileName),
554560
orderSubscriberArgs,
555561
'orderSubscriber',
556562
(msg: any) => {

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,7 @@ es6-promisify@^5.0.0:
31373137
dependencies:
31383138
es6-promise "^4.0.3"
31393139

3140-
esbuild@^0.24.0:
3140+
31413141
version "0.24.0"
31423142
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.0.tgz#f2d470596885fcb2e91c21eb3da3b3c89c0b55e7"
31433143
integrity sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==
@@ -5150,7 +5150,7 @@ thread-stream@^0.15.1:
51505150
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
51515151
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==
51525152

5153-
tiny-glob@^0.2.9:
5153+
51545154
version "0.2.9"
51555155
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.9.tgz#2212d441ac17928033b110f8b3640683129d31e2"
51565156
integrity sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==

0 commit comments

Comments
 (0)