@ultrade/ultrade-js-sdk 2.0.3 → 2.0.4

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
@@ -1,7 +1,26 @@
1
- # @ultrade/ultrade-js-sdk
2
1
 
3
2
  JavaScript/TypeScript SDK for Ultrade platform integration.
4
3
 
4
+ ## Overview
5
+
6
+ The `@ultrade/ultrade-js-sdk` package provides a JavaScript/TypeScript interface for interacting with ULTRADE's V2 platform, the Native Exchange (NEX) with Bridgeless Crosschain Orderbook technology. It offers a simple interface for creating and managing orders, as well as for interacting with the Ultrade API and WebSocket streams.
7
+
8
+ ### Key Features
9
+
10
+ - **Deposits**: Always credited to the logged in account
11
+ - **Order Creation**: Orders are created via this SDK by cryptographically signing order messages and sending them to the API
12
+ - **Gas-Free Trading**: This process does not involve on-chain transactions and does not incur any gas costs
13
+ - **Trading Keys**: Can be associated with a specific login account and its balances. Trading keys are used for managing orders but cannot withdraw funds. This is useful for working with market maker (MM) clients on their own accounts
14
+
15
+ ### Important Notes
16
+
17
+ **Atomic Units**: Token amounts and prices stated in Atomic Units represent the smallest indivisible units of the token based on its number of decimals, in an unsigned integer format.
18
+
19
+ - Example: 1 ETH (Ethereum, 18 decimals) = `1000000000000000000` (1 with 18 zeros)
20
+ - Example: 1 USDC (Algorand, 6 decimals) = `1000000` (1 with 6 zeros)
21
+
22
+ **Price Denomination**: The price is denominated based on the Price (Quote) token, while amounts of a base token are denominated according to that base token's decimals.
23
+
5
24
  **Repository:** [https://github.com/ultrade-org/ultrade-js-sdk](https://github.com/ultrade-org/ultrade-js-sdk)
6
25
 
7
26
  ## Package Info
@@ -26,6 +45,2367 @@ yarn add @ultrade/ultrade-js-sdk
26
45
  pnpm add @ultrade/ultrade-js-sdk
27
46
  ```
28
47
 
48
+ ## Quick Start
49
+
50
+ ### Creating a Client
51
+
52
+ ```typescript
53
+ import { Client } from '@ultrade/ultrade-js-sdk';
54
+ import algosdk from 'algosdk';
55
+
56
+ // Create Algorand SDK client
57
+ const algodClient = new algosdk.Algodv2(
58
+ '', // token
59
+ 'https://testnet-api.algonode.cloud', // server
60
+ '' // port
61
+ );
62
+
63
+ // Initialize Ultrade client
64
+ const client = new Client({
65
+ network: 'testnet', // or 'mainnet'
66
+ apiUrl: 'https://api.testnet.ultrade.org',
67
+ algoSdkClient: algodClient,
68
+ websocketUrl: 'wss://ws.testnet.ultrade.org',
69
+ });
70
+ ```
71
+
72
+ ### Client Options
73
+
74
+ | Option | Type | Required | Description | Default |
75
+ |--------|------|----------|-------------|---------|
76
+ | `network` | `'mainnet' \| 'testnet'` | Yes | Algorand network | - |
77
+ | `algoSdkClient` | `Algodv2` | Yes | Algorand SDK client instance | - |
78
+ | `websocketUrl` | `string` | Yes | WebSocket server URL | - |
79
+ | `companyId` | `number` | No | Company ID | 1 |
80
+ | `apiUrl` | `string` | No | Override API URL | Auto-detected |
81
+
82
+ ---
83
+
84
+ ## Table of Contents
85
+
86
+ 1. [Authentication & Wallet](#authentication--wallet)
87
+ 2. [Market Data](#market-data)
88
+ 3. [Trading](#trading)
89
+ 4. [Account & Balances](#account--balances)
90
+ 5. [Wallet Operations](#wallet-operations)
91
+ 6. [Whitelist & Withdrawal Wallets](#whitelist--withdrawal-wallets)
92
+ 7. [KYC](#kyc)
93
+ 8. [WebSocket](#websocket)
94
+ 9. [System](#system)
95
+ 10. [Notifications](#notifications)
96
+ 11. [Affiliates](#affiliates)
97
+ 12. [Social](#social)
98
+ 13. [Social Integrations](#social-integrations)
99
+
100
+ ---
101
+
102
+ ## Authentication & Wallet
103
+
104
+ ### login
105
+
106
+ Authenticate a user with their wallet.
107
+
108
+ **Parameters:**
109
+
110
+ | Name | Type | Required | Description |
111
+ |------|------|----------|-------------|
112
+ | `data` | `ILoginData` | Yes | Login data object |
113
+
114
+ **ILoginData interface:**
115
+
116
+ | Property | Type | Required | Description |
117
+ |----------|------|----------|-------------|
118
+ | `address` | `string` | Yes | Wallet address |
119
+ | `provider` | `PROVIDERS` | Yes | Wallet provider (PERA, METAMASK, etc.) |
120
+ | `chain` | `string` | No | Blockchain chain |
121
+ | `referralToken` | `string` | No | Referral token |
122
+ | `loginMessage` | `string` | No | Custom login message |
123
+
124
+ **Returns:** `Promise<string>` - Authentication token
125
+
126
+ **Example:**
127
+
128
+ ```typescript
129
+ import { PROVIDERS } from '@ultrade/ultrade-js-sdk';
130
+ import algosdk from 'algosdk';
131
+ import { encodeBase64 } from '@ultrade/shared/browser/helpers';
132
+
133
+ // Example signer implementation
134
+ const signMessage = async (data: string, encoding?: BufferEncoding): Promise<string> => {
135
+ // For Pera Wallet
136
+ const message = typeof data === 'string'
137
+ ? new Uint8Array(Buffer.from(data, encoding))
138
+ : data;
139
+
140
+ const signedData = await peraWallet.signData([{
141
+ data: message,
142
+ message: 'Please sign this message'
143
+ }], walletAddress);
144
+
145
+ return encodeBase64(signedData[0]);
146
+ };
147
+
148
+ // For trading key signing
149
+ const signMessageByToken = async (data: string, encoding?: BufferEncoding): Promise<string> => {
150
+ const message = typeof data === 'string' ? data : JSON.stringify(data);
151
+ const bytes = new Uint8Array(Buffer.from(message, encoding));
152
+
153
+ // Get trading key from secure storage
154
+ const keyData = secureStorage.getKeyFromLocalStorage();
155
+ const { sk } = algosdk.mnemonicToSecretKey(keyData.mnemonic);
156
+
157
+ const signature = algosdk.signBytes(bytes, sk);
158
+ return encodeBase64(signature);
159
+ };
160
+
161
+ // Set signer before login
162
+ client.setSigner({
163
+ signMessage,
164
+ signMessageByToken
165
+ });
166
+
167
+ // Login with wallet
168
+ const token = await client.login({
169
+ address: 'NWQVUPGM7TBQO5FGRWQ45VD45JLFJFRKYVVNGVI6NZA4CVWZH7SDNWCHQU',
170
+ provider: PROVIDERS.PERA,
171
+ chain: 'algorand',
172
+ referralToken: 'REF_ABC123XYZ'
173
+ });
174
+
175
+ console.log('Logged in with token:', token);
176
+
177
+ // Save wallet data
178
+ client.mainWallet = {
179
+ address: 'NWQVUPGM7TBQO5FGRWQ45VD45JLFJFRKYVVNGVI6NZA4CVWZH7SDNWCHQU',
180
+ provider: PROVIDERS.PERA,
181
+ token,
182
+ chain: 'algorand'
183
+ };
184
+ ```
185
+
186
+ ### addTradingKey
187
+
188
+ Create a new trading key for automated trading.
189
+
190
+ **Parameters:**
191
+
192
+ | Name | Type | Required | Description |
193
+ |------|------|----------|-------------|
194
+ | `data` | `ITradingKeyData` | Yes | Trading key data object |
195
+
196
+ **ITradingKeyData interface:**
197
+
198
+ | Property | Type | Required | Description |
199
+ |----------|------|----------|-------------|
200
+ | `tkAddress` | `string` | Yes | Trading key address |
201
+ | `device` | `string` | Yes | Device identifier |
202
+ | `type` | `TradingKeyType` | Yes | Key type (User or Bot) |
203
+ | `expiredDate` | `number` | No | Expiration timestamp (ms) |
204
+ | `loginAddress` | `string` | Yes | Login wallet address |
205
+ | `loginChainId` | `string \| number` | Yes | Login chain ID |
206
+
207
+ **Returns:** `Promise<TradingKeyView>`
208
+
209
+ **Example:**
210
+
211
+ ```typescript
212
+ import { TradingKeyType } from '@ultrade/ultrade-js-sdk';
213
+ import algosdk from 'algosdk';
214
+
215
+ // Generate new trading key account
216
+ const generatedAccount = algosdk.generateAccount();
217
+ const mnemonic = algosdk.secretKeyToMnemonic(generatedAccount.sk);
218
+
219
+ // Expiration: 30 days from now (in milliseconds)
220
+ const expirationTime = Date.now() + 30 * 24 * 60 * 60 * 1000;
221
+
222
+ // Get device info
223
+ const getDeviceInfo = () => {
224
+ const ua = navigator.userAgent;
225
+ if (/mobile/i.test(ua)) return 'mobile';
226
+ if (/tablet/i.test(ua)) return 'tablet';
227
+ return 'desktop';
228
+ };
229
+
230
+ // Create trading key data
231
+ const tkData = {
232
+ tkAddress: generatedAccount.addr,
233
+ expiredDate: expirationTime,
234
+ loginAddress: client.mainWallet.address,
235
+ loginChainId: 'algorand',
236
+ device: getDeviceInfo(),
237
+ type: TradingKeyType.User
238
+ };
239
+
240
+ // Add trading key to account
241
+ const tradingKey = await client.addTradingKey(tkData);
242
+
243
+ console.log('Trading key created:', {
244
+ address: tradingKey.address,
245
+ type: tradingKey.type,
246
+ expiresAt: new Date(tradingKey.expiredAt)
247
+ });
248
+
249
+ // Save mnemonic securely for signing
250
+ secureStorage.setKeyToLocalStorage({
251
+ address: generatedAccount.addr,
252
+ mnemonic,
253
+ expiredAt: expirationTime
254
+ });
255
+
256
+ // Set trading key to client
257
+ client.mainWallet.tradingKey = generatedAccount.addr;
258
+ ```
259
+
260
+ ### revokeTradingKey
261
+
262
+ Revoke an existing trading key.
263
+
264
+ **Parameters:**
265
+
266
+ | Name | Type | Required | Description |
267
+ |------|------|----------|-------------|
268
+ | `data` | `ITradingKeyData` | Yes | Trading key data object |
269
+
270
+ **ITradingKeyData interface:**
271
+
272
+ | Property | Type | Required | Description |
273
+ |----------|------|----------|-------------|
274
+ | `tkAddress` | `string` | Yes | Trading key address to revoke |
275
+ | `device` | `string` | Yes | Device identifier |
276
+ | `type` | `TradingKeyType` | Yes | Key type |
277
+ | `loginAddress` | `string` | Yes | Login wallet address |
278
+ | `loginChainId` | `string \| number` | Yes | Login chain ID |
279
+
280
+ **Returns:** `Promise<IRevokeTradingKeyResponse>`
281
+
282
+ **Example:**
283
+
284
+ ```typescript
285
+ await client.revokeTradingKey({
286
+ tkAddress: 'TK_ADDRESS_HERE',
287
+ device: 'web-browser',
288
+ type: TradingKeyType.User,
289
+ loginAddress: client.mainWallet?.address || '',
290
+ loginChainId: 'algorand'
291
+ });
292
+
293
+ console.log('Trading key revoked');
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Market Data
299
+
300
+ ### getPairList
301
+
302
+ Retrieve list of all trading pairs.
303
+
304
+ **Parameters:**
305
+
306
+ | Name | Type | Required | Description |
307
+ |------|------|----------|-------------|
308
+ | `companyId` | `number` | No | Filter by company ID |
309
+
310
+ **Returns:** `Promise<IPairDto[]>`
311
+
312
+ **Example:**
313
+
314
+ ```typescript
315
+ const pairs = await client.getPairList();
316
+
317
+ pairs.forEach(pair => {
318
+ console.log(`${pair.pair_name}: ${pair.base_currency}/${pair.price_currency}`);
319
+ console.log(`Pair ID: ${pair.id}, Active: ${pair.is_active}`);
320
+ });
321
+ ```
322
+
323
+ ### getPair
324
+
325
+ Get detailed information about a specific trading pair.
326
+
327
+ **Parameters:**
328
+
329
+ | Name | Type | Required | Description |
330
+ |------|------|----------|-------------|
331
+ | `symbol` | `string \| number` | Yes | Trading pair symbol or ID |
332
+
333
+ **Returns:** `Promise<IPairDto>`
334
+
335
+ **IPairDto interface:**
336
+
337
+ | Property | Type | Description |
338
+ |----------|------|-------------|
339
+ | `id` | `number` | Pair ID |
340
+ | `pairId` | `number` | Pair ID (alternative) |
341
+ | `pair_key` | `string` | Pair key |
342
+ | `pair_name` | `string` | Pair name |
343
+ | `base_currency` | `string` | Base currency symbol |
344
+ | `base_decimal` | `number` | Base token decimals |
345
+ | `base_id` | `string` | Base token ID |
346
+ | `base_chain_id` | `number` | Base chain ID |
347
+ | `price_currency` | `string` | Price currency symbol |
348
+ | `price_decimal` | `number` | Price token decimals |
349
+ | `price_id` | `string` | Price token ID |
350
+ | `price_chain_id` | `number` | Price chain ID |
351
+ | `min_order_size` | `string` | Minimum order size |
352
+ | `min_price_increment` | `string` | Minimum price increment |
353
+ | `min_size_increment` | `string` | Minimum size increment |
354
+ | `is_active` | `boolean` | Whether pair is active |
355
+ | `current_price` | `string` | Current price (optional) |
356
+ | `volume_24` | `string` | 24h volume (optional) |
357
+ | `change_24` | `string` | 24h change (optional) |
358
+
359
+ **Example:**
360
+
361
+ ```typescript
362
+ const pair = await client.getPair('ALGO/USDC');
363
+
364
+ console.log('Pair info:', {
365
+ id: pair.id,
366
+ pairId: pair.pairId,
367
+ pairName: pair.pair_name,
368
+ baseCurrency: pair.base_currency,
369
+ priceCurrency: pair.price_currency,
370
+ minOrderSize: pair.min_order_size,
371
+ minPriceIncrement: pair.min_price_increment,
372
+ isActive: pair.is_active,
373
+ currentPrice: pair.current_price
374
+ });
375
+ ```
376
+
377
+ ### getPrice
378
+
379
+ Get current market price for a trading pair.
380
+
381
+ **Parameters:**
382
+
383
+ | Name | Type | Required | Description |
384
+ |------|------|----------|-------------|
385
+ | `symbol` | `string` | Yes | Trading pair symbol |
386
+
387
+ **Returns:** `Promise<IGetPrice>`
388
+
389
+ **IGetPrice interface:**
390
+
391
+ | Property | Type | Description |
392
+ |----------|------|-------------|
393
+ | `ask` | `number` | Ask price (sell orders) |
394
+ | `bid` | `number` | Bid price (buy orders) |
395
+ | `last` | `number` | Last trade price |
396
+
397
+ **Example:**
398
+
399
+ ```typescript
400
+ const price = await client.getPrice('ALGO/USDC');
401
+
402
+ console.log('Ask price:', price.ask);
403
+ console.log('Bid price:', price.bid);
404
+ console.log('Last price:', price.last);
405
+ ```
406
+
407
+ ### getDepth
408
+
409
+ Get order book depth for a trading pair.
410
+
411
+ **Parameters:**
412
+
413
+ | Name | Type | Required | Description |
414
+ |------|------|----------|-------------|
415
+ | `symbol` | `string` | Yes | Trading pair symbol |
416
+ | `depth` | `number` | Yes | Number of price levels (max 20) |
417
+
418
+ **Returns:** `Promise<IGetDepth>`
419
+
420
+ **IGetDepth interface:**
421
+
422
+ | Property | Type | Description |
423
+ |----------|------|-------------|
424
+ | `buy` | `string[][]` | Buy orders (bids) array |
425
+ | `sell` | `string[][]` | Sell orders (asks) array |
426
+ | `pair` | `string` | Trading pair symbol |
427
+ | `ts` | `number` | Timestamp |
428
+ | `U` | `number` | Update ID (upper) |
429
+ | `u` | `number` | Update ID (lower) |
430
+
431
+ **Example:**
432
+
433
+ ```typescript
434
+ const depth = await client.getDepth('ALGO/USDC', 10);
435
+
436
+ console.log('Bids (buy orders):', depth.buy);
437
+ console.log('Asks (sell orders):', depth.sell);
438
+ console.log('Pair:', depth.pair);
439
+ console.log('Last update ID:', depth.U);
440
+ ```
441
+
442
+ ### getSymbols
443
+
444
+ Get list of trading pairs matching a pattern.
445
+
446
+ **Parameters:**
447
+
448
+ | Name | Type | Required | Description |
449
+ |------|------|----------|-------------|
450
+ | `mask` | `string` | No | Search mask (e.g., 'ALGO*') |
451
+
452
+ **Returns:** `Promise<IGetSymbols>`
453
+
454
+ **Note:** Returns an array of `IGetSymbolsItem` objects.
455
+
456
+ **IGetSymbolsItem interface:**
457
+
458
+ | Property | Type | Description |
459
+ |----------|------|-------------|
460
+ | `pairKey` | `string` | Trading pair key |
461
+
462
+ **Example:**
463
+
464
+ ```typescript
465
+ const symbols = await client.getSymbols('ALGO*');
466
+
467
+ symbols.forEach(symbol => {
468
+ console.log('Pair:', symbol.pairKey);
469
+ });
470
+ ```
471
+
472
+ ### getLastTrades
473
+
474
+ Get recent trades for a trading pair.
475
+
476
+ **Parameters:**
477
+
478
+ | Name | Type | Required | Description |
479
+ |------|------|----------|-------------|
480
+ | `symbol` | `string` | Yes | Trading pair symbol |
481
+
482
+ **Returns:** `Promise<IGetLastTrades>`
483
+
484
+ **Note:** Returns a single `IGetLastTrades` object, not an array.
485
+
486
+ **IGetLastTrades interface:**
487
+
488
+ | Property | Type | Description |
489
+ |----------|------|-------------|
490
+ | `tradeId` | `number` | Trade ID |
491
+ | `amount` | `string` | Trade amount |
492
+ | `createdAt` | `number` | Creation timestamp |
493
+ | `price` | `string` | Trade price |
494
+ | `isBuyerMaker` | `boolean` | Whether buyer is maker |
495
+
496
+ **Example:**
497
+
498
+ ```typescript
499
+ const trade = await client.getLastTrades('ALGO/USDC');
500
+
501
+ console.log(`Trade ${trade.tradeId}: ${trade.amount} @ ${trade.price}`);
502
+ console.log(`Buyer is maker: ${trade.isBuyerMaker}`);
503
+ console.log(`Created: ${new Date(trade.createdAt)}`);
504
+ ```
505
+
506
+ ### getHistory
507
+
508
+ Get historical candlestick data.
509
+
510
+ **Parameters:**
511
+
512
+ | Name | Type | Required | Description |
513
+ |------|------|----------|-------------|
514
+ | `symbol` | `string` | Yes | Trading pair symbol |
515
+ | `interval` | `string` | Yes | Candle interval ('1m', '5m', '1h', '1d', etc.) |
516
+ | `startTime` | `number` | No | Start timestamp (ms) |
517
+ | `endTime` | `number` | No | End timestamp (ms) |
518
+ | `limit` | `number` | No | Number of candles (default: 500) |
519
+ | `page` | `number` | No | Page number (default: 1) |
520
+
521
+ **Returns:** `Promise<IGetHistoryResponse>`
522
+
523
+ **IGetHistoryResponse interface:**
524
+
525
+ | Property | Type | Description |
526
+ |----------|------|-------------|
527
+ | `t` | `number[]` | Timestamps array |
528
+ | `o` | `number[]` | Open prices array |
529
+ | `c` | `number[]` | Close prices array |
530
+ | `l` | `number[]` | Low prices array |
531
+ | `h` | `number[]` | High prices array |
532
+ | `v` | `number[]` | Volumes array |
533
+ | `q` | `number[]` | Quote volumes array |
534
+ | `s` | `string` | Symbol |
535
+ | `b` | `number` | Base value |
536
+
537
+ **Example:**
538
+
539
+ ```typescript
540
+ const history = await client.getHistory(
541
+ 'ALGO/USDC',
542
+ '1h',
543
+ Date.now() - 24 * 60 * 60 * 1000, // 24 hours ago
544
+ Date.now(),
545
+ 100,
546
+ 1
547
+ );
548
+
549
+ // Access candle data by index
550
+ for (let i = 0; i < history.t.length; i++) {
551
+ console.log(`[${new Date(history.t[i])}] O:${history.o[i]} H:${history.h[i]} L:${history.l[i]} C:${history.c[i]} V:${history.v[i]}`);
552
+ }
553
+ ```
554
+
555
+ ---
556
+
557
+ ## Trading
558
+
559
+ ### createOrder
560
+
561
+ Place a new order.
562
+
563
+ **Parameters:**
564
+
565
+ | Name | Type | Required | Description |
566
+ |------|------|----------|-------------|
567
+ | `order` | `CreateOrderArgs` | Yes | Order creation data object |
568
+
569
+ **CreateOrderArgs interface:**
570
+
571
+ | Property | Type | Required | Description |
572
+ |----------|------|----------|-------------|
573
+ | `pairId` | `number` | Yes | Trading pair ID |
574
+ | `companyId` | `number` | Yes | Company ID |
575
+ | `orderSide` | `'S' \| 'B'` | Yes | Order side (S=SELL, B=BUY) |
576
+ | `orderType` | `'L' \| 'I' \| 'P' \| 'M'` | Yes | Order type |
577
+ | `amount` | `string` | Yes | Order quantity |
578
+ | `price` | `string` | Yes | Order price |
579
+ | `decimalPrice` | `number` | Yes | Price decimal places |
580
+ | `address` | `string` | Yes | Trading key address |
581
+ | `chainId` | `number` | Yes | Chain ID |
582
+ | `baseTokenAddress` | `string` | Yes | Base token address |
583
+ | `baseTokenChainId` | `number` | Yes | Base token chain ID |
584
+ | `baseChain` | `string` | Yes | Base chain name |
585
+ | `baseCurrency` | `string` | Yes | Base currency symbol |
586
+ | `baseDecimal` | `number` | Yes | Base token decimals |
587
+ | `priceTokenAddress` | `string` | Yes | Price token address |
588
+ | `priceTokenChainId` | `number` | Yes | Price token chain ID |
589
+ | `priceChain` | `string` | Yes | Price chain name |
590
+ | `priceCurrency` | `string` | Yes | Price currency symbol |
591
+ | `priceDecimal` | `number` | Yes | Price token decimals |
592
+
593
+ **Returns:** `Promise<IOrderDto>`
594
+
595
+ **Example:**
596
+
597
+ ```typescript
598
+ const order = await client.createOrder({
599
+ pairId: 1,
600
+ companyId: 1,
601
+ orderSide: 'B',
602
+ orderType: 'L',
603
+ amount: '100',
604
+ price: '1.25',
605
+ decimalPrice: 2,
606
+ address: client.mainWallet?.tradingKey || '',
607
+ chainId: 1,
608
+ baseTokenAddress: 'ALGO_ADDRESS',
609
+ baseTokenChainId: 1,
610
+ baseChain: 'algorand',
611
+ baseCurrency: 'ALGO',
612
+ baseDecimal: 6,
613
+ priceTokenAddress: 'USDC_ADDRESS',
614
+ priceTokenChainId: 1,
615
+ priceChain: 'algorand',
616
+ priceCurrency: 'USDC',
617
+ priceDecimal: 6
618
+ });
619
+
620
+ console.log('Order created:', order.id);
621
+ console.log('Status:', order.status);
622
+ ```
623
+
624
+ ### cancelOrder
625
+
626
+ Cancel an existing order.
627
+
628
+ **Parameters:**
629
+
630
+ | Name | Type | Required | Description |
631
+ |------|------|----------|-------------|
632
+ | `order` | `CancelOrderArgs` | Yes | Order cancellation data object |
633
+
634
+ **CancelOrderArgs interface:**
635
+
636
+ | Property | Type | Required | Description |
637
+ |----------|------|----------|-------------|
638
+ | `orderId` | `number` | Yes | Order ID to cancel |
639
+ | `orderSide` | `'S' \| 'B'` | Yes | Order side (S=SELL, B=BUY) |
640
+ | `orderType` | `'L' \| 'I' \| 'P' \| 'M'` | Yes | Order type |
641
+ | `amount` | `string` | Yes | Order amount |
642
+ | `price` | `string` | Yes | Order price |
643
+ | `baseTokenAddress` | `string` | Yes | Base token address |
644
+ | `baseChain` | `string` | Yes | Base chain name |
645
+ | `baseCurrency` | `string` | Yes | Base currency symbol |
646
+ | `baseDecimal` | `number` | Yes | Base token decimals |
647
+ | `priceTokenAddress` | `string` | Yes | Price token address |
648
+ | `priceChain` | `string` | Yes | Price chain name |
649
+ | `priceCurrency` | `string` | Yes | Price currency symbol |
650
+ | `priceDecimal` | `number` | Yes | Price token decimals |
651
+
652
+ **Returns:** `Promise<ICancelOrderResponse>`
653
+
654
+ **ICancelOrderResponse interface:**
655
+
656
+ | Property | Type | Description |
657
+ |----------|------|-------------|
658
+ | `orderId` | `number` | Order ID |
659
+ | `isCancelled` | `boolean` | Whether order was cancelled |
660
+ | `amount` | `string` | Order amount (optional) |
661
+ | `filledAmount` | `string` | Filled amount (optional) |
662
+ | `filledTotal` | `string` | Filled total (optional) |
663
+ | `averageExecutedPrice` | `string` | Average executed price (optional) |
664
+
665
+ **Example:**
666
+
667
+ ```typescript
668
+ const result = await client.cancelOrder({
669
+ orderId: 12345,
670
+ orderSide: 'B',
671
+ orderType: 'L',
672
+ amount: '100',
673
+ price: '1.25',
674
+ baseTokenAddress: 'ALGO_ADDRESS',
675
+ baseChain: 'algorand',
676
+ baseCurrency: 'ALGO',
677
+ baseDecimal: 6,
678
+ priceTokenAddress: 'USDC_ADDRESS',
679
+ priceChain: 'algorand',
680
+ priceCurrency: 'USDC',
681
+ priceDecimal: 6
682
+ });
683
+
684
+ console.log('Order cancelled:', result.isCancelled);
685
+ console.log('Order ID:', result.orderId);
686
+ if (result.filledAmount) {
687
+ console.log('Filled amount:', result.filledAmount);
688
+ }
689
+ ```
690
+
691
+ ### cancelMultipleOrders
692
+
693
+ Cancel multiple orders at once.
694
+
695
+ **Parameters:**
696
+
697
+ | Name | Type | Required | Description |
698
+ |------|------|----------|-------------|
699
+ | `orderIds` | `number[]` | No* | Array of order IDs |
700
+ | `pairId` | `number` | No* | Cancel all orders for pair |
701
+
702
+ *At least one parameter is required
703
+
704
+ **Returns:** `Promise<ICancelMultipleOrdersResponse>`
705
+
706
+ **Note:** Returns an array of `ICancelMultipleOrdersResponseItem` objects.
707
+
708
+ **ICancelMultipleOrdersResponseItem interface:**
709
+
710
+ | Property | Type | Description |
711
+ |----------|------|-------------|
712
+ | `orderId` | `number` | Order ID |
713
+ | `pairId` | `number` | Pair ID |
714
+ | `isCancelled` | `boolean` | Whether order was cancelled |
715
+ | `reason` | `string` | Cancellation reason (optional) |
716
+ | `amount` | `string` | Order amount (optional) |
717
+ | `filledAmount` | `string` | Filled amount (optional) |
718
+ | `filledTotal` | `string` | Filled total (optional) |
719
+
720
+ **Example:**
721
+
722
+ ```typescript
723
+ // Cancel specific orders
724
+ const results = await client.cancelMultipleOrders({
725
+ orderIds: [123, 456, 789]
726
+ });
727
+
728
+ results.forEach(result => {
729
+ console.log(`Order ${result.orderId}: ${result.isCancelled ? 'Cancelled' : 'Failed'}`);
730
+ if (result.reason) {
731
+ console.log(`Reason: ${result.reason}`);
732
+ }
733
+ });
734
+
735
+ // Cancel all orders for a pair
736
+ const pairResults = await client.cancelMultipleOrders({
737
+ pairId: 1
738
+ });
739
+ ```
740
+
741
+ ### getOrders
742
+
743
+ Get user's orders with filters.
744
+
745
+ **Parameters:**
746
+
747
+ | Name | Type | Required | Description |
748
+ |------|------|----------|-------------|
749
+ | `symbol` | `string` | No | Filter by trading pair |
750
+ | `status` | `number` | No | Filter by status (1=Open, 2=Closed) |
751
+ | `limit` | `number` | No | Max results (default: 50) |
752
+ | `endTime` | `number` | No | End timestamp (ms) |
753
+ | `startTime` | `number` | No | Start timestamp (ms) |
754
+
755
+ **Returns:** `Promise<IOrderDto[]>`
756
+
757
+ **Example:**
758
+
759
+ ```typescript
760
+ // Get all open orders
761
+ const openOrders = await client.getOrders(undefined, 1);
762
+
763
+ // Get ALGO/USDC orders
764
+ const algoOrders = await client.getOrders('ALGO/USDC');
765
+
766
+ // Get last 100 orders
767
+ const recentOrders = await client.getOrders(undefined, undefined, 100);
768
+
769
+ // Get orders with time range
770
+ const timeRangeOrders = await client.getOrders(
771
+ 'ALGO/USDC',
772
+ 1,
773
+ 50,
774
+ Date.now(),
775
+ Date.now() - 24 * 60 * 60 * 1000
776
+ );
777
+ ```
778
+
779
+ ### getOrderById
780
+
781
+ Get detailed information about a specific order.
782
+
783
+ **Parameters:**
784
+
785
+ | Name | Type | Required | Description |
786
+ |------|------|----------|-------------|
787
+ | `orderId` | `number` | Yes | Order ID |
788
+
789
+ **Returns:** `Promise<Order>`
790
+
791
+ **Order interface:**
792
+
793
+ Extends `IOrderDto` with additional properties:
794
+ - `executed`: `boolean` - Whether order is executed
795
+ - `updateStatus`: `OrderUpdateStaus` - Update status (optional)
796
+ - `base_currency`: `string` - Base currency symbol
797
+ - `base_decimal`: `number` - Base token decimals
798
+ - `price_currency`: `string` - Price currency symbol
799
+ - `price_decimal`: `number` - Price token decimals
800
+ - `min_size_increment`: `string` - Minimum size increment
801
+ - `min_price_increment`: `string` - Minimum price increment
802
+ - `price_id`: `number` - Price token ID
803
+
804
+ **IOrderDto properties:**
805
+
806
+ | Property | Type | Description |
807
+ |----------|------|-------------|
808
+ | `id` | `number` | Order ID |
809
+ | `pairId` | `number` | Pair ID |
810
+ | `pair` | `string` | Pair symbol |
811
+ | `status` | `OrderStatus` | Order status |
812
+ | `side` | `0 \| 1` | Order side (0=Buy, 1=Sell) |
813
+ | `type` | `OrderTypeEnum` | Order type |
814
+ | `price` | `string` | Order price |
815
+ | `amount` | `string` | Order amount |
816
+ | `filledAmount` | `string` | Filled amount |
817
+ | `total` | `string` | Total value |
818
+ | `filledTotal` | `string` | Filled total |
819
+ | `avgPrice` | `string` | Average execution price |
820
+ | `createdAt` | `number` | Creation timestamp |
821
+ | `updatedAt` | `number` | Update timestamp (optional) |
822
+ | `completedAt` | `number` | Completion timestamp (optional) |
823
+ | `trades` | `ITradeDto[]` | Trade history (optional) |
824
+
825
+ **Example:**
826
+
827
+ ```typescript
828
+ const order = await client.getOrderById(12345);
829
+
830
+ console.log('Order details:', {
831
+ id: order.id,
832
+ pair: order.pair,
833
+ side: order.side === 0 ? 'BUY' : 'SELL',
834
+ price: order.price,
835
+ amount: order.amount,
836
+ filledAmount: order.filledAmount,
837
+ status: order.status,
838
+ executed: order.executed,
839
+ baseCurrency: order.base_currency,
840
+ priceCurrency: order.price_currency
841
+ });
842
+ ```
843
+
844
+ ---
845
+
846
+ ## Account & Balances
847
+
848
+ ### getBalances
849
+
850
+ Get user's balances for all assets.
851
+
852
+ **Returns:** `Promise<CodexBalanceDto[]>`
853
+
854
+ **CodexBalanceDto interface:**
855
+
856
+ | Property | Type | Description |
857
+ |----------|------|-------------|
858
+ | `hash` | `string` | Balance hash |
859
+ | `loginAddress` | `string` | Login wallet address |
860
+ | `loginChainId` | `number` | Login chain ID |
861
+ | `tokenId` | `number` | Token ID |
862
+ | `tokenAddress` | `string` | Token address |
863
+ | `tokenChainId` | `number` | Token chain ID |
864
+ | `amount` | `string` | Available amount |
865
+ | `lockedAmount` | `string` | Locked amount |
866
+
867
+ **Example:**
868
+
869
+ ```typescript
870
+ const balances = await client.getBalances();
871
+
872
+ balances.forEach(balance => {
873
+ console.log(`Token ${balance.tokenId} (${balance.tokenAddress}):`);
874
+ console.log(` Available: ${balance.amount}`);
875
+ console.log(` Locked: ${balance.lockedAmount}`);
876
+ });
877
+ ```
878
+
879
+ ### getCodexAssets
880
+
881
+ Get all available Codex assets.
882
+
883
+ **Returns:** `Promise<CodexBalanceDto>`
884
+
885
+ **Note:** Returns a single `CodexBalanceDto` object, not an array.
886
+
887
+ **Example:**
888
+
889
+ ```typescript
890
+ const assets = await client.getCodexAssets();
891
+
892
+ console.log('Available assets:', assets);
893
+ ```
894
+
895
+ ### getCCTPAssets
896
+
897
+ Get CCTP (Cross-Chain Transfer Protocol) assets.
898
+
899
+ **Returns:** `Promise<MappedCCTPAssets>`
900
+
901
+ **Note:** Returns an object with dynamic keys (`[key: string]: CCTPAssets[]`), where keys are asset identifiers and values are arrays of CCTP assets.
902
+
903
+ **CCTPAssets interface:**
904
+
905
+ | Property | Type | Description |
906
+ |----------|------|-------------|
907
+ | `chainId` | `number` | Wormhole chain ID |
908
+ | `address` | `string` | Token address |
909
+ | `unifiedChainId` | `number` | Unified chain ID |
910
+
911
+ **Example:**
912
+
913
+ ```typescript
914
+ const cctpAssets = await client.getCCTPAssets();
915
+
916
+ Object.keys(cctpAssets).forEach(assetKey => {
917
+ console.log(`Asset ${assetKey}:`);
918
+ cctpAssets[assetKey].forEach(asset => {
919
+ console.log(` Chain ${asset.chainId}: ${asset.address}`);
920
+ });
921
+ });
922
+ ```
923
+
924
+ ### getCCTPUnifiedAssets
925
+
926
+ Get unified CCTP assets across chains.
927
+
928
+ **Returns:** `Promise<CCTPUnifiedAssets[]>`
929
+
930
+ **CCTPUnifiedAssets interface:**
931
+
932
+ | Property | Type | Description |
933
+ |----------|------|-------------|
934
+ | `id` | `number` | Asset ID |
935
+ | `chainId` | `number` | Chain ID |
936
+ | `address` | `string` | Token address |
937
+ | `symbol` | `string` | Token symbol |
938
+
939
+ **Example:**
940
+
941
+ ```typescript
942
+ const unifiedAssets = await client.getCCTPUnifiedAssets();
943
+
944
+ unifiedAssets.forEach(asset => {
945
+ console.log(`${asset.symbol} on chain ${asset.chainId}: ${asset.address}`);
946
+ });
947
+ ```
948
+
949
+ ---
950
+
951
+ ## Wallet Operations
952
+
953
+ ### withdraw
954
+
955
+ Withdraw funds from the exchange.
956
+
957
+ **Parameters:**
958
+
959
+ | Name | Type | Required | Description |
960
+ |------|------|----------|-------------|
961
+ | `withdrawData` | `IWithdrawData` | Yes | Withdrawal data object |
962
+ | `prettyMsg` | `string` | No | Custom withdrawal message |
963
+
964
+ **IWithdrawData interface:**
965
+
966
+ | Property | Type | Required | Description |
967
+ |----------|------|----------|-------------|
968
+ | `assetId` | `number` | Yes | Asset ID to withdraw |
969
+ | `amount` | `string` | Yes | Withdrawal amount |
970
+ | `recipient` | `string` | Yes | Recipient address |
971
+ | `chainId` | `number` | No | Target chain ID |
972
+
973
+ **Returns:** `Promise<IWithdrawResponse>`
974
+
975
+ **Example:**
976
+
977
+ ```typescript
978
+ const withdrawal = await client.withdraw({
979
+ assetId: 0, // ALGO
980
+ amount: '100',
981
+ recipient: 'RECIPIENT_ADDRESS_HERE',
982
+ chainId: 1
983
+ }, 'Withdrawal to my wallet');
984
+
985
+ console.log('Withdrawal operation ID:', withdrawal.operationId);
986
+ console.log('Withdrawal txn:', withdrawal.txnId);
987
+ ```
988
+
989
+ ### transfer
990
+
991
+ Transfer funds between accounts.
992
+
993
+ **Parameters:**
994
+
995
+ | Name | Type | Required | Description |
996
+ |------|------|----------|-------------|
997
+ | `transferData` | `ITransferData` | Yes | Transfer data object |
998
+
999
+ **ITransferData interface:**
1000
+
1001
+ | Property | Type | Required | Description |
1002
+ |----------|------|----------|-------------|
1003
+ | `assetId` | `number` | Yes | Asset ID |
1004
+ | `amount` | `string` | Yes | Transfer amount |
1005
+ | `recipient` | `string` | Yes | Recipient address |
1006
+ | `memo` | `string` | No | Transfer memo |
1007
+
1008
+ **Returns:** `Promise<ITransfer>`
1009
+
1010
+ **Example:**
1011
+
1012
+ ```typescript
1013
+ const transfer = await client.transfer({
1014
+ assetId: 0,
1015
+ amount: '50',
1016
+ recipient: 'RECIPIENT_ADDRESS',
1017
+ memo: 'Payment for services'
1018
+ });
1019
+
1020
+ console.log('Transfer ID:', transfer.transferId);
1021
+ console.log('Status:', transfer.status);
1022
+ ```
1023
+
1024
+ ### getWalletTransactions
1025
+
1026
+ Get wallet transaction history.
1027
+
1028
+ **Parameters:**
1029
+
1030
+ | Name | Type | Required | Description |
1031
+ |------|------|----------|-------------|
1032
+ | `type` | `string` | Yes | Transaction type ('DEPOSIT', 'WITHDRAWAL', etc.) |
1033
+ | `page` | `number` | Yes | Page number |
1034
+ | `limit` | `number` | No | Results per page (default: 100) |
1035
+
1036
+ **Returns:** `Promise<PaginatedResult<ITransaction>>`
1037
+
1038
+ **Example:**
1039
+
1040
+ ```typescript
1041
+ const transactions = await client.getWalletTransactions('DEPOSIT', 1, 50);
1042
+
1043
+ console.log(`Page ${transactions.page} of ${transactions.totalPages}`);
1044
+ console.log('Transactions:', transactions.data);
1045
+ ```
1046
+
1047
+ ### getTransfers
1048
+
1049
+ Get transfer history.
1050
+
1051
+ **Parameters:**
1052
+
1053
+ | Name | Type | Required | Description |
1054
+ |------|------|----------|-------------|
1055
+ | `page` | `number` | Yes | Page number |
1056
+ | `limit` | `number` | No | Results per page (default: 100) |
1057
+
1058
+ **Returns:** `Promise<PaginatedResult<ITransfer>>`
1059
+
1060
+ **Example:**
1061
+
1062
+ ```typescript
1063
+ const transfers = await client.getTransfers(1, 20);
1064
+
1065
+ transfers.data.forEach(transfer => {
1066
+ console.log(`Transfer ${transfer.transferId}: ${transfer.amount} from ${transfer.senderAddress} to ${transfer.recipientAddress}`);
1067
+ console.log(`Status: ${transfer.status}, Completed: ${transfer.completedAt}`);
1068
+ });
1069
+ ```
1070
+
1071
+ ### getPendingTransactions
1072
+
1073
+ Get pending transactions.
1074
+
1075
+ **Returns:** `Promise<IPendingTxn[]>`
1076
+
1077
+ **Example:**
1078
+
1079
+ ```typescript
1080
+ const pending = await client.getPendingTransactions();
1081
+
1082
+ console.log('Pending transactions:', pending.length);
1083
+ ```
1084
+
1085
+ ### getTradingKeys
1086
+
1087
+ Get user's trading keys.
1088
+
1089
+ **Returns:** `Promise<ITradingKey>`
1090
+
1091
+ **Note:** Returns a single `ITradingKey` object, not an array.
1092
+
1093
+ **ITradingKey interface:**
1094
+
1095
+ | Property | Type | Description |
1096
+ |----------|------|-------------|
1097
+ | `address` | `string` | Trading key address |
1098
+ | `createdAt` | `Date` | Creation timestamp |
1099
+ | `expiredAt` | `Date` | Expiration timestamp |
1100
+ | `orders` | `number` | Number of orders |
1101
+ | `device` | `string` | Device identifier |
1102
+ | `type` | `TradingKeyType` | Key type (optional) |
1103
+
1104
+ **Example:**
1105
+
1106
+ ```typescript
1107
+ const tradingKey = await client.getTradingKeys();
1108
+
1109
+ console.log('Trading key address:', tradingKey.address);
1110
+ console.log('Expires at:', tradingKey.expiredAt);
1111
+ console.log('Orders count:', tradingKey.orders);
1112
+ ```
1113
+
1114
+ ---
1115
+
1116
+ ## Whitelist & Withdrawal Wallets
1117
+
1118
+ ### getWhitelist
1119
+
1120
+ Get withdrawal whitelist.
1121
+
1122
+ **Returns:** `Promise<PaginatedResult<IGetWhiteList>>`
1123
+
1124
+ **IGetWhiteList interface:**
1125
+
1126
+ | Property | Type | Description |
1127
+ |----------|------|-------------|
1128
+ | `id` | `number` | Whitelist entry ID |
1129
+ | `recipientAddress` | `string` | Recipient wallet address |
1130
+ | `tkAddress` | `string` | Trading key address |
1131
+ | `expiredAt` | `number` | Expiration timestamp |
1132
+
1133
+ **Example:**
1134
+
1135
+ ```typescript
1136
+ const whitelist = await client.getWhitelist();
1137
+
1138
+ whitelist.data.forEach(item => {
1139
+ console.log(`${item.recipientAddress} - expires: ${new Date(item.expiredAt)}`);
1140
+ });
1141
+ ```
1142
+
1143
+ ### addWhitelist
1144
+
1145
+ Add address to withdrawal whitelist.
1146
+
1147
+ **Parameters:**
1148
+
1149
+ | Name | Type | Required | Description |
1150
+ |------|------|----------|-------------|
1151
+ | `data` | `IWhiteList` | Yes | Whitelist data object |
1152
+
1153
+ **IWhiteList interface:**
1154
+
1155
+ | Property | Type | Required | Description |
1156
+ |----------|------|----------|-------------|
1157
+ | `id` | `number` | No | Whitelist entry ID (for updates) |
1158
+ | `loginAddress` | `string` | Yes | Login wallet address |
1159
+ | `loginChainId` | `number` | Yes | Login chain ID |
1160
+ | `recipient` | `string` | Yes | Recipient wallet address |
1161
+ | `recipientChainId` | `number` | Yes | Recipient chain ID |
1162
+ | `tkAddress` | `string` | Yes | Trading key address |
1163
+ | `expiredDate` | `number` | No | Expiration timestamp in milliseconds (will be converted to seconds internally) |
1164
+
1165
+ **Returns:** `Promise<IGetWhiteList>`
1166
+
1167
+ **Example:**
1168
+
1169
+ ```typescript
1170
+ const whitelisted = await client.addWhitelist({
1171
+ loginAddress: client.mainWallet?.address || '',
1172
+ loginChainId: 1,
1173
+ recipient: 'WHITELISTED_ADDRESS',
1174
+ recipientChainId: 1,
1175
+ tkAddress: client.mainWallet?.tradingKey || '',
1176
+ expiredDate: Date.now() + 365 * 24 * 60 * 60 * 1000 // 1 year
1177
+ });
1178
+
1179
+ console.log('Address whitelisted:', whitelisted.id);
1180
+ ```
1181
+
1182
+ ### deleteWhitelist
1183
+
1184
+ Remove address from whitelist.
1185
+
1186
+ **Parameters:**
1187
+
1188
+ | Name | Type | Required | Description |
1189
+ |------|------|----------|-------------|
1190
+ | `whitelistId` | `number` | Yes | Whitelist entry ID |
1191
+
1192
+ **Returns:** `Promise<void>`
1193
+
1194
+ **Example:**
1195
+
1196
+ ```typescript
1197
+ await client.deleteWhitelist(123);
1198
+ ```
1199
+
1200
+ ### getAllWithdrawalWallets
1201
+
1202
+ Get all withdrawal wallets.
1203
+
1204
+ **Returns:** `Promise<ISafeWithdrawalWallets[]>`
1205
+
1206
+ **ISafeWithdrawalWallets interface:**
1207
+
1208
+ | Property | Type | Description |
1209
+ |----------|------|-------------|
1210
+ | `name` | `string` | Wallet name |
1211
+ | `type` | `WithdrawalWalletType` | Wallet type |
1212
+ | `address` | `string` | Wallet address |
1213
+ | `description` | `string` | Wallet description |
1214
+ | `createdAt` | `Date` | Creation timestamp |
1215
+
1216
+ **Example:**
1217
+
1218
+ ```typescript
1219
+ const wallets = await client.getAllWithdrawalWallets();
1220
+
1221
+ wallets.forEach(wallet => {
1222
+ console.log(`${wallet.name}: ${wallet.address}`);
1223
+ console.log(`Type: ${wallet.type}, Description: ${wallet.description}`);
1224
+ });
1225
+ ```
1226
+
1227
+ ### createWithdrawalWallet
1228
+
1229
+ Create a new withdrawal wallet.
1230
+
1231
+ **Parameters:**
1232
+
1233
+ | Name | Type | Required | Description |
1234
+ |------|------|----------|-------------|
1235
+ | `body` | `CreateWithdrawalWallet` | Yes | Withdrawal wallet creation data object |
1236
+
1237
+ **CreateWithdrawalWallet interface:**
1238
+
1239
+ Extends `ISignedMessage<WithdrawalWalletData>` with:
1240
+ - `data`: Contains `address`, `name`, `type`, `description?`
1241
+ - `message`: Signed message
1242
+ - `signature`: Message signature
1243
+
1244
+ **Returns:** `Promise<ISafeWithdrawalWallets>`
1245
+
1246
+ **ISafeWithdrawalWallets interface:**
1247
+
1248
+ | Property | Type | Description |
1249
+ |----------|------|-------------|
1250
+ | `name` | `string` | Wallet name |
1251
+ | `type` | `WithdrawalWalletType` | Wallet type |
1252
+ | `address` | `string` | Wallet address |
1253
+ | `description` | `string` | Wallet description |
1254
+ | `createdAt` | `Date` | Creation timestamp |
1255
+
1256
+ **Example:**
1257
+
1258
+ ```typescript
1259
+ const wallet = await client.createWithdrawalWallet({
1260
+ data: {
1261
+ address: 'WALLET_ADDRESS',
1262
+ name: 'Main wallet',
1263
+ type: WithdrawalWalletType.SAFE,
1264
+ description: 'My main withdrawal wallet'
1265
+ },
1266
+ message: 'SIGNED_MESSAGE',
1267
+ signature: 'SIGNATURE'
1268
+ });
1269
+
1270
+ console.log('Wallet created:', wallet.address);
1271
+ console.log('Name:', wallet.name);
1272
+ ```
1273
+
1274
+ ### updateWithdrawalWallet
1275
+
1276
+ Update withdrawal wallet.
1277
+
1278
+ **Parameters:**
1279
+
1280
+ | Name | Type | Required | Description |
1281
+ |------|------|----------|-------------|
1282
+ | `params` | `UpdateWithdrawalWallet` | Yes | Withdrawal wallet update data object |
1283
+
1284
+ **UpdateWithdrawalWallet interface:**
1285
+
1286
+ Extends `ISignedMessage<UpdateWithdrawalWalletData>` with:
1287
+ - `data`: Contains `oldAddress`, `address`, `name`, `type`, `description?`
1288
+ - `message`: Signed message
1289
+ - `signature`: Message signature
1290
+
1291
+ **Returns:** `Promise<boolean>`
1292
+
1293
+ **Example:**
1294
+
1295
+ ```typescript
1296
+ await client.updateWithdrawalWallet({
1297
+ data: {
1298
+ oldAddress: 'OLD_WALLET_ADDRESS',
1299
+ address: 'NEW_WALLET_ADDRESS',
1300
+ name: 'Updated wallet name',
1301
+ type: WithdrawalWalletType.SAFE,
1302
+ description: 'Updated description'
1303
+ },
1304
+ message: 'SIGNED_MESSAGE',
1305
+ signature: 'SIGNATURE'
1306
+ });
1307
+ ```
1308
+
1309
+ ### deleteWithdrawalWallet
1310
+
1311
+ Delete withdrawal wallet.
1312
+
1313
+ **Parameters:**
1314
+
1315
+ | Name | Type | Required | Description |
1316
+ |------|------|----------|-------------|
1317
+ | `address` | `string` | Yes | Wallet address |
1318
+
1319
+ **Returns:** `Promise<boolean>`
1320
+
1321
+ **Example:**
1322
+
1323
+ ```typescript
1324
+ await client.deleteWithdrawalWallet('WALLET_ADDRESS');
1325
+ ```
1326
+
1327
+ ---
1328
+
1329
+ ## KYC
1330
+
1331
+ ### getKycStatus
1332
+
1333
+ Get user's KYC verification status.
1334
+
1335
+ **Returns:** `Promise<IGetKycStatus>`
1336
+
1337
+ **IGetKycStatus interface:**
1338
+
1339
+ | Property | Type | Description |
1340
+ |----------|------|-------------|
1341
+ | `kycStatus` | `KYCAuthenticationStatus` | KYC authentication status (optional) |
1342
+
1343
+ **Example:**
1344
+
1345
+ ```typescript
1346
+ import { KYCAuthenticationStatus } from '@ultrade/ultrade-js-sdk';
1347
+
1348
+ const kycStatus = await client.getKycStatus();
1349
+
1350
+ if (kycStatus.kycStatus) {
1351
+ console.log('KYC status:', kycStatus.kycStatus);
1352
+ }
1353
+ ```
1354
+
1355
+ ### getKycInitLink
1356
+
1357
+ Initialize KYC verification process.
1358
+
1359
+ **Parameters:**
1360
+
1361
+ | Name | Type | Required | Description |
1362
+ |------|------|----------|-------------|
1363
+ | `embeddedAppUrl` | `string \| null` | Yes | Callback URL after KYC |
1364
+
1365
+ **Returns:** `Promise<IGetKycInitLink>`
1366
+
1367
+ **Example:**
1368
+
1369
+ ```typescript
1370
+ const kycLink = await client.getKycInitLink('https://myapp.com/kyc-callback');
1371
+
1372
+ console.log('KYC verification URL:', kycLink.url);
1373
+ window.open(kycLink.url, '_blank');
1374
+ ```
1375
+
1376
+ ---
1377
+
1378
+ ## WebSocket
1379
+
1380
+ ### subscribe
1381
+
1382
+ Subscribe to real-time WebSocket streams.
1383
+
1384
+ **Parameters:**
1385
+
1386
+ | Name | Type | Required | Description |
1387
+ |------|------|----------|-------------|
1388
+ | `subscribeOptions` | `SubscribeOptions` | Yes | Subscription options object |
1389
+ | `callback` | `Function` | Yes | Event callback function |
1390
+
1391
+ **SubscribeOptions interface:**
1392
+
1393
+ | Property | Type | Required | Description |
1394
+ |----------|------|----------|-------------|
1395
+ | `symbol` | `string` | Yes | Trading pair symbol |
1396
+ | `streams` | `STREAMS[]` | Yes | Array of streams to subscribe |
1397
+ | `options` | `object` | Yes | Subscription options (e.g., `address`, `depth`, `token`, `tradingKey`) |
1398
+
1399
+ **Returns:** `number` - Handler ID for unsubscribing
1400
+
1401
+ **Example:**
1402
+
1403
+ ```typescript
1404
+ import { STREAMS } from '@ultrade/ultrade-js-sdk';
1405
+
1406
+ const handlerId = client.subscribe(
1407
+ {
1408
+ symbol: 'ALGO/USDC',
1409
+ streams: [STREAMS.DEPTH, STREAMS.TRADES, STREAMS.TICKER],
1410
+ options: {
1411
+ address: client.mainWallet?.address || '',
1412
+ depth: 10
1413
+ }
1414
+ },
1415
+ (event: string, data: any) => {
1416
+ console.log('WebSocket event:', event, data);
1417
+
1418
+ switch(event) {
1419
+ case 'depth':
1420
+ console.log('Order book update:', data);
1421
+ break;
1422
+ case 'trade':
1423
+ console.log('New trade:', data);
1424
+ break;
1425
+ case 'ticker':
1426
+ console.log('Price ticker:', data);
1427
+ break;
1428
+ }
1429
+ }
1430
+ );
1431
+
1432
+ // Save handler ID for cleanup
1433
+ ```
1434
+
1435
+ ### unsubscribe
1436
+
1437
+ Unsubscribe from WebSocket streams.
1438
+
1439
+ **Parameters:**
1440
+
1441
+ | Name | Type | Required | Description |
1442
+ |------|------|----------|-------------|
1443
+ | `handlerId` | `number` | Yes | Handler ID from subscribe |
1444
+
1445
+ **Returns:** `void`
1446
+
1447
+ **Example:**
1448
+
1449
+ ```typescript
1450
+ // Unsubscribe using handler ID
1451
+ client.unsubscribe(handlerId);
1452
+ ```
1453
+
1454
+ ---
1455
+
1456
+ ## System
1457
+
1458
+ ### getSettings
1459
+
1460
+ Get platform settings.
1461
+
1462
+ **Returns:** `Promise<SettingsInit>`
1463
+
1464
+ **Note:** Returns an object with dynamic keys based on `SettingIds` enum. Common properties include:
1465
+ - `partnerId`: Partner ID
1466
+ - `isUltrade`: Whether it's Ultrade platform
1467
+ - `companyId`: Company ID
1468
+ - `currentCountry`: Current country (optional)
1469
+ - Various setting values indexed by `SettingIds` enum keys
1470
+
1471
+ **Example:**
1472
+
1473
+ ```typescript
1474
+ const settings = await client.getSettings();
1475
+
1476
+ console.log('Company ID:', settings.companyId);
1477
+ console.log('Partner ID:', settings.partnerId);
1478
+ console.log('Is Ultrade:', settings.isUltrade);
1479
+ console.log('Current country:', settings.currentCountry);
1480
+ // Access specific settings by SettingIds enum
1481
+ console.log('App title:', settings[SettingIds.APP_TITLE]);
1482
+ ```
1483
+
1484
+ ### getVersion
1485
+
1486
+ Get API version information.
1487
+
1488
+ **Returns:** `Promise<ISystemVersion>`
1489
+
1490
+ **ISystemVersion interface:**
1491
+
1492
+ | Property | Type | Description |
1493
+ |----------|------|-------------|
1494
+ | `version` | `string \| null` | API version string |
1495
+
1496
+ **Example:**
1497
+
1498
+ ```typescript
1499
+ const version = await client.getVersion();
1500
+
1501
+ console.log('API version:', version.version);
1502
+ ```
1503
+
1504
+ ### getMaintenance
1505
+
1506
+ Get maintenance status.
1507
+
1508
+ **Returns:** `Promise<ISystemMaintenance>`
1509
+
1510
+ **ISystemMaintenance interface:**
1511
+
1512
+ | Property | Type | Description |
1513
+ |----------|------|-------------|
1514
+ | `mode` | `MaintenanceMode` | Maintenance mode enum |
1515
+
1516
+ **Example:**
1517
+
1518
+ ```typescript
1519
+ import { MaintenanceMode } from '@ultrade/ultrade-js-sdk';
1520
+
1521
+ const maintenance = await client.getMaintenance();
1522
+
1523
+ if (maintenance.mode === MaintenanceMode.ACTIVE) {
1524
+ console.log('Platform is under maintenance');
1525
+ }
1526
+ ```
1527
+
1528
+ ### ping
1529
+
1530
+ Check latency to the server.
1531
+
1532
+ **Returns:** `Promise<number>` - Latency in milliseconds
1533
+
1534
+ **Example:**
1535
+
1536
+ ```typescript
1537
+ const latency = await client.ping();
1538
+
1539
+ console.log(`Server latency: ${latency}ms`);
1540
+ ```
1541
+
1542
+ ### getChains
1543
+
1544
+ Get supported blockchain chains.
1545
+
1546
+ **Returns:** `Promise<Chain[]>`
1547
+
1548
+ **Chain interface:**
1549
+
1550
+ | Property | Type | Description |
1551
+ |----------|------|-------------|
1552
+ | `chainId` | `number` | Chain ID |
1553
+ | `whChainId` | `string` | Wormhole chain ID |
1554
+ | `tmc` | `string` | TMC identifier |
1555
+ | `name` | `BLOCKCHAINS` | Blockchain name enum |
1556
+
1557
+ **Example:**
1558
+
1559
+ ```typescript
1560
+ const chains = await client.getChains();
1561
+
1562
+ chains.forEach(chain => {
1563
+ console.log(`${chain.name} (Chain ID: ${chain.chainId}, WH Chain ID: ${chain.whChainId})`);
1564
+ });
1565
+ ```
1566
+
1567
+ ### getDollarValues
1568
+
1569
+ Get USD values for assets.
1570
+
1571
+ **Parameters:**
1572
+
1573
+ | Name | Type | Required | Description |
1574
+ |------|------|----------|-------------|
1575
+ | `assetIds` | `number[]` | No | Array of asset IDs (default: empty array for all) |
1576
+
1577
+ **Returns:** `Promise<IGetDollarValues>`
1578
+
1579
+ **Note:** Returns an object with dynamic keys (`[key: string]: number`), where keys are asset IDs and values are USD prices.
1580
+
1581
+ **Example:**
1582
+
1583
+ ```typescript
1584
+ // Get prices for specific assets
1585
+ const prices = await client.getDollarValues([0, 1, 2]);
1586
+
1587
+ // Get prices for all assets
1588
+ const allPrices = await client.getDollarValues();
1589
+
1590
+ // Access prices by asset ID
1591
+ Object.keys(prices).forEach(assetId => {
1592
+ console.log(`Asset ${assetId}: $${prices[assetId]}`);
1593
+ });
1594
+ ```
1595
+
1596
+ ### getTransactionDetalis
1597
+
1598
+ Get detailed transaction information.
1599
+
1600
+ **Parameters:**
1601
+
1602
+ | Name | Type | Required | Description |
1603
+ |------|------|----------|-------------|
1604
+ | `transactionId` | `number` | Yes | Transaction ID |
1605
+
1606
+ **Returns:** `Promise<ITransactionDetails>`
1607
+
1608
+ **Example:**
1609
+
1610
+ ```typescript
1611
+ const details = await client.getTransactionDetalis(12345);
1612
+
1613
+ console.log('Transaction:', {
1614
+ id: details.id,
1615
+ primaryId: details.primaryId,
1616
+ actionType: details.action_type,
1617
+ amount: details.amount,
1618
+ status: details.status,
1619
+ targetAddress: details.targetAddress,
1620
+ timestamp: details.timestamp,
1621
+ createdAt: details.createdAt,
1622
+ fee: details.fee
1623
+ });
1624
+ ```
1625
+
1626
+ ### getWithdrawalFee
1627
+
1628
+ Get withdrawal fee for an asset.
1629
+
1630
+ **Parameters:**
1631
+
1632
+ | Name | Type | Required | Description |
1633
+ |------|------|----------|-------------|
1634
+ | `assetAddress` | `string` | Yes | Asset address |
1635
+ | `chainId` | `number` | Yes | Chain ID |
1636
+
1637
+ **Returns:** `Promise<IWithdrawalFee>`
1638
+
1639
+ **IWithdrawalFee interface:**
1640
+
1641
+ | Property | Type | Description |
1642
+ |----------|------|-------------|
1643
+ | `fee` | `string` | Withdrawal fee amount |
1644
+ | `dollarValue` | `string` | Fee value in USD |
1645
+
1646
+ **Example:**
1647
+
1648
+ ```typescript
1649
+ const fee = await client.getWithdrawalFee('ASSET_ADDRESS', 1);
1650
+
1651
+ console.log('Withdrawal fee:', fee.fee);
1652
+ console.log('Fee in USD:', fee.dollarValue);
1653
+ ```
1654
+
1655
+ ---
1656
+
1657
+ ## Notifications
1658
+
1659
+ ### getNotifications
1660
+
1661
+ Get user notifications.
1662
+
1663
+ **Returns:** `Promise<UserNotification[]>`
1664
+
1665
+ **UserNotification interface:**
1666
+
1667
+ | Property | Type | Description |
1668
+ |----------|------|-------------|
1669
+ | `id` | `number` | Notification ID |
1670
+ | `globalNotificationId` | `number` | Global notification ID |
1671
+ | `priority` | `any` | Notification priority |
1672
+ | `status` | `any` | Notification status |
1673
+ | `type` | `any` | Notification type |
1674
+ | `message` | `string` | Notification message |
1675
+ | `createdAt` | `Date` | Creation timestamp |
1676
+
1677
+ **Example:**
1678
+
1679
+ ```typescript
1680
+ const notifications = await client.getNotifications();
1681
+
1682
+ notifications.forEach(notif => {
1683
+ console.log(`[${notif.type}] ${notif.message}`);
1684
+ console.log('Status:', notif.status);
1685
+ console.log('Created:', notif.createdAt);
1686
+ });
1687
+ ```
1688
+
1689
+ ### getNotificationsUnreadCount
1690
+
1691
+ Get count of unread notifications.
1692
+
1693
+ **Returns:** `Promise<IUnreadNotificationsCount>`
1694
+
1695
+ **Example:**
1696
+
1697
+ ```typescript
1698
+ const { count } = await client.getNotificationsUnreadCount();
1699
+
1700
+ console.log(`You have ${count} unread notifications`);
1701
+ ```
1702
+
1703
+ ### readNotifications
1704
+
1705
+ Mark notifications as read.
1706
+
1707
+ **Parameters:**
1708
+
1709
+ | Name | Type | Required | Description |
1710
+ |------|------|----------|-------------|
1711
+ | `notifications` | `UpdateUserNotificationDto[]` | Yes | Array of notifications to update |
1712
+
1713
+ **UpdateUserNotificationDto interface:**
1714
+
1715
+ | Property | Type | Required | Description |
1716
+ |----------|------|----------|-------------|
1717
+ | `id` | `number` | No | Notification ID |
1718
+ | `globalNotificationId` | `number` | No | Global notification ID |
1719
+ | `status` | `NotificationStatusEnum` | Yes | Notification status |
1720
+
1721
+ **Returns:** `Promise<UpdateUserNotificationDto[]>`
1722
+
1723
+ **Example:**
1724
+
1725
+ ```typescript
1726
+ import { NotificationStatusEnum } from '@ultrade/ultrade-js-sdk';
1727
+
1728
+ await client.readNotifications([
1729
+ { id: 1, status: NotificationStatusEnum.READ },
1730
+ { globalNotificationId: 2, status: NotificationStatusEnum.READ }
1731
+ ]);
1732
+ ```
1733
+
1734
+ ---
1735
+
1736
+ ## Affiliates
1737
+
1738
+ ### getAffiliatesStatus
1739
+
1740
+ Get affiliate program status.
1741
+
1742
+ **Parameters:**
1743
+
1744
+ | Name | Type | Required | Description |
1745
+ |------|------|----------|-------------|
1746
+ | `companyId` | `number` | Yes | Company ID |
1747
+
1748
+ **Returns:** `Promise<IAffiliateDashboardStatus>`
1749
+
1750
+ **IAffiliateDashboardStatus interface:**
1751
+
1752
+ | Property | Type | Description |
1753
+ |----------|------|-------------|
1754
+ | `enabled` | `boolean` | Whether affiliate program is enabled |
1755
+ | `isAffiliate` | `boolean` | Whether user is an affiliate |
1756
+
1757
+ **Example:**
1758
+
1759
+ ```typescript
1760
+ const status = await client.getAffiliatesStatus(1);
1761
+
1762
+ console.log('Is affiliate:', status.isAffiliate);
1763
+ console.log('Program enabled:', status.enabled);
1764
+ ```
1765
+
1766
+ ### createAffiliate
1767
+
1768
+ Register as an affiliate.
1769
+
1770
+ **Parameters:**
1771
+
1772
+ | Name | Type | Required | Description |
1773
+ |------|------|----------|-------------|
1774
+ | `companyId` | `number` | Yes | Company ID |
1775
+
1776
+ **Returns:** `Promise<DashboardInfo>`
1777
+
1778
+ **DashboardInfo interface:**
1779
+
1780
+ | Property | Type | Description |
1781
+ |----------|------|-------------|
1782
+ | `feeShare` | `number` | Fee share percentage |
1783
+ | `referralLink` | `string` | Referral link |
1784
+ | `summaryStats` | `AffiliateSummaryStats` | Summary statistics |
1785
+ | `trendStats` | `AffiliateTrendStats \| null` | Trend statistics (optional) |
1786
+
1787
+ **Example:**
1788
+
1789
+ ```typescript
1790
+ const affiliate = await client.createAffiliate(1);
1791
+
1792
+ console.log('Referral link:', affiliate.referralLink);
1793
+ console.log('Fee share:', affiliate.feeShare);
1794
+ console.log('Summary stats:', affiliate.summaryStats);
1795
+ ```
1796
+
1797
+ ### getAffiliateProgress
1798
+
1799
+ Get affiliate progress.
1800
+
1801
+ **Parameters:**
1802
+
1803
+ | Name | Type | Required | Description |
1804
+ |------|------|----------|-------------|
1805
+ | `companyId` | `number` | Yes | Company ID |
1806
+
1807
+ **Returns:** `Promise<IAffiliateProgress>`
1808
+
1809
+ **IAffiliateProgress interface:**
1810
+
1811
+ | Property | Type | Description |
1812
+ |----------|------|-------------|
1813
+ | `totalTradingVolumeUsd` | `number` | Total trading volume in USD |
1814
+ | `unlockThreshold` | `number` | Threshold to unlock affiliate status |
1815
+
1816
+ **Example:**
1817
+
1818
+ ```typescript
1819
+ const progress = await client.getAffiliateProgress(1);
1820
+
1821
+ console.log('Trading volume (USD):', progress.totalTradingVolumeUsd);
1822
+ console.log('Unlock threshold:', progress.unlockThreshold);
1823
+ console.log('Progress:', (progress.totalTradingVolumeUsd / progress.unlockThreshold * 100).toFixed(2) + '%');
1824
+ ```
1825
+
1826
+ ### getAffiliateInfo
1827
+
1828
+ Get affiliate dashboard information.
1829
+
1830
+ **Parameters:**
1831
+
1832
+ | Name | Type | Required | Description |
1833
+ |------|------|----------|-------------|
1834
+ | `companyId` | `number` | Yes | Company ID |
1835
+ | `range` | `string` | Yes | Date range ('day', 'week', 'month', 'all') |
1836
+
1837
+ **Returns:** `Promise<DashboardInfo>`
1838
+
1839
+ **Example:**
1840
+
1841
+ ```typescript
1842
+ const info = await client.getAffiliateInfo(1, 'month');
1843
+
1844
+ console.log('Referral link:', info.referralLink);
1845
+ console.log('Fee share:', info.feeShare);
1846
+ console.log('Total revenue:', info.summaryStats.totalRevenue);
1847
+ console.log('Link clicks:', info.summaryStats.linkClicks);
1848
+ console.log('Registrations:', info.summaryStats.registrations);
1849
+ console.log('Trading volume:', info.summaryStats.totalTradingVolume);
1850
+ ```
1851
+
1852
+ ### countAffiliateDepost
1853
+
1854
+ Count affiliate deposit.
1855
+
1856
+ **Parameters:**
1857
+
1858
+ | Name | Type | Required | Description |
1859
+ |------|------|----------|-------------|
1860
+ | `companyId` | `number` | Yes | Company ID |
1861
+
1862
+ **Returns:** `Promise<void>`
1863
+
1864
+ **Example:**
1865
+
1866
+ ```typescript
1867
+ await client.countAffiliateDepost(1);
1868
+ ```
1869
+
1870
+ ### countAffiliateClick
1871
+
1872
+ Track affiliate referral click.
1873
+
1874
+ **Parameters:**
1875
+
1876
+ | Name | Type | Required | Description |
1877
+ |------|------|----------|-------------|
1878
+ | `referralToken` | `string` | Yes | Referral token |
1879
+
1880
+ **Returns:** `Promise<void>`
1881
+
1882
+ **Example:**
1883
+
1884
+ ```typescript
1885
+ await client.countAffiliateClick('REF123');
1886
+ ```
1887
+
1888
+ ---
1889
+
1890
+ ## Social
1891
+
1892
+ ### getSocialAccount
1893
+
1894
+ Get user's social account information.
1895
+
1896
+ **Returns:** `Promise<ISocialAccount | undefined>`
1897
+
1898
+ **ISocialAccount interface:**
1899
+
1900
+ | Property | Type | Description |
1901
+ |----------|------|-------------|
1902
+ | `points` | `number` | User points |
1903
+ | `address` | `string` | Wallet address |
1904
+ | `email` | `string` | Email address (optional) |
1905
+ | `emailVerified` | `boolean` | Email verification status |
1906
+ | `twitterAccount` | `object` | Twitter account info (optional) |
1907
+ | `telegramAccount` | `object` | Telegram account info (optional) |
1908
+ | `discordAccount` | `object` | Discord account info (optional) |
1909
+
1910
+ **Example:**
1911
+
1912
+ ```typescript
1913
+ const social = await client.getSocialAccount();
1914
+
1915
+ if (social) {
1916
+ console.log('Address:', social.address);
1917
+ console.log('Points:', social.points);
1918
+ console.log('Email:', social.email);
1919
+ console.log('Email verified:', social.emailVerified);
1920
+ if (social.twitterAccount) {
1921
+ console.log('Twitter:', social.twitterAccount.userName);
1922
+ }
1923
+ }
1924
+ ```
1925
+
1926
+ ### addSocialEmail
1927
+
1928
+ Add email to social account.
1929
+
1930
+ **Parameters:**
1931
+
1932
+ | Name | Type | Required | Description |
1933
+ |------|------|----------|-------------|
1934
+ | `email` | `string` | Yes | Email address |
1935
+ | `embeddedAppUrl` | `string` | Yes | Callback URL |
1936
+
1937
+ **Returns:** `Promise<void>`
1938
+
1939
+ **Example:**
1940
+
1941
+ ```typescript
1942
+ await client.addSocialEmail(
1943
+ 'user@example.com',
1944
+ 'https://myapp.com/verify'
1945
+ );
1946
+
1947
+ console.log('Verification email sent');
1948
+ ```
1949
+
1950
+ ### verifySocialEmail
1951
+
1952
+ Verify email address.
1953
+
1954
+ **Parameters:**
1955
+
1956
+ | Name | Type | Required | Description |
1957
+ |------|------|----------|-------------|
1958
+ | `email` | `string` | Yes | Email address |
1959
+ | `hash` | `string` | Yes | Verification hash |
1960
+
1961
+ **Returns:** `Promise<void>`
1962
+
1963
+ **Example:**
1964
+
1965
+ ```typescript
1966
+ await client.verifySocialEmail(
1967
+ 'user@example.com',
1968
+ 'VERIFICATION_HASH'
1969
+ );
1970
+
1971
+ console.log('Email verified');
1972
+ ```
1973
+
1974
+ ### getLeaderboards
1975
+
1976
+ Get leaderboard rankings.
1977
+
1978
+ **Returns:** `Promise<ILeaderboardItem[]>`
1979
+
1980
+ **ILeaderboardItem interface:**
1981
+
1982
+ | Property | Type | Description |
1983
+ |----------|------|-------------|
1984
+ | `address` | `string` | Wallet address |
1985
+ | `currentPoints` | `number` | Current points |
1986
+ | `tasksCompleted` | `number` | Number of completed tasks |
1987
+ | `twitter` | `string` | Twitter username (optional) |
1988
+ | `discord` | `string` | Discord username (optional) |
1989
+ | `telegram` | `string` | Telegram username (optional) |
1990
+ | `order` | `number` | Ranking position |
1991
+
1992
+ **Example:**
1993
+
1994
+ ```typescript
1995
+ const leaderboard = await client.getLeaderboards();
1996
+
1997
+ leaderboard.forEach((item) => {
1998
+ console.log(`${item.order}. ${item.address} - ${item.currentPoints} points`);
1999
+ console.log(`Tasks completed: ${item.tasksCompleted}`);
2000
+ });
2001
+ ```
2002
+
2003
+ ### getUnlocks
2004
+
2005
+ Get user's unlocked achievements.
2006
+
2007
+ **Returns:** `Promise<IUnlock[]>`
2008
+
2009
+ **IUnlock interface:**
2010
+
2011
+ | Property | Type | Description |
2012
+ |----------|------|-------------|
2013
+ | `id` | `number` | Unlock ID |
2014
+ | `companyId` | `number` | Company ID |
2015
+ | `seasonId` | `number` | Season ID |
2016
+ | `name` | `string` | Unlock name |
2017
+ | `description` | `string` | Unlock description |
2018
+ | `points` | `number` | Points required |
2019
+ | `enabled` | `boolean` | Whether unlock is enabled |
2020
+
2021
+ **Example:**
2022
+
2023
+ ```typescript
2024
+ const unlocks = await client.getUnlocks();
2025
+
2026
+ unlocks.forEach(unlock => {
2027
+ console.log(`Unlocked: ${unlock.name} - ${unlock.description}`);
2028
+ console.log(`Points: ${unlock.points}`);
2029
+ });
2030
+ ```
2031
+
2032
+ ### getSocialSettings
2033
+
2034
+ Get social feature settings.
2035
+
2036
+ **Returns:** `Promise<ISocialSettings>`
2037
+
2038
+ **Note:** Returns an object with dynamic key-value pairs (`[key: string]: any`).
2039
+
2040
+ **Example:**
2041
+
2042
+ ```typescript
2043
+ const settings = await client.getSocialSettings();
2044
+
2045
+ console.log('Social settings:', settings);
2046
+ // Access specific settings by key
2047
+ console.log('Setting value:', settings['someKey']);
2048
+ ```
2049
+
2050
+ ### getSeason
2051
+
2052
+ Get current active season.
2053
+
2054
+ **Parameters:**
2055
+
2056
+ | Name | Type | Required | Description |
2057
+ |------|------|----------|-------------|
2058
+ | `ultradeId` | `number` | No | Ultrade ID (optional) |
2059
+
2060
+ **Returns:** `Promise<ISocialSeason>`
2061
+
2062
+ **Example:**
2063
+
2064
+ ```typescript
2065
+ // Get season for default company
2066
+ const season = await client.getSeason();
2067
+
2068
+ // Get season for specific Ultrade ID
2069
+ const ultradeSeason = await client.getSeason(1);
2070
+
2071
+ console.log('Season:', season.name);
2072
+ console.log('Start:', new Date(season.startDate));
2073
+ console.log('End:', season.endDate ? new Date(season.endDate) : 'Ongoing');
2074
+ ```
2075
+
2076
+ ### getPastSeasons
2077
+
2078
+ Get historical seasons.
2079
+
2080
+ **Returns:** `Promise<ISocialSeason[]>`
2081
+
2082
+ **ISocialSeason interface:**
2083
+
2084
+ | Property | Type | Description |
2085
+ |----------|------|-------------|
2086
+ | `id` | `number` | Season ID |
2087
+ | `companyId` | `number` | Company ID |
2088
+ | `startDate` | `Date` | Season start date |
2089
+ | `endDate` | `Date` | Season end date (optional) |
2090
+ | `name` | `string` | Season name |
2091
+ | `isSelected` | `boolean` | Whether season is selected |
2092
+ | `status` | `string` | Season status |
2093
+ | `createdAt` | `Date` | Creation timestamp |
2094
+ | `updatedAt` | `Date` | Update timestamp |
2095
+
2096
+ **Example:**
2097
+
2098
+ ```typescript
2099
+ const pastSeasons = await client.getPastSeasons();
2100
+
2101
+ pastSeasons.forEach(season => {
2102
+ console.log(`${season.name} (${new Date(season.startDate)} - ${season.endDate ? new Date(season.endDate) : 'Ongoing'})`);
2103
+ console.log(`Status: ${season.status}, Selected: ${season.isSelected}`);
2104
+ });
2105
+ ```
2106
+
2107
+ ---
2108
+
2109
+ ## Social Integrations
2110
+
2111
+ ### Telegram
2112
+
2113
+ #### addTelegram
2114
+
2115
+ Connect Telegram account.
2116
+
2117
+ **Parameters:**
2118
+
2119
+ | Name | Type | Required | Description |
2120
+ |------|------|----------|-------------|
2121
+ | `data` | `TelegramData` | Yes | Telegram authentication data |
2122
+
2123
+ **TelegramData interface:**
2124
+
2125
+ | Property | Type | Required | Description |
2126
+ |----------|------|----------|-------------|
2127
+ | `auth_date` | `number` | Yes | Authentication date timestamp |
2128
+ | `id` | `number` | Yes | Telegram user ID |
2129
+ | `first_name` | `string` | Yes | First name |
2130
+ | `hash` | `string` | Yes | Authentication hash |
2131
+ | `photo_url` | `string` | Yes | Profile photo URL |
2132
+ | `username` | `string` | Yes | Telegram username |
2133
+
2134
+ **Returns:** `Promise<ITelegramConnectResponse>`
2135
+
2136
+ **Example:**
2137
+
2138
+ ```typescript
2139
+ const result = await client.addTelegram({
2140
+ auth_date: Math.floor(Date.now() / 1000),
2141
+ id: 123456789,
2142
+ first_name: 'John',
2143
+ hash: 'TELEGRAM_HASH',
2144
+ photo_url: 'https://t.me/photo.jpg',
2145
+ username: 'myusername'
2146
+ });
2147
+
2148
+ console.log('Telegram connected:', result.address);
2149
+ console.log('Telegram ID:', result.telegramId);
2150
+ ```
2151
+
2152
+ #### disconnectTelegram
2153
+
2154
+ Disconnect Telegram account.
2155
+
2156
+ **Parameters:**
2157
+
2158
+ | Name | Type | Required | Description |
2159
+ |------|------|----------|-------------|
2160
+ | `data` | `TelegramData` | Yes | Telegram authentication data |
2161
+
2162
+ **Returns:** `Promise<void>`
2163
+
2164
+ **Example:**
2165
+
2166
+ ```typescript
2167
+ await client.disconnectTelegram({
2168
+ auth_date: Math.floor(Date.now() / 1000),
2169
+ id: 123456789,
2170
+ first_name: 'John',
2171
+ hash: 'TELEGRAM_HASH',
2172
+ photo_url: 'https://t.me/photo.jpg',
2173
+ username: 'myusername'
2174
+ });
2175
+ ```
2176
+
2177
+ ### Discord
2178
+
2179
+ #### getDiscordConnectionUrl
2180
+
2181
+ Get Discord OAuth URL.
2182
+
2183
+ **Parameters:**
2184
+
2185
+ | Name | Type | Required | Description |
2186
+ |------|------|----------|-------------|
2187
+ | `url` | `string` | Yes | Callback URL |
2188
+
2189
+ **Returns:** `Promise<string>` - Discord OAuth URL
2190
+
2191
+ **Example:**
2192
+
2193
+ ```typescript
2194
+ const discordUrl = await client.getDiscordConnectionUrl(
2195
+ 'https://myapp.com/discord-callback'
2196
+ );
2197
+
2198
+ window.open(discordUrl, '_blank');
2199
+ ```
2200
+
2201
+ #### disconnectDiscord
2202
+
2203
+ Disconnect Discord account.
2204
+
2205
+ **Returns:** `Promise<void>`
2206
+
2207
+ **Example:**
2208
+
2209
+ ```typescript
2210
+ await client.disconnectDiscord();
2211
+ ```
2212
+
2213
+ ### Twitter
2214
+
2215
+ #### getTwitterConnectionUrl
2216
+
2217
+ Get Twitter OAuth URL.
2218
+
2219
+ **Parameters:**
2220
+
2221
+ | Name | Type | Required | Description |
2222
+ |------|------|----------|-------------|
2223
+ | `appUrl` | `string` | Yes | Callback URL |
2224
+ | `permissions` | `string` | No | OAuth scopes |
2225
+
2226
+ **Returns:** `Promise<string>` - Twitter OAuth URL
2227
+
2228
+ **Example:**
2229
+
2230
+ ```typescript
2231
+ const twitterUrl = await client.getTwitterConnectionUrl(
2232
+ 'https://myapp.com/twitter-callback',
2233
+ 'tweet.read tweet.write'
2234
+ );
2235
+
2236
+ window.open(twitterUrl, '_blank');
2237
+ ```
2238
+
2239
+ #### disconnectTwitter
2240
+
2241
+ Disconnect Twitter account.
2242
+
2243
+ **Returns:** `Promise<void>`
2244
+
2245
+ **Example:**
2246
+
2247
+ ```typescript
2248
+ await client.disconnectTwitter();
2249
+ ```
2250
+
2251
+ #### getTweets
2252
+
2253
+ Get company tweets for interaction.
2254
+
2255
+ **Returns:** `Promise<ICompanyTweet[]>`
2256
+
2257
+ **ICompanyTweet interface:**
2258
+
2259
+ | Property | Type | Description |
2260
+ |----------|------|-------------|
2261
+ | `id` | `string` | Tweet ID |
2262
+ | `companyId` | `number` | Company ID |
2263
+ | `seasonId` | `number` | Season ID |
2264
+ | `type` | `string` | Tweet type |
2265
+ | `text` | `string` | Tweet text |
2266
+ | `enabled` | `boolean` | Whether tweet is enabled |
2267
+ | `isProcessed` | `boolean` | Processing status |
2268
+ | `expiresAt` | `Date` | Expiration date |
2269
+ | `createdAt` | `Date` | Creation timestamp |
2270
+ | `updatedAt` | `Date` | Update timestamp |
2271
+
2272
+ **Example:**
2273
+
2274
+ ```typescript
2275
+ const tweets = await client.getTweets();
2276
+
2277
+ tweets.forEach(tweet => {
2278
+ console.log('Tweet:', tweet.text);
2279
+ console.log('Type:', tweet.type);
2280
+ console.log('Enabled:', tweet.enabled);
2281
+ console.log('Expires:', tweet.expiresAt);
2282
+ });
2283
+ ```
2284
+
2285
+ #### actionWithTweet
2286
+
2287
+ Perform actions on a tweet.
2288
+
2289
+ **Parameters:**
2290
+
2291
+ | Name | Type | Required | Description |
2292
+ |------|------|----------|-------------|
2293
+ | `data` | `{ actions: Array<{ id: number; text?: string }>; tweetId?: string }` | Yes | Action data object |
2294
+
2295
+ **Returns:** `Promise<void>`
2296
+
2297
+ **Example:**
2298
+
2299
+ ```typescript
2300
+ await client.actionWithTweet({
2301
+ actions: [
2302
+ { id: 1 }, // Like
2303
+ { id: 2, text: 'Great project!' } // Comment
2304
+ ],
2305
+ tweetId: 'TWEET_ID'
2306
+ });
2307
+ ```
2308
+
2309
+ #### getActions
2310
+
2311
+ Get available social actions.
2312
+
2313
+ **Returns:** `Promise<IAction[]>`
2314
+
2315
+ **Example:**
2316
+
2317
+ ```typescript
2318
+ const actions = await client.getActions();
2319
+
2320
+ actions.forEach(action => {
2321
+ console.log(`${action.name}: ${action.points} points`);
2322
+ });
2323
+ ```
2324
+
2325
+ #### getActionHistory
2326
+
2327
+ Get user's action history.
2328
+
2329
+ **Returns:** `Promise<IActionHistory[]>`
2330
+
2331
+ **IActionHistory interface:**
2332
+
2333
+ | Property | Type | Description |
2334
+ |----------|------|-------------|
2335
+ | `id` | `number` | History entry ID |
2336
+ | `address` | `string` | Wallet address |
2337
+ | `companyId` | `number` | Company ID |
2338
+ | `actionId` | `number` | Action ID |
2339
+ | `seasonId` | `number` | Season ID |
2340
+ | `source` | `string` | Action source |
2341
+ | `points` | `number` | Points earned |
2342
+ | `referenceId` | `string` | Reference ID (optional) |
2343
+ | `createdAt` | `Date` | Creation timestamp |
2344
+
2345
+ **Example:**
2346
+
2347
+ ```typescript
2348
+ const history = await client.getActionHistory();
2349
+
2350
+ history.forEach(item => {
2351
+ console.log(`Action ${item.actionId} - ${item.points} points - ${item.source}`);
2352
+ console.log(`Date: ${item.createdAt}`);
2353
+ });
2354
+ ```
2355
+
2356
+ #### getAIStyles
2357
+
2358
+ Get available AI comment styles.
2359
+
2360
+ **Returns:** `Promise<IAIStyle[]>`
2361
+
2362
+ **IAIStyle interface:**
2363
+
2364
+ | Property | Type | Description |
2365
+ |----------|------|-------------|
2366
+ | `id` | `number` | Style ID |
2367
+ | `title` | `string` | Style title |
2368
+ | `content` | `string` | Style content |
2369
+ | `enabled` | `boolean` | Whether style is enabled |
2370
+ | `type` | `string` | Style type |
2371
+ | `createdAt` | `Date` | Creation timestamp |
2372
+ | `updatedAt` | `Date` | Update timestamp |
2373
+
2374
+ **Example:**
2375
+
2376
+ ```typescript
2377
+ const styles = await client.getAIStyles();
2378
+
2379
+ styles.forEach(style => {
2380
+ console.log(`${style.title}: ${style.content}`);
2381
+ console.log(`Type: ${style.type}, Enabled: ${style.enabled}`);
2382
+ });
2383
+ ```
2384
+
2385
+ #### getAIComment
2386
+
2387
+ Generate AI comment for a tweet.
2388
+
2389
+ **Parameters:**
2390
+
2391
+ | Name | Type | Required | Description |
2392
+ |------|------|----------|-------------|
2393
+ | `styleId` | `number` | Yes | AI style ID |
2394
+ | `tweetId` | `string` | Yes | Tweet ID |
2395
+
2396
+ **Returns:** `Promise<IAIGeneratedComment>`
2397
+
2398
+ **Example:**
2399
+
2400
+ ```typescript
2401
+ const comment = await client.getAIComment(1, 'TWEET_ID');
2402
+
2403
+ console.log('Generated comment:', comment.comment);
2404
+ console.log('Requests left:', comment.requestsLeft);
2405
+ ```
2406
+
2407
+ ---
2408
+
29
2409
  ## Structure
30
2410
 
31
2411
  ```
@@ -90,7 +2470,6 @@ Defined in `tsconfig.alias.json`:
90
2470
 
91
2471
  | Alias | Path | Description |
92
2472
  |-------|------|-------------|
93
- | `@ultrade/shared/browser/*` | `../shared/dist/browser/*` | Browser-specific shared utilities |
94
2473
  | `@utils` | `./src/utils/index.ts` | Utility functions |
95
2474
  | `@interface` | `./src/interface/index.ts` | TypeScript interfaces |
96
2475
  | `@const` | `./src/const/index.ts` | Constants |