chore: update to common redis + top markers account flag
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
PerpMarketConfig,
|
||||
SpotMarketConfig,
|
||||
} from '@drift-labs/sdk';
|
||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||
|
||||
import { logger, setLogLevel } from '../utils/logger';
|
||||
import {
|
||||
@@ -31,7 +32,6 @@ import {
|
||||
DLOBSubscriberIO,
|
||||
wsMarketInfo,
|
||||
} from '../dlob-subscriber/DLOBSubscriberIO';
|
||||
import { RedisClient } from '../utils/redisClient';
|
||||
import {
|
||||
DLOBProvider,
|
||||
getDLOBProviderFromGrpcOrderSubscriber,
|
||||
@@ -47,9 +47,8 @@ require('dotenv').config();
|
||||
const stateCommitment: Commitment = 'confirmed';
|
||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||
const commitHash = process.env.COMMIT;
|
||||
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
||||
const REDIS_PORT = process.env.REDIS_PORT || '6379';
|
||||
const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
|
||||
|
||||
const REDIS_CLIENT = process.env.REDIS_CLIENT || 'DLOB';
|
||||
|
||||
// Set up express for health checks
|
||||
const app = express();
|
||||
@@ -259,6 +258,11 @@ const main = async () => {
|
||||
const wallet = new Wallet(new Keypair());
|
||||
const clearingHousePublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
|
||||
|
||||
const redisClient = new RedisClient({
|
||||
prefix: RedisClientPrefix[REDIS_CLIENT],
|
||||
});
|
||||
await redisClient.connect();
|
||||
|
||||
const connection = new Connection(endpoint, {
|
||||
wsEndpoint: wsEndpoint,
|
||||
commitment: stateCommitment,
|
||||
@@ -391,9 +395,6 @@ const main = async () => {
|
||||
|
||||
await dlobProvider.subscribe();
|
||||
|
||||
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
||||
await redisClient.connect();
|
||||
|
||||
const dlobSubscriber = new DLOBSubscriberIO({
|
||||
driftClient,
|
||||
env: driftEnv,
|
||||
|
||||
@@ -10,20 +10,17 @@ import {
|
||||
BulkAccountLoader,
|
||||
getMarketsAndOraclesForSubscription,
|
||||
} from '@drift-labs/sdk';
|
||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||
|
||||
import { logger, setLogLevel } from '../utils/logger';
|
||||
import { sleep } from '../utils/utils';
|
||||
import express from 'express';
|
||||
// import { handleHealthCheck } from '../core/metrics';
|
||||
import { RedisClient } from '../utils/redisClient';
|
||||
|
||||
require('dotenv').config();
|
||||
const stateCommitment: Commitment = 'confirmed';
|
||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||
const commitHash = process.env.COMMIT;
|
||||
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
||||
const REDIS_PORT = process.env.REDIS_PORT || '6379';
|
||||
const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
|
||||
|
||||
// Set up express for health checks
|
||||
const app = express();
|
||||
@@ -137,25 +134,25 @@ class PriorityFeeSubscriber {
|
||||
|
||||
dataPerp.forEach((result: any) => {
|
||||
const marketIndex = parseInt(result['id']);
|
||||
this.redisClient.client.publish(
|
||||
this.redisClient.publish(
|
||||
`priorityFees_perp_${marketIndex}`,
|
||||
JSON.stringify(result.result['priorityFeeLevels'])
|
||||
result.result['priorityFeeLevels']
|
||||
);
|
||||
this.redisClient.client.set(
|
||||
this.redisClient.set(
|
||||
`priorityFees_perp_${marketIndex}`,
|
||||
JSON.stringify(result.result['priorityFeeLevels'])
|
||||
result.result['priorityFeeLevels']
|
||||
);
|
||||
});
|
||||
|
||||
dataSpot.forEach((result: any) => {
|
||||
const marketIndex = parseInt(result['id']) - 100;
|
||||
this.redisClient.client.publish(
|
||||
this.redisClient.publish(
|
||||
`priorityFees_spot_${marketIndex}`,
|
||||
JSON.stringify(result.result['priorityFeeLevels'])
|
||||
result.result['priorityFeeLevels']
|
||||
);
|
||||
this.redisClient.client.set(
|
||||
this.redisClient.set(
|
||||
`priorityFees_spot_${marketIndex}`,
|
||||
JSON.stringify(result.result['priorityFeeLevels'])
|
||||
result.result['priorityFeeLevels']
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -167,6 +164,11 @@ const main = async () => {
|
||||
commitment: stateCommitment,
|
||||
});
|
||||
|
||||
const redisClient = new RedisClient({
|
||||
prefix: RedisClientPrefix.DLOB_HELIUS,
|
||||
});
|
||||
await redisClient.connect();
|
||||
|
||||
const { perpMarketIndexes, spotMarketIndexes, oracleInfos } =
|
||||
getMarketsAndOraclesForSubscription(sdkConfig.ENV);
|
||||
|
||||
@@ -209,9 +211,6 @@ const main = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
||||
await redisClient.connect();
|
||||
|
||||
const priorityFeeSubscriber = new PriorityFeeSubscriber({
|
||||
endpoint,
|
||||
perpMarketPubkeys,
|
||||
|
||||
@@ -20,18 +20,15 @@ import {
|
||||
OrderActionRecord,
|
||||
Event,
|
||||
} from '@drift-labs/sdk';
|
||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||
|
||||
import { logger, setLogLevel } from '../utils/logger';
|
||||
import { sleep } from '../utils/utils';
|
||||
import { RedisClient } from '../utils/redisClient';
|
||||
import { fromEvent, filter, map } from 'rxjs';
|
||||
|
||||
require('dotenv').config();
|
||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||
const commitHash = process.env.COMMIT;
|
||||
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
||||
const REDIS_PORT = process.env.REDIS_PORT || '6379';
|
||||
const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
|
||||
|
||||
//@ts-ignore
|
||||
const sdkConfig = initialize({ env: process.env.ENV });
|
||||
@@ -70,6 +67,9 @@ const main = async () => {
|
||||
env: driftEnv,
|
||||
});
|
||||
|
||||
const redisClient = new RedisClient({ prefix: RedisClientPrefix.DLOB });
|
||||
await redisClient.connect();
|
||||
|
||||
const slotSubscriber = new SlotSubscriber(connection, {});
|
||||
|
||||
const lamportsBalance = await connection.getBalance(wallet.publicKey);
|
||||
@@ -86,9 +86,6 @@ const main = async () => {
|
||||
|
||||
await slotSubscriber.subscribe();
|
||||
|
||||
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
||||
await redisClient.connect();
|
||||
|
||||
const eventSubscriber = new EventSubscriber(connection, driftClient.program, {
|
||||
maxTx: 8192,
|
||||
maxEventsPerType: 4096,
|
||||
@@ -182,9 +179,9 @@ const main = async () => {
|
||||
})
|
||||
)
|
||||
.subscribe((fillEvent) => {
|
||||
redisClient.client.publish(
|
||||
redisClient.publish(
|
||||
`trades_${fillEvent.marketType}_${fillEvent.marketIndex}`,
|
||||
JSON.stringify(fillEvent)
|
||||
fillEvent
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user