Skip to content

Commit

Permalink
Send notification test from ender
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfraser committed Aug 13, 2024
1 parent f813892 commit 1034845
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions indexer/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions indexer/services/ender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@dydxprotocol-indexer/redis": "workspace:^0.0.1",
"@dydxprotocol-indexer/v4-proto-parser": "workspace:^0.0.1",
"@dydxprotocol-indexer/v4-protos": "workspace:^0.0.1",
"@dydxprotocol-indexer/notifications": "workspace:^0.0.1",
"big.js": "^6.0.2",
"dd-trace": "^3.32.1",
"dotenv-flow": "^3.2.0",
Expand Down
18 changes: 17 additions & 1 deletion indexer/services/ender/src/handlers/order-fills/order-handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
sendFirebaseMessage,
createNotification,
NotificationType,
NotificationDynamicFieldKey,
} from '@dydxprotocol-indexer/notifications';
import {
FillFromDatabase,
FillModel,
Expand All @@ -18,7 +24,9 @@ import {
} from '@dydxprotocol-indexer/postgres';
import { StateFilledQuantumsCache } from '@dydxprotocol-indexer/redis';
import { isStatefulOrder } from '@dydxprotocol-indexer/v4-proto-parser';
import { IndexerOrder, IndexerOrderId, IndexerSubaccountId } from '@dydxprotocol-indexer/v4-protos';
import {
ClobPair, IndexerOrder, IndexerOrderId, IndexerSubaccountId,
} from '@dydxprotocol-indexer/v4-protos';
import Long from 'long';
import * as pg from 'pg';

Expand Down Expand Up @@ -118,6 +126,14 @@ export class OrderHandler extends AbstractOrderFillHandler<OrderFillWithLiquidit
// block.
if (order.status === OrderStatus.FILLED && isStatefulOrder(order.orderFlags)) {
kafkaEvents.push(this.getOrderRemoveKafkaEvent(orderProto.orderId!));

const subaccount = await SubaccountTable.findById(order.subaccountId);
const notification = createNotification(NotificationType.ORDER_FILLED, {
[NotificationDynamicFieldKey.MARKET]: 'BTC/USD',
[NotificationDynamicFieldKey.AVERAGE_PRICE]: order.price,
});

await sendFirebaseMessage(subaccount!.address, notification);
}

if (this.event.liquidity === Liquidity.TAKER) {
Expand Down

0 comments on commit 1034845

Please sign in to comment.