Skip to content

Commit

Permalink
Merge pull request #142 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: element fixes
  • Loading branch information
nofir authored Nov 25, 2024
2 parents 6f5ba35 + f8954ba commit 2c3e02c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const config = {
),
x2y2ApiKey: String(process.env.X2Y2_API_KEY),
looksrareApiKey: String(process.env.LOOKSRARE_API_KEY),
elementApiKey: String(process.env.ELEMENT_API_KEY),
elementChainName: process.env.ELEMENT_CHAIN_NAME,

blurApiKey: String(process.env.BLUR_API_KEY),

openseaNftApiKey: String(process.env.OPENSEA_NFT_API_KEY),
Expand All @@ -30,6 +29,11 @@ export const config = {
okxChainName: process.env.OKX_CHAIN_NAME,
doOkxWork: Boolean(Number(process.env.DO_OKX_WORK || 1)),

// Element
elementApiKey: String(process.env.ELEMENT_API_KEY),
elementChainName: process.env.ELEMENT_CHAIN_NAME,
doElementWork: Boolean(Number(process.env.DO_ELEMENT_WORK || 1)),

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
10 changes: 5 additions & 5 deletions src/jobs/element-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { acquireLock, redis } from "../../common/redis";
import { config } from "../../config";
import { Element } from "../../utils/element";

if (config.doRealtimeWork) {
cron.schedule("*/5 * * * * *", async () => {
if (config.doRealtimeWork && config.doElementWork) {
cron.schedule("*/1 * * * *", async () => {
if (new Element().getChainName()) {
const lockAcquired = await acquireLock("element-sync-lock", 60 * 5);
const lockAcquired = await acquireLock("element-sync-lock", 60 - 5);
if (lockAcquired) {
const cacheKey = "element-sync-cursor";
const cursor = await redis.get(cacheKey);
Expand All @@ -31,11 +31,11 @@ if (config.doRealtimeWork) {
}
});

cron.schedule("*/30 * * * * *", async () => {
cron.schedule("*/1 * * * *", async () => {
if (new Element().getChainName()) {
const lockAcquired = await acquireLock(
"element-sync-offers-lock",
60 * 5
60 - 5
);
if (lockAcquired) {
const cacheKey = "element-sync-offers-cursor";
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/element-sync/queues/backfill-queue-offers.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.doElementWork) {
const backfillWorker = new Worker(
BACKFILL_QUEUE_NAME,
async (job: Job) => {
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/element-sync/queues/backfill-queue.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.doElementWork) {
const backfillWorker = new Worker(
BACKFILL_QUEUE_NAME,
async (job: Job) => {
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/element-sync/queues/realtime-queue-offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const realtimeQueue = new Queue(REALTIME_QUEUE_NAME, {
});
new QueueScheduler(REALTIME_QUEUE_NAME, { connection: redis.duplicate() });

if (config.doRealtimeWork) {
if (config.doRealtimeWork && config.doElementWork) {
const realtimeWorker = new Worker(
REALTIME_QUEUE_NAME,
async (job: Job) => {
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/element-sync/queues/realtime-queue.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.doElementWork) {
const realtimeWorker = new Worker(
REALTIME_QUEUE_NAME,
async (job: Job) => {
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/element-sync/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const fetchOrders = async (
) {
parsedOrders.push({
order: parsedOrder,
originatedAt: new Date(order.createTime).toISOString(),
originatedAt: new Date(order.createTime * 1000).toISOString(),
});
}

Expand Down

0 comments on commit 2c3e02c

Please sign in to comment.