Skip to content

Commit

Permalink
Merge pull request #140 from reservoirprotocol/ofir/platf-4708-invest…
Browse files Browse the repository at this point in the history
…igate-element-okx-orders-not-being-aggregating-on

feat: add env var
  • Loading branch information
nofir authored Nov 21, 2024
2 parents 768c36d + 9cd4322 commit 8d906a9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ export const config = {
elementApiKey: String(process.env.ELEMENT_API_KEY),
elementChainName: process.env.ELEMENT_CHAIN_NAME,
blurApiKey: String(process.env.BLUR_API_KEY),
okxApiKey: String(process.env.OKX_API_KEY),
okxSecretKey: String(process.env.OKX_SECRET_KEY),
okxPassphrase: String(process.env.OKX_PASSPHRASE),
okxChainName: process.env.OKX_CHAIN_NAME,

openseaNftApiKey: String(process.env.OPENSEA_NFT_API_KEY),

blurUrl: String(process.env.BLUR_URL),
openseaApiUrl: String(process.env.OPENSEA_API_URL),

// OKX
okxApiKey: String(process.env.OKX_API_KEY),
okxSecretKey: String(process.env.OKX_SECRET_KEY),
okxPassphrase: String(process.env.OKX_PASSPHRASE),
okxChainName: process.env.OKX_CHAIN_NAME,
doOkxWork: Boolean(Number(process.env.DO_OKX_WORK)),

doBackgroundWork: Boolean(Number(process.env.DO_BACKGROUND_WORK)),
doBackfillWork: Boolean(Number(process.env.DO_BACKFILL_WORK)),
doRealtimeWork: Boolean(Number(process.env.DO_REALTIME_WORK)),
Expand Down
3 changes: 2 additions & 1 deletion src/jobs/okx-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { acquireLock } from "../../common/redis";
import { config } from "../../config";
import { Okx } from "../../utils/okx";

if (config.doRealtimeWork) {
if (config.doRealtimeWork && config.doOkxWork) {
if (new Okx().getChainName()) {
cron.schedule("*/30 * * * * *", async () => {
const lockAcquired = await acquireLock(
realtimeQueueListings.getLockKey(),
60 * 10
);

if (lockAcquired) {
await realtimeQueueListings.addToRealtimeQueue();
}
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/okx-sync/queues/backfill-queue-listings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const backfillQueue = new Queue(BACKFILL_QUEUE_NAME, {
});
new QueueScheduler(BACKFILL_QUEUE_NAME, { connection: redis.duplicate() });

if (config.doBackfillWork) {
if (config.doBackfillWork && config.doOkxWork) {
const realtimeWorker = new Worker(
BACKFILL_QUEUE_NAME,
async (job: Job) => {
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/okx-sync/queues/realtime-queue-listings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const realtimeQueue = new Queue(REALTIME_QUEUE_NAME, {
});
new QueueScheduler(REALTIME_QUEUE_NAME, { connection: redis.duplicate() });

if (config.doRealtimeWork) {
if (config.doRealtimeWork && config.doOkxWork) {
const realtimeWorker = new Worker(
REALTIME_QUEUE_NAME,
async (job: Job) => {
Expand Down

0 comments on commit 8d906a9

Please sign in to comment.