@axxel/event-bus 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/config/kafka.d.ts +0 -0
- package/dist/config/kafka.d.ts.map +0 -0
- package/dist/config/kafka.js +0 -0
- package/dist/consumers/index.d.ts +1 -0
- package/dist/consumers/index.d.ts.map +1 -1
- package/dist/consumers/index.js +1 -0
- package/dist/consumers/tokenPriceConsumer.d.ts +0 -0
- package/dist/consumers/tokenPriceConsumer.d.ts.map +0 -0
- package/dist/consumers/tokenPriceConsumer.js +0 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts +8 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts.map +1 -0
- package/dist/consumers/tradeExecutionConsumer.js +27 -0
- package/dist/consumers/walletTransactionConsumer.d.ts +0 -0
- package/dist/consumers/walletTransactionConsumer.d.ts.map +0 -0
- package/dist/consumers/walletTransactionConsumer.js +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/producers/index.d.ts +1 -0
- package/dist/producers/index.d.ts.map +1 -1
- package/dist/producers/index.js +1 -0
- package/dist/producers/tokenPriceProducer.d.ts +0 -0
- package/dist/producers/tokenPriceProducer.d.ts.map +0 -0
- package/dist/producers/tokenPriceProducer.js +0 -0
- package/dist/producers/tradeExecutionProducer.d.ts +3 -0
- package/dist/producers/tradeExecutionProducer.d.ts.map +1 -0
- package/dist/producers/tradeExecutionProducer.js +21 -0
- package/dist/producers/walletTransactionProducer.d.ts +0 -0
- package/dist/producers/walletTransactionProducer.d.ts.map +0 -0
- package/dist/producers/walletTransactionProducer.js +0 -0
- package/dist/topics.d.ts +1 -0
- package/dist/topics.d.ts.map +1 -1
- package/dist/topics.js +1 -0
- package/dist/types/TokenPriceEvent.d.ts +0 -0
- package/dist/types/TokenPriceEvent.d.ts.map +0 -0
- package/dist/types/TokenPriceEvent.js +0 -0
- package/dist/types/TradeExecutionEvent.d.ts +15 -0
- package/dist/types/TradeExecutionEvent.d.ts.map +1 -0
- package/dist/types/TradeExecutionEvent.js +2 -0
- package/dist/types/WalletTransactionEvent.d.ts +0 -0
- package/dist/types/WalletTransactionEvent.d.ts.map +0 -0
- package/dist/types/WalletTransactionEvent.js +0 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/validation/common.d.ts +0 -0
- package/dist/validation/common.d.ts.map +0 -0
- package/dist/validation/common.js +0 -0
- package/dist/validation/tokenPriceEvent.schema.d.ts +0 -0
- package/dist/validation/tokenPriceEvent.schema.d.ts.map +1 -1
- package/dist/validation/tokenPriceEvent.schema.js +7 -3
- package/dist/validation/walletTransactionEvent.schema.d.ts +0 -0
- package/dist/validation/walletTransactionEvent.schema.d.ts.map +0 -0
- package/dist/validation/walletTransactionEvent.schema.js +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
File without changes
|
package/dist/config/kafka.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/config/kafka.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
|
package/dist/consumers/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./tokenPriceConsumer"), exports);
|
|
18
18
|
__exportStar(require("./walletTransactionConsumer"), exports);
|
|
19
|
+
__exportStar(require("./tradeExecutionConsumer"), exports);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TradeExecutionEvent } from '../types/TradeExecutionEvent';
|
|
2
|
+
/**
|
|
3
|
+
* Start consuming trade execution events.
|
|
4
|
+
* @param groupId - unique consumer group ID
|
|
5
|
+
* @param handler - function to handle each trade execution event
|
|
6
|
+
*/
|
|
7
|
+
export declare function startTradeExecutionConsumer(groupId: string, handler: (event: TradeExecutionEvent) => Promise<void> | void): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=tradeExecutionConsumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tradeExecutionConsumer.d.ts","sourceRoot":"","sources":["../../src/consumers/tradeExecutionConsumer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,iBAqB9D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startTradeExecutionConsumer = startTradeExecutionConsumer;
|
|
4
|
+
const kafka_1 = require("../config/kafka");
|
|
5
|
+
const topics_1 = require("../topics");
|
|
6
|
+
/**
|
|
7
|
+
* Start consuming trade execution events.
|
|
8
|
+
* @param groupId - unique consumer group ID
|
|
9
|
+
* @param handler - function to handle each trade execution event
|
|
10
|
+
*/
|
|
11
|
+
async function startTradeExecutionConsumer(groupId, handler) {
|
|
12
|
+
const consumer = kafka_1.kafka.consumer({ groupId });
|
|
13
|
+
await consumer.connect();
|
|
14
|
+
await consumer.subscribe({
|
|
15
|
+
topic: topics_1.TOPICS.TRADE_EXECUTION,
|
|
16
|
+
fromBeginning: false,
|
|
17
|
+
});
|
|
18
|
+
await consumer.run({
|
|
19
|
+
eachMessage: async ({ message }) => {
|
|
20
|
+
if (!message.value)
|
|
21
|
+
return;
|
|
22
|
+
const event = JSON.parse(message.value.toString());
|
|
23
|
+
await handler(event);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
console.log(`📡 Listening for trade execution events (consumer group: ${groupId})`);
|
|
27
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from './validation/tokenPriceEvent.schema';
|
|
|
5
5
|
export * from './validation/walletTransactionEvent.schema';
|
|
6
6
|
export * from './producers/tokenPriceProducer';
|
|
7
7
|
export * from './producers/walletTransactionProducer';
|
|
8
|
+
export * from './producers/tradeExecutionProducer';
|
|
8
9
|
export * from './consumers/tokenPriceConsumer';
|
|
9
10
|
export * from './consumers/walletTransactionConsumer';
|
|
11
|
+
export * from './consumers/tradeExecutionConsumer';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,5 +21,7 @@ __exportStar(require("./validation/tokenPriceEvent.schema"), exports);
|
|
|
21
21
|
__exportStar(require("./validation/walletTransactionEvent.schema"), exports);
|
|
22
22
|
__exportStar(require("./producers/tokenPriceProducer"), exports);
|
|
23
23
|
__exportStar(require("./producers/walletTransactionProducer"), exports);
|
|
24
|
+
__exportStar(require("./producers/tradeExecutionProducer"), exports);
|
|
24
25
|
__exportStar(require("./consumers/tokenPriceConsumer"), exports);
|
|
25
26
|
__exportStar(require("./consumers/walletTransactionConsumer"), exports);
|
|
27
|
+
__exportStar(require("./consumers/tradeExecutionConsumer"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
|
package/dist/producers/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./tokenPriceProducer"), exports);
|
|
18
18
|
__exportStar(require("./walletTransactionProducer"), exports);
|
|
19
|
+
__exportStar(require("./tradeExecutionProducer"), exports);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tradeExecutionProducer.d.ts","sourceRoot":"","sources":["../../src/producers/tradeExecutionProducer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,iBAqBrE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.produceTradeExecution = produceTradeExecution;
|
|
4
|
+
const kafka_1 = require("../config/kafka");
|
|
5
|
+
const topics_1 = require("../topics");
|
|
6
|
+
async function produceTradeExecution(event) {
|
|
7
|
+
const producer = kafka_1.kafka.producer();
|
|
8
|
+
await producer.connect();
|
|
9
|
+
const key = `${event.chainId}:${event.walletAddress}`;
|
|
10
|
+
await producer.send({
|
|
11
|
+
topic: topics_1.TOPICS.TRADE_EXECUTION,
|
|
12
|
+
messages: [
|
|
13
|
+
{
|
|
14
|
+
key,
|
|
15
|
+
value: JSON.stringify(event),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
await producer.disconnect();
|
|
20
|
+
console.log(`✅ Execution event added for wallet=${event.walletAddress} on chain=${event.chainId} for ${event.orderType} order of type (${event.type} )`);
|
|
21
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/topics.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const TOPICS: {
|
|
2
2
|
readonly TOKEN_PRICES: "token-prices";
|
|
3
3
|
readonly WALLET_TRANSACTIONS: "wallet-transactions";
|
|
4
|
+
readonly TRADE_EXECUTION: "trade-execution";
|
|
4
5
|
};
|
|
5
6
|
export type Topic = (typeof TOPICS)[keyof typeof TOPICS];
|
|
6
7
|
//# sourceMappingURL=topics.d.ts.map
|
package/dist/topics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../src/topics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../src/topics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;CAIT,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
|
package/dist/topics.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type TradeExecutionEvent = {
|
|
2
|
+
orderId: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
tokenAddress: string;
|
|
6
|
+
walletAddress: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
slippage: string;
|
|
9
|
+
mev: boolean;
|
|
10
|
+
totalFee: string;
|
|
11
|
+
type: string;
|
|
12
|
+
executionPriceUsd: string;
|
|
13
|
+
orderType: 'limit' | 'trailing';
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=TradeExecutionEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TradeExecutionEvent.d.ts","sourceRoot":"","sources":["../../src/types/TradeExecutionEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,OAAO,GAAG,UAAU,CAAC;CACjC,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./TokenPriceEvent"), exports);
|
|
18
18
|
__exportStar(require("./WalletTransactionEvent"), exports);
|
|
19
|
+
__exportStar(require("./TradeExecutionEvent"), exports);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenPriceEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/tokenPriceEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tokenPriceEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/tokenPriceEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiDxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAQhC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAE3E"}
|
|
@@ -5,9 +5,9 @@ exports.ensureTokenPriceEvent = ensureTokenPriceEvent;
|
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const common_1 = require("./common");
|
|
7
7
|
const priceEntrySchema = zod_1.z.object({
|
|
8
|
-
price: zod_1.z.number()
|
|
8
|
+
price: zod_1.z.number(),
|
|
9
9
|
exchange: zod_1.z.string().min(1),
|
|
10
|
-
liquidity: zod_1.z.number()
|
|
10
|
+
liquidity: zod_1.z.number(),
|
|
11
11
|
});
|
|
12
12
|
const priceRecordSchema = zod_1.z.preprocess((value) => {
|
|
13
13
|
if (value instanceof Map) {
|
|
@@ -16,7 +16,11 @@ const priceRecordSchema = zod_1.z.preprocess((value) => {
|
|
|
16
16
|
if (typeof key !== 'string') {
|
|
17
17
|
throw new Error(`Invalid price key type: expected string, got ${typeof key}`);
|
|
18
18
|
}
|
|
19
|
-
if (typeof entry === 'object' &&
|
|
19
|
+
if (typeof entry === 'object' &&
|
|
20
|
+
entry !== null &&
|
|
21
|
+
'price' in entry &&
|
|
22
|
+
'exchange' in entry &&
|
|
23
|
+
'liquidity' in entry) {
|
|
20
24
|
normalized[key] = {
|
|
21
25
|
price: Number(entry.price),
|
|
22
26
|
exchange: String(entry.exchange),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axxel/event-bus",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Axxel Kafka Event Bus SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
"tsx": "^4.20.6",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|