@axxel/event-bus 1.0.0 → 1.0.2
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 +55 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,21 +43,33 @@ KAFKA_BROKER="localhost:9092"
|
|
|
43
43
|
import { produceTokenPrice, produceWalletTransaction } from '@axxel/event-bus';
|
|
44
44
|
|
|
45
45
|
await produceTokenPrice({
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
chainId: 1,
|
|
47
|
+
tokenAddress: '0xC02a...',
|
|
48
|
+
blockNumber: 21345678,
|
|
49
|
+
price: {
|
|
50
|
+
USD: { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 },
|
|
51
|
+
},
|
|
52
|
+
marketcap: 1234567890,
|
|
48
53
|
symbol: 'WETH',
|
|
49
|
-
|
|
50
|
-
timestamp: Date.now(),
|
|
54
|
+
updatedAt: Math.floor(Date.now() / 1000),
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
await produceWalletTransaction({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
amount: 10.5,
|
|
58
|
+
chainId: 8453,
|
|
59
|
+
walletAddress: '0xabc...',
|
|
60
|
+
type: 'BUY',
|
|
61
|
+
pool: '0xpool...',
|
|
59
62
|
txHash: '0xdeadbeef...',
|
|
60
|
-
|
|
63
|
+
baseAmount: '10.5',
|
|
64
|
+
quoteAmount: '32500.42',
|
|
65
|
+
baseTokenAddress: '0x123...',
|
|
66
|
+
baseTokenSymbol: 'WETH',
|
|
67
|
+
quoteTokenAddress: '0x456...',
|
|
68
|
+
quoteTokenSymbol: 'USDC',
|
|
69
|
+
blockTimestamp: Math.floor(Date.now() / 1000),
|
|
70
|
+
liquidity: 250000,
|
|
71
|
+
marketcap: 500000000,
|
|
72
|
+
totalSupply: 1000000,
|
|
61
73
|
});
|
|
62
74
|
```
|
|
63
75
|
|
|
@@ -72,12 +84,18 @@ import {
|
|
|
72
84
|
} from '@axxel/event-bus';
|
|
73
85
|
|
|
74
86
|
await startTokenPriceConsumer('limit-orders', async (priceEvent) => {
|
|
75
|
-
|
|
87
|
+
const usdInfo =
|
|
88
|
+
priceEvent.price instanceof Map
|
|
89
|
+
? priceEvent.price.get('USD')
|
|
90
|
+
: priceEvent.price['USD'];
|
|
91
|
+
console.log(
|
|
92
|
+
`📈 ${priceEvent.symbol ?? priceEvent.tokenAddress} @ $${usdInfo?.price ?? 'n/a'} (chain ${priceEvent.chainId})`,
|
|
93
|
+
);
|
|
76
94
|
});
|
|
77
95
|
|
|
78
96
|
await startWalletTransactionConsumer('wallet-tracker', async (txEvent) => {
|
|
79
97
|
console.log(
|
|
80
|
-
`💸 ${txEvent.
|
|
98
|
+
`💸 ${txEvent.walletAddress} ${txEvent.type} ${txEvent.baseAmount} ${txEvent.baseTokenSymbol}/${txEvent.quoteTokenSymbol}`,
|
|
81
99
|
);
|
|
82
100
|
});
|
|
83
101
|
```
|
|
@@ -91,8 +109,8 @@ Multiple instances with the same group ID will automatically load-balance partit
|
|
|
91
109
|
|
|
92
110
|
| Topic | Description | Partition Key |
|
|
93
111
|
| --------------------- | ------------------------------------------ | -------------- |
|
|
94
|
-
| `token-prices` | Live token price updates across all chains | `
|
|
95
|
-
| `wallet-transactions` | Wallet buy/sell/transfer events | `
|
|
112
|
+
| `token-prices` | Live token price updates across all chains | `chainId:tokenAddress` |
|
|
113
|
+
| `wallet-transactions` | Wallet buy/sell/transfer events | `chainId:walletAddress` |
|
|
96
114
|
|
|
97
115
|
---
|
|
98
116
|
|
|
@@ -101,12 +119,16 @@ Multiple instances with the same group ID will automatically load-balance partit
|
|
|
101
119
|
### TokenPriceEvent
|
|
102
120
|
|
|
103
121
|
```ts
|
|
122
|
+
type PriceInfo = { price: number; exchange: string; liquidity: number };
|
|
123
|
+
|
|
104
124
|
interface TokenPriceEvent {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
price:
|
|
109
|
-
|
|
125
|
+
chainId: number;
|
|
126
|
+
tokenAddress: string;
|
|
127
|
+
blockNumber: number;
|
|
128
|
+
price: Record<string, PriceInfo> | Map<string, PriceInfo>;
|
|
129
|
+
marketcap?: number | null;
|
|
130
|
+
symbol?: string | null;
|
|
131
|
+
updatedAt?: number;
|
|
110
132
|
}
|
|
111
133
|
```
|
|
112
134
|
|
|
@@ -114,13 +136,21 @@ interface TokenPriceEvent {
|
|
|
114
136
|
|
|
115
137
|
```ts
|
|
116
138
|
interface WalletTransactionEvent {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
amount: number;
|
|
139
|
+
chainId: number;
|
|
140
|
+
walletAddress: string;
|
|
141
|
+
type: string;
|
|
142
|
+
pool?: string | null;
|
|
122
143
|
txHash: string;
|
|
123
|
-
|
|
144
|
+
baseAmount: string;
|
|
145
|
+
quoteAmount: string;
|
|
146
|
+
baseTokenAddress: string;
|
|
147
|
+
baseTokenSymbol: string;
|
|
148
|
+
quoteTokenAddress: string;
|
|
149
|
+
quoteTokenSymbol: string;
|
|
150
|
+
blockTimestamp: number;
|
|
151
|
+
liquidity?: number | null;
|
|
152
|
+
marketcap?: number | null;
|
|
153
|
+
totalSupply?: number | null;
|
|
124
154
|
}
|
|
125
155
|
```
|
|
126
156
|
|