Skip to content

Commit

Permalink
Merge pull request #332 from drift-labs/master
Browse files Browse the repository at this point in the history
mainnet
  • Loading branch information
wphan authored Dec 24, 2024
2 parents 7203e6b + f92e25a commit 5155b17
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/experimental-bots/filler-common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,13 @@ export const getPriorityFeeInstruction = (priorityFeeMicroLamports: number) => {
microLamports,
});
};

export const isTsRuntime = (): boolean => {
// @ts-ignore - This is how to check for tsx unfortunately https://github.com/privatenumber/tsx/issues/49
const isTsx: boolean = process._preload_modules.some((m: string) =>
m.includes('tsx')
);
const isTsNode = process.argv.some((arg) => arg.includes('ts-node'));
const isBun = process.versions.bun !== undefined;
return isTsNode || isTsx || isBun;
};
14 changes: 11 additions & 3 deletions src/experimental-bots/filler/fillerMultithreaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
deserializeNodeToFill,
deserializeOrder,
getPriorityFeeInstruction,
isTsRuntime,
} from '../filler-common/utils';
import {
CounterValue,
Expand Down Expand Up @@ -109,6 +110,8 @@ import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes';
import { ChildProcess } from 'child_process';
import { PythPriceFeedSubscriber } from 'src/pythPriceFeedSubscriber';
import { PythLazerClient } from '@pythnetwork/pyth-lazer-sdk';
import path from 'path';


const logPrefix = '[Filler]';
export type MakerNodeMap = Map<string, DLOBNode[]>;
Expand Down Expand Up @@ -504,8 +507,9 @@ export class FillerMultithreaded {
`--market-type=${this.config.marketType}`,
`--market-indexes=${marketIndexes.map(String)}`,
];
const dlobBuilderFileName = 'dlobBuilder' + isTsRuntime() ? '.ts' : '.js';
const dlobBuilderProcess = spawnChild(
'./src/experimental-bots/filler-common/dlobBuilder.ts',
path.join(__dirname, '../filler-common', dlobBuilderFileName),
dlobBuilderArgs,
'dlobBuilder',
(msg: any) => {
Expand Down Expand Up @@ -596,8 +600,10 @@ export class FillerMultithreaded {
}
};

const orderSubscriberFileName =
'orderSubscriberFiltered' + isTsRuntime() ? '.ts' : '.js';
const orderSubscriberProcess = spawnChild(
'./src/experimental-bots/filler-common/orderSubscriberFiltered.ts',
path.join(__dirname, '../filler-common', orderSubscriberFileName),
orderSubscriberArgs,
'orderSubscriber',
(msg: any) => {
Expand All @@ -623,8 +629,10 @@ export class FillerMultithreaded {
);

// Swift Subscriber process
const swiftOrderSubscriberFileName =
'swiftOrderSubscriber' + isTsRuntime() ? '.ts' : '.js';
const swiftOrderSubscriberProcess = spawnChild(
'./src/experimental-bots/filler-common/swiftOrderSubscriber.ts',
path.join(__dirname, '../filler-common', swiftOrderSubscriberFileName),
orderSubscriberArgs,
'swiftOrderSubscriber',
(msg: any) => {
Expand Down
10 changes: 8 additions & 2 deletions src/experimental-bots/spotFiller/spotFillerMultithreaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
deserializeOrder,
serializeNodeToFill,
spawnChild,
isTsRuntime,
} from '../filler-common/utils';
import {
CACHED_BLOCKHASH_OFFSET,
Expand All @@ -98,6 +99,7 @@ import { getErrorCode } from '../../error';
import { webhookMessage } from '../../webhook';
import { selectMakers } from '../../makerSelection';
import { PythPriceFeedSubscriber } from 'src/pythPriceFeedSubscriber';
import path from 'path';

enum METRIC_TYPES {
try_fill_duration_histogram = 'try_fill_duration_histogram',
Expand Down Expand Up @@ -457,8 +459,10 @@ export class SpotFillerMultithreaded {
`--market-type=${this.config.marketType}`,
`--market-indexes=${marketIndexes.map(String)}`,
];

const dlobBuilderFileName = 'dlobBuilder' + isTsRuntime() ? '.ts' : '.js';
const dlobBuilderProcess = spawnChild(
'./src/experimental-bots/filler-common/dlobBuilder.ts',
path.join(__dirname, '../filler-common', dlobBuilderFileName),
dlobBuilderArgs,
'dlobBuilder',
(msg: any) => {
Expand Down Expand Up @@ -549,8 +553,10 @@ export class SpotFillerMultithreaded {
}
};

const orderSubscriberFileName =
'orderSubscriberFiltered' + isTsRuntime() ? '.ts' : '.js';
const orderSubscriberProcess = spawnChild(
'./src/experimental-bots/filler-common/orderSubscriberFiltered.ts',
path.join(__dirname, '../filler-common', orderSubscriberFileName),
orderSubscriberArgs,
'orderSubscriber',
(msg: any) => {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,7 @@ es6-promisify@^5.0.0:
dependencies:
es6-promise "^4.0.3"

esbuild@^0.24.0:
[email protected]:
version "0.24.0"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.0.tgz#f2d470596885fcb2e91c21eb3da3b3c89c0b55e7"
integrity sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==
Expand Down Expand Up @@ -5150,7 +5150,7 @@ thread-stream@^0.15.1:
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==

tiny-glob@^0.2.9:
[email protected]:
version "0.2.9"
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.9.tgz#2212d441ac17928033b110f8b3640683129d31e2"
integrity sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==
Expand Down

0 comments on commit 5155b17

Please sign in to comment.