@usherlabs/cex-broker 0.1.16 → 0.1.19

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
@@ -29,7 +29,7 @@ A high-performance gRPC-based cryptocurrency exchange broker service that provid
29
29
  1. **Clone the repository:**
30
30
  ```bash
31
31
  git clone <repository-url>
32
- cd fietCexBroker
32
+ cd cex-broker
33
33
  ```
34
34
 
35
35
  2. **Install dependencies:**
@@ -147,7 +147,14 @@ Options:
147
147
  # Start the server
148
148
  bun run start
149
149
 
150
+ # Start broker server (development)
151
+ bun run start-broker
152
+
153
+ # Start broker server with Verity
154
+ bun run start-broker-server-with-verity
155
+
150
156
  # Build for production
157
+ bun run build
151
158
  bun run build:ts
152
159
 
153
160
  # Run tests
@@ -161,9 +168,11 @@ bun run format
161
168
 
162
169
  # Lint code
163
170
  bun run lint
171
+ bun run lint:fix
164
172
 
165
173
  # Check code (format + lint)
166
174
  bun run check
175
+ bun run check:fix
167
176
  ```
168
177
 
169
178
  ## 📡 API Reference
@@ -194,22 +203,38 @@ message ActionResponse {
194
203
  **Available Actions:**
195
204
  - `NoAction` (0): No operation
196
205
  - `Deposit` (1): Confirm deposit transaction
197
- - `Transfer` (2): Transfer/withdraw funds
206
+ - `Withdraw` (2): Withdraw funds
198
207
  - `CreateOrder` (3): Create a new order
199
208
  - `GetOrderDetails` (4): Get order information
200
209
  - `CancelOrder` (5): Cancel an existing order
201
- - `FetchBalance` (6): Get account balance
210
+ - `FetchBalances` (6): Get account balances. Supports `balanceType`: "free", "used", "total" (defaults to "total").
202
211
  - `FetchDepositAddresses` (7): Get deposit addresses for a token/network
212
+ - `FetchTicker` (8): Get ticker information
213
+ - `FetchCurrency` (9): Get currency metadata (networks, fees, etc.) for a symbol
214
+ - `Call` (10): Generic method invocation on the underlying broker instance. Provide `functionName`, optional `args` array, and optional `params` object.
203
215
 
204
216
  **Example Usage:**
205
217
 
206
218
  ```typescript
207
- // Fetch balance
208
- const balanceRequest = {
209
- action: 6, // FetchBalance
210
- payload: {},
211
- cex: "binance",
212
- symbol: "USDT"
219
+ // Fetch total balances (default)
220
+ const totalBalancesRequest = {
221
+ action: 6, // FetchBalances
222
+ payload: { type: "spot" }, // default is spot if omitted
223
+ cex: "binance"
224
+ };
225
+
226
+ // Fetch free balances
227
+ const freeBalancesRequest = {
228
+ action: 6, // FetchBalances
229
+ payload: { balanceType: "free", type: "spot" },
230
+ cex: "binance"
231
+ };
232
+
233
+ // Fetch used balances
234
+ const usedBalancesRequest = {
235
+ action: 6, // FetchBalances
236
+ payload: { balanceType: "used", type: "spot" },
237
+ cex: "binance"
213
238
  };
214
239
 
215
240
  // Create order
@@ -235,6 +260,14 @@ const depositAddressRequest = {
235
260
  cex: "binance",
236
261
  symbol: "USDT"
237
262
  };
263
+
264
+ // Fetch currency metadata
265
+ const fetchCurrencyRequest = {
266
+ action: 9, // FetchCurrency
267
+ payload: {},
268
+ cex: "binance",
269
+ symbol: "USDT"
270
+ };
238
271
  ```
239
272
 
240
273
  ### Subscribe (Streaming)
@@ -366,26 +399,40 @@ const response = await client.ExecuteAction(request, metadata);
366
399
  ### Project Structure
367
400
 
368
401
  ```
369
- fietCexBroker/
402
+ cex-broker/
370
403
  ├── src/ # Source code
404
+ │ ├── cli.ts # CLI entry point
405
+ │ ├── client.dev.ts # Development client
371
406
  │ ├── commands/ # CLI commands
372
407
  │ │ └── start-broker.ts # Broker startup command
373
408
  │ ├── helpers/ # Utility functions
374
409
  │ │ ├── index.ts # Policy validation helpers
410
+ │ │ ├── index.test.ts # Helper tests
375
411
  │ │ └── logger.ts # Logging configuration
376
412
  │ ├── index.ts # Main broker class
413
+ │ ├── proto/ # Generated protobuf types
414
+ │ │ ├── cex_broker/ # Generated broker types
415
+ │ │ ├── node.proto # Service definition
416
+ │ │ └── node.ts # Type exports
377
417
  │ ├── server.ts # gRPC server implementation
378
- │ ├── cli.ts # CLI entry point
379
418
  │ └── types.ts # TypeScript type definitions
380
419
  ├── proto/ # Protocol buffer definitions
381
- │ ├── node.proto # Service definition
382
- │ └── node.ts # Type exports
420
+ │ ├── cexBroker/ # Legacy generated types
421
+ │ └── node.proto # Service definition
383
422
  ├── policy/ # Policy configuration
384
423
  │ └── policy.json # Trading and withdrawal rules
385
424
  ├── scripts/ # Build scripts
425
+ │ └── patch-protobufjs.js # Protobuf patching script
386
426
  ├── test/ # Test files
387
427
  ├── patches/ # Dependency patches
428
+ ├── examples/ # Example usage
429
+ │ └── kraken-orderbook-demo.ts
388
430
  ├── build.ts # Build configuration
431
+ ├── proto-gen.sh # Proto generation script
432
+ ├── test-setup.ts # Test setup
433
+ ├── tsconfig.json # TypeScript configuration
434
+ ├── biome.json # Code formatting/linting
435
+ ├── bunfig.toml # Bun configuration
389
436
  └── package.json # Dependencies and scripts
390
437
  ```
391
438