@axxel/event-bus 1.0.6 → 1.0.8

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 CHANGED
@@ -54,8 +54,8 @@ await produceTokenPrice({
54
54
  price: {
55
55
  USD: { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 },
56
56
  },
57
- priceInUsd: 3250.42,
58
- fdvInUsd: 1234567890,
57
+ priceUsd: 3250.42,
58
+ fdv: 1234567890,
59
59
  symbol: 'WETH',
60
60
  updatedAt: Math.floor(Date.now() / 1000),
61
61
  });
@@ -86,8 +86,8 @@ const safePricePayload = ensureTokenPriceEvent({
86
86
  price: new Map([
87
87
  ['USD', { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 }],
88
88
  ]),
89
- priceInUsd: 3250.42,
90
- fdvInUsd: 1234567890,
89
+ priceUsd: 3250.42,
90
+ fdv: 1234567890,
91
91
  });
92
92
  await produceTokenPrice(safePricePayload);
93
93
  ```
@@ -108,7 +108,9 @@ await startTokenPriceConsumer('limit-orders', async (priceEvent) => {
108
108
  ? priceEvent.price.get('USD')
109
109
  : priceEvent.price['USD'];
110
110
  console.log(
111
- `📈 ${priceEvent.symbol ?? priceEvent.tokenAddress} @ $${usdInfo?.price ?? 'n/a'} (chain ${priceEvent.chainId})`,
111
+ `📈 ${priceEvent.symbol ?? priceEvent.tokenAddress} @ $${
112
+ usdInfo?.price ?? 'n/a'
113
+ } (chain ${priceEvent.chainId})`,
112
114
  );
113
115
  });
114
116
 
@@ -126,8 +128,8 @@ Multiple instances with the same group ID will automatically load-balance partit
126
128
 
127
129
  ## 🧠 Topics Overview
128
130
 
129
- | Topic | Description | Partition Key |
130
- | --------------------- | ------------------------------------------ | -------------- |
131
+ | Topic | Description | Partition Key |
132
+ | --------------------- | ------------------------------------------ | ----------------------- |
131
133
  | `token-prices` | Live token price updates across all chains | `chainId:tokenAddress` |
132
134
  | `wallet-transactions` | Wallet buy/sell/transfer events | `chainId:walletAddress` |
133
135
 
@@ -145,8 +147,8 @@ interface TokenPriceEvent {
145
147
  tokenAddress: string;
146
148
  blockNumber: number;
147
149
  price: Record<string, PriceInfo> | Map<string, PriceInfo>;
148
- priceInUsd?: number | null;
149
- fdvInUsd?: number | null;
150
+ priceUsd?: number | null;
151
+ fdv?: number | null;
150
152
  symbol?: string | null;
151
153
  updatedAt?: number;
152
154
  }
@@ -179,7 +181,10 @@ interface WalletTransactionEvent {
179
181
  Shared Zod schemas are exported to normalize inputs consistently:
180
182
 
181
183
  ```ts
182
- import { ensureTokenPriceEvent, ensureWalletTransactionEvent } from '@axxel/event-bus';
184
+ import {
185
+ ensureTokenPriceEvent,
186
+ ensureWalletTransactionEvent,
187
+ } from '@axxel/event-bus';
183
188
 
184
189
  const normalizedPrice = ensureTokenPriceEvent(rawPricePayload);
185
190
  const normalizedTx = ensureWalletTransactionEvent(rawTxPayload);
@@ -1,4 +1,5 @@
1
1
  export * from './tokenPriceConsumer';
2
2
  export * from './walletTransactionConsumer';
3
3
  export * from './tradeExecutionConsumer';
4
+ export * from './poolCreatedConsumer';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAC5C,cAAc,0BAA0B,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;AACzC,cAAc,uBAAuB,CAAC"}
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./tokenPriceConsumer"), exports);
18
18
  __exportStar(require("./walletTransactionConsumer"), exports);
19
19
  __exportStar(require("./tradeExecutionConsumer"), exports);
20
+ __exportStar(require("./poolCreatedConsumer"), exports);
@@ -0,0 +1,8 @@
1
+ import type { PoolCreatedEvent } from '../types/PoolCreatedEvent';
2
+ /**
3
+ * Start consuming pool created events.
4
+ * @param groupId - unique consumer group ID
5
+ * @param handler - function to handle each pool created event
6
+ */
7
+ export declare function startPoolCreatedConsumer(groupId: string, handler: (event: PoolCreatedEvent) => Promise<void> | void): Promise<void>;
8
+ //# sourceMappingURL=poolCreatedConsumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolCreatedConsumer.d.ts","sourceRoot":"","sources":["../../src/consumers/poolCreatedConsumer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,iBAuB3D"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startPoolCreatedConsumer = startPoolCreatedConsumer;
4
+ const kafka_1 = require("../config/kafka");
5
+ const topics_1 = require("../topics");
6
+ /**
7
+ * Start consuming pool created events.
8
+ * @param groupId - unique consumer group ID
9
+ * @param handler - function to handle each pool created event
10
+ */
11
+ async function startPoolCreatedConsumer(groupId, handler) {
12
+ const consumer = kafka_1.kafka.consumer({ groupId });
13
+ await consumer.connect();
14
+ await consumer.subscribe({
15
+ topic: topics_1.TOPICS.POOL_CREATED,
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 pool created events (consumer group: ${groupId})`);
27
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './tokenPriceProducer';
2
2
  export * from './walletTransactionProducer';
3
3
  export * from './tradeExecutionProducer';
4
+ export * from './poolCreatedProducer';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAC5C,cAAc,0BAA0B,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;AACzC,cAAc,uBAAuB,CAAC"}
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./tokenPriceProducer"), exports);
18
18
  __exportStar(require("./walletTransactionProducer"), exports);
19
19
  __exportStar(require("./tradeExecutionProducer"), exports);
20
+ __exportStar(require("./poolCreatedProducer"), exports);
@@ -0,0 +1,3 @@
1
+ import type { PoolCreatedEvent } from '../types/PoolCreatedEvent';
2
+ export declare function producePoolCreated(event: PoolCreatedEvent): Promise<void>;
3
+ //# sourceMappingURL=poolCreatedProducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolCreatedProducer.d.ts","sourceRoot":"","sources":["../../src/producers/poolCreatedProducer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,iBAqB/D"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.producePoolCreated = producePoolCreated;
4
+ const kafka_1 = require("../config/kafka");
5
+ const topics_1 = require("../topics");
6
+ async function producePoolCreated(event) {
7
+ const producer = kafka_1.kafka.producer();
8
+ await producer.connect();
9
+ const key = `${event.chainId}:${event.factoryAddress}`;
10
+ await producer.send({
11
+ topic: topics_1.TOPICS.POOL_CREATED,
12
+ messages: [
13
+ {
14
+ key,
15
+ value: JSON.stringify(event),
16
+ },
17
+ ],
18
+ });
19
+ await producer.disconnect();
20
+ console.log(`✅ Pool created event published | chain=${event.chainId} | pool=${event.address}`);
21
+ }
package/dist/topics.d.ts CHANGED
@@ -2,6 +2,7 @@ export declare const TOPICS: {
2
2
  readonly TOKEN_PRICES: "token-prices";
3
3
  readonly WALLET_TRANSACTIONS: "wallet-transactions";
4
4
  readonly TRADE_EXECUTION: "trade-execution";
5
+ readonly POOL_CREATED: "pool-created";
5
6
  };
6
7
  export type Topic = (typeof TOPICS)[keyof typeof TOPICS];
7
8
  //# sourceMappingURL=topics.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../src/topics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/topics.js CHANGED
@@ -5,4 +5,5 @@ exports.TOPICS = {
5
5
  TOKEN_PRICES: 'token-prices',
6
6
  WALLET_TRANSACTIONS: 'wallet-transactions',
7
7
  TRADE_EXECUTION: 'trade-execution',
8
+ POOL_CREATED: 'pool-created',
8
9
  };
@@ -0,0 +1,17 @@
1
+ export type PoolCreatedEvent = {
2
+ address: string;
3
+ createdBlock: number | null;
4
+ chainId: number;
5
+ factoryAddress: string;
6
+ exchangeName: string;
7
+ protocol: string;
8
+ token0Address: string;
9
+ token0Symbol: string;
10
+ token0Decimals: number;
11
+ token1Address: string;
12
+ token1Symbol: string;
13
+ token1Decimals: number;
14
+ fee: string | null;
15
+ tickSpacing: number | null;
16
+ };
17
+ //# sourceMappingURL=PoolCreatedEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PoolCreatedEvent.d.ts","sourceRoot":"","sources":["../../src/types/PoolCreatedEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IAEvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IAEvB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,8 +8,8 @@ export interface TokenPriceEvent {
8
8
  tokenAddress: string;
9
9
  blockNumber: number;
10
10
  price: Record<string, PriceInfo> | Map<string, PriceInfo>;
11
- priceInUsd?: number | null;
12
- fdvInUsd?: number | null;
11
+ priceUsd?: number | null;
12
+ fdv?: number | null;
13
13
  symbol?: string | null;
14
14
  updatedAt?: number;
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
1
+ {"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -8,8 +8,26 @@ export type TradeExecutionEvent = {
8
8
  slippage: string;
9
9
  mev: boolean;
10
10
  totalFee: string;
11
+ /**
12
+ * Execution side (buy | sell)
13
+ * For sniper orders, this represents only buy
14
+ */
11
15
  type: string;
12
- executionPriceUsd: string;
13
- orderType: 'limit' | 'trailing';
16
+ /**
17
+ * USD execution price.
18
+ * Present for limit and trailing orders.
19
+ * Undefined for sniper orders.
20
+ */
21
+ executionPriceUsd?: string;
22
+ /**
23
+ * Pool address used for execution.
24
+ * Present for sniper orders.
25
+ * Undefined for limit and trailing orders.
26
+ */
27
+ poolAddress?: string;
28
+ /**
29
+ * Order category driving execution semantics.
30
+ */
31
+ orderType: 'limit' | 'trailing' | 'sniper';
14
32
  };
15
33
  //# sourceMappingURL=TradeExecutionEvent.d.ts.map
@@ -1 +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"}
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;IAEjB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;CAC5C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './TokenPriceEvent';
2
2
  export * from './WalletTransactionEvent';
3
3
  export * from './TradeExecutionEvent';
4
+ export * from './PoolCreatedEvent';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -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;AACzC,cAAc,uBAAuB,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;AACtC,cAAc,oBAAoB,CAAC"}
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./TokenPriceEvent"), exports);
18
18
  __exportStar(require("./WalletTransactionEvent"), exports);
19
19
  __exportStar(require("./TradeExecutionEvent"), exports);
20
+ __exportStar(require("./PoolCreatedEvent"), exports);
@@ -8,8 +8,8 @@ export declare const tokenPriceEventSchema: z.ZodObject<{
8
8
  exchange: z.ZodString;
9
9
  liquidity: z.ZodNumber;
10
10
  }, z.core.$strip>>>>;
11
- priceInUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
- fdvInUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
11
+ priceUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
+ fdv: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
13
13
  symbol: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
14
  updatedAt: z.ZodOptional<z.ZodNumber>;
15
15
  }, z.core.$strip>;
@@ -42,8 +42,8 @@ exports.tokenPriceEventSchema = zod_1.z.object({
42
42
  tokenAddress: common_1.addressSchema,
43
43
  blockNumber: zod_1.z.number().int().min(0),
44
44
  price: priceRecordSchema,
45
- priceInUsd: zod_1.z.number().nullable().optional(),
46
- fdvInUsd: zod_1.z.number().nullable().optional(),
45
+ priceUsd: zod_1.z.number().nullable().optional(),
46
+ fdv: zod_1.z.number().nullable().optional(),
47
47
  symbol: zod_1.z.string().nullable().optional(),
48
48
  updatedAt: zod_1.z.number().int().min(0).optional(),
49
49
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axxel/event-bus",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Axxel Kafka Event Bus SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,10 @@
20
20
  "prepublishOnly": "npm run build",
21
21
  "test": "echo \"No tests yet\" && exit 0",
22
22
  "publish:public": "npm publish --access public",
23
- "publish:private": "npm publish"
23
+ "publish:private": "npm publish",
24
+ "release:patch": "npm version patch && npm publish --access public",
25
+ "release:minor": "npm version minor && npm publish --access public",
26
+ "release:major": "npm version major && npm publish --access public"
24
27
  },
25
28
  "keywords": [],
26
29
  "author": "",
@@ -36,4 +39,4 @@
36
39
  "tsx": "^4.20.6",
37
40
  "typescript": "^5.9.3"
38
41
  }
39
- }
42
+ }