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