Skip to content

Commit

Permalink
address cmts
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill committed Nov 9, 2023
1 parent a2a6d12 commit 863c2ee
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
} from '../../helpers/indexer-proto-helpers';
import { DydxIndexerSubtypes } from '../../../src/lib/types';
import {
DELEVERAGING_EVENT_TYPE,
MILLIS_IN_NANOS,
SECONDS_IN_MILLIS,
SUBACCOUNT_ORDER_FILL_EVENT_TYPE,
Expand Down Expand Up @@ -165,14 +164,10 @@ describe('DeleveragingHandler', () => {
expect(handler.getParallelizationIds()).toEqual([
`${handler.eventType}_${offsettingSubaccountUuid}_${perpetualMarket!.clobPairId}`,
`${handler.eventType}_${deleveragedSubaccountUuid}_${perpetualMarket!.clobPairId}`,
// To ensure that SubaccountUpdateEvents and OrderFillEvents for the same subaccount are not
// processed in parallel
// To ensure that SubaccountUpdateEvents, OrderFillEvents, and DeleveragingEvents for
// the same subaccount are not processed in parallel
`${SUBACCOUNT_ORDER_FILL_EVENT_TYPE}_${offsettingSubaccountUuid}`,
`${SUBACCOUNT_ORDER_FILL_EVENT_TYPE}_${deleveragedSubaccountUuid}`,
// To ensure that StatefulOrderEvents and OrderFillEvents for the same order are not
// processed in parallel
`${DELEVERAGING_EVENT_TYPE}_${offsettingSubaccountUuid}`,
`${DELEVERAGING_EVENT_TYPE}_${deleveragedSubaccountUuid}`,
]);
});

Expand Down Expand Up @@ -298,13 +293,8 @@ describe('DeleveragingHandler', () => {
deleveragedPerpetualPosition.openEventId,
),
{
sumOpen: Big(deleveragedPerpetualPosition.size).plus(totalFilled).toFixed(),
entryPrice: getWeightedAverage(
deleveragedPerpetualPosition.entryPrice!,
deleveragedPerpetualPosition.size,
price,
totalFilled,
),
sumClose: Big(totalFilled).toFixed(),
exitPrice: price,
},
),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
import { KafkaMessage } from 'kafkajs';
import { DateTime } from 'luxon';
import {
DELEVERAGING_EVENT_TYPE,
MILLIS_IN_NANOS,
SECONDS_IN_MILLIS,
STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE,
Expand Down Expand Up @@ -200,9 +199,6 @@ describe('LiquidationHandler', () => {
if (orderId !== undefined) {
parallelizationIds.push(`${STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE}_${orderId}`);
}
parallelizationIds.push(
`${DELEVERAGING_EVENT_TYPE}_${SubaccountTable.subaccountIdToUuid(subaccountId)}`,
);
expect(handler.getParallelizationIds()).toEqual(parallelizationIds);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
import { KafkaMessage } from 'kafkajs';
import { DateTime } from 'luxon';
import {
DELEVERAGING_EVENT_TYPE,
MILLIS_IN_NANOS,
SECONDS_IN_MILLIS,
STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE,
Expand Down Expand Up @@ -198,7 +197,6 @@ describe('OrderHandler', () => {
`${handler.eventType}_${SubaccountTable.subaccountIdToUuid(subaccountId)}_${defaultOrderEvent.makerOrder!.orderId!.clobPairId}`,
`${SUBACCOUNT_ORDER_FILL_EVENT_TYPE}_${SubaccountTable.subaccountIdToUuid(subaccountId)}`,
`${STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE}_${orderUuid}`,
`${DELEVERAGING_EVENT_TYPE}_${SubaccountTable.subaccountIdToUuid(subaccountId)}`,
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { DeleveragingEventV1 } from '@dydxprotocol-indexer/v4-protos';
import * as pg from 'pg';

import { DELEVERAGING_EVENT_TYPE, SUBACCOUNT_ORDER_FILL_EVENT_TYPE } from '../../constants';
import { SUBACCOUNT_ORDER_FILL_EVENT_TYPE } from '../../constants';
import { indexerTendermintEventToTransactionIndex } from '../../lib/helper';
import { ConsolidatedKafkaEvent } from '../../lib/types';
import { AbstractOrderFillHandler } from './abstract-order-fill-handler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import Long from 'long';
import * as pg from 'pg';

import config from '../../config';
import {
DELEVERAGING_EVENT_TYPE,
STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE,
SUBACCOUNT_ORDER_FILL_EVENT_TYPE,
} from '../../constants';
import { STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE, SUBACCOUNT_ORDER_FILL_EVENT_TYPE } from '../../constants';
import { convertPerpetualPosition } from '../../helpers/kafka-helper';
import { redisClient } from '../../helpers/redis/redis-controller';
import {
Expand Down Expand Up @@ -78,9 +74,6 @@ export class LiquidationHandler extends AbstractOrderFillHandler<OrderFillWithLi
// To ensure that SubaccountUpdateEvents and OrderFillEvents for the same subaccount are not
// processed in parallel
`${SUBACCOUNT_ORDER_FILL_EVENT_TYPE}_${subaccountUuid}`,
// To ensure that DeleveragingEvents for the same subaccount are not
// processed in parallel
`${DELEVERAGING_EVENT_TYPE}_${subaccountUuid}`,
// We do not need to add the StatefulOrderEvent parallelizationId here, because liquidation
// fills have no order in postgres
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import Long from 'long';
import * as pg from 'pg';

import config from '../../config';
import {
DELEVERAGING_EVENT_TYPE,
STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE,
SUBACCOUNT_ORDER_FILL_EVENT_TYPE,
} from '../../constants';
import { STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE, SUBACCOUNT_ORDER_FILL_EVENT_TYPE } from '../../constants';
import { convertPerpetualPosition } from '../../helpers/kafka-helper';
import { redisClient } from '../../helpers/redis/redis-controller';
import { orderFillWithLiquidityToOrderFillEventWithOrder } from '../../helpers/translation-helper';
Expand Down Expand Up @@ -61,9 +57,6 @@ export class OrderHandler extends AbstractOrderFillHandler<OrderFillWithLiquidit
// To ensure that StatefulOrderEvents and OrderFillEvents for the same order are not
// processed in parallel
`${STATEFUL_ORDER_ORDER_FILL_EVENT_TYPE}_${orderUuid}`,
// To ensure that DeleveragingEvents for the same subaccount are not
// processed in parallel
`${DELEVERAGING_EVENT_TYPE}_${subaccountUuid}`,
];
}

Expand Down

0 comments on commit 863c2ee

Please sign in to comment.