@axxel/event-bus 1.0.6 → 1.0.7
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
|
-
|
|
58
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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} @ $${
|
|
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
|
-
|
|
149
|
-
|
|
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 {
|
|
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);
|
|
@@ -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
|
-
|
|
12
|
-
|
|
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,
|
|
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,8 @@ export declare const tokenPriceEventSchema: z.ZodObject<{
|
|
|
8
8
|
exchange: z.ZodString;
|
|
9
9
|
liquidity: z.ZodNumber;
|
|
10
10
|
}, z.core.$strip>>>>;
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
});
|