@limitless-exchange/sdk 0.0.3 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -74
- package/dist/index.d.mts +905 -1022
- package/dist/index.d.ts +905 -1022
- package/dist/index.js +477 -833
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +473 -830
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Limitless Exchange TypeScript SDK
|
|
2
2
|
|
|
3
|
+
**v1.0.2 LTS (Long-Term Support)** | Production-Ready | Type-Safe | Fully Documented
|
|
4
|
+
|
|
3
5
|
A TypeScript SDK for interacting with the Limitless Exchange platform, providing type-safe access to CLOB and NegRisk prediction markets.
|
|
4
6
|
|
|
7
|
+
> 🎉 **v1.0.2 LTS Release**: This is the first stable, production-ready release with long-term support. Recommended for all production deployments. See [Changelog](#changelog) for details.
|
|
8
|
+
|
|
5
9
|
## ⚠️ Disclaimer
|
|
6
10
|
|
|
7
11
|
**USE AT YOUR OWN RISK**
|
|
@@ -23,16 +27,22 @@ For production use, we strongly recommend:
|
|
|
23
27
|
3. Monitoring all transactions carefully
|
|
24
28
|
4. Having proper error handling and recovery mechanisms
|
|
25
29
|
|
|
30
|
+
**Feedback Welcome**: We encourage you to report any bugs, suggest improvements, or contribute to the project. Please submit issues or pull requests on our GitHub repository.
|
|
31
|
+
|
|
32
|
+
## 🌍 Geographic Restrictions
|
|
33
|
+
|
|
34
|
+
**Important**: Limitless restricts order placement from US locations due to regulatory requirements and compliance with international sanctions. Before placing orders, builders should verify their location complies with applicable regulations.
|
|
35
|
+
|
|
26
36
|
## Features
|
|
27
37
|
|
|
28
|
-
- ✅ **Authentication**:
|
|
38
|
+
- ✅ **Authentication**: API key authentication with X-API-Key header
|
|
29
39
|
- ✅ **Order Management**: Create, cancel, and manage orders on CLOB and NegRisk markets
|
|
30
40
|
- ✅ **Market Data**: Access real-time market data and orderbooks
|
|
31
41
|
- ✅ **NegRisk Markets**: Full support for group markets with multiple outcomes
|
|
32
42
|
- ✅ **Error Handling & Retry**: Automatic retry logic for rate limits and transient failures
|
|
33
43
|
- ✅ **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
34
44
|
- ✅ **TSDoc Documentation**: Complete API documentation with examples
|
|
35
|
-
- ✅ **WebSocket**: Real-time price and position updates
|
|
45
|
+
- ✅ **WebSocket**: Real-time price and position updates with API key auth
|
|
36
46
|
|
|
37
47
|
## Installation
|
|
38
48
|
|
|
@@ -58,7 +68,6 @@ const httpClient = new HttpClient({
|
|
|
58
68
|
// Optional: Add custom headers to all requests
|
|
59
69
|
additionalHeaders: {
|
|
60
70
|
'X-Custom-Header': 'my-value',
|
|
61
|
-
'X-API-Version': 'v1',
|
|
62
71
|
},
|
|
63
72
|
});
|
|
64
73
|
|
|
@@ -84,37 +93,37 @@ See [examples/project-integration/src/active-markets.ts](./examples/project-inte
|
|
|
84
93
|
|
|
85
94
|
### Authentication
|
|
86
95
|
|
|
87
|
-
|
|
88
|
-
import { ethers } from 'ethers';
|
|
89
|
-
import { HttpClient, MessageSigner, Authenticator } from '@limitless-exchange/sdk';
|
|
96
|
+
The SDK uses API keys for authentication. API keys can be obtained from your Limitless Exchange account settings(Click on User Profile).
|
|
90
97
|
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
```typescript
|
|
99
|
+
import { HttpClient } from '@limitless-exchange/sdk';
|
|
93
100
|
|
|
94
|
-
//
|
|
101
|
+
// Option 1: Automatic from environment variable (recommended)
|
|
102
|
+
// Set LIMITLESS_API_KEY in your .env file
|
|
95
103
|
const httpClient = new HttpClient({
|
|
96
104
|
baseURL: 'https://api.limitless.exchange',
|
|
97
105
|
});
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const result = await authenticator.authenticate({
|
|
104
|
-
client: 'eoa', // 'eoa', 'base', or 'etherspot'
|
|
107
|
+
// Option 2: Explicit API key
|
|
108
|
+
const httpClient = new HttpClient({
|
|
109
|
+
baseURL: 'https://api.limitless.exchange',
|
|
110
|
+
apiKey: process.env.LIMITLESS_API_KEY,
|
|
105
111
|
});
|
|
106
112
|
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
// All requests automatically include X-API-Key header
|
|
114
|
+
// For authenticated endpoints like portfolio, orders, etc.
|
|
109
115
|
```
|
|
110
116
|
|
|
111
|
-
|
|
117
|
+
**Environment Variables:**
|
|
112
118
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
Create a `.env` file:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Required for authenticated endpoints
|
|
123
|
+
LIMITLESS_API_KEY=sk_live_your_api_key_here
|
|
124
|
+
|
|
125
|
+
# Optional: Private key for order signing (EIP-712)
|
|
126
|
+
PRIVATE_KEY=0x...
|
|
118
127
|
```
|
|
119
128
|
|
|
120
129
|
### Token Approvals
|
|
@@ -124,10 +133,12 @@ const result = await authenticator.authenticate({
|
|
|
124
133
|
#### Required Approvals
|
|
125
134
|
|
|
126
135
|
**CLOB Markets:**
|
|
136
|
+
|
|
127
137
|
- **BUY orders**: Approve USDC → `market.venue.exchange`
|
|
128
138
|
- **SELL orders**: Approve Conditional Tokens → `market.venue.exchange`
|
|
129
139
|
|
|
130
140
|
**NegRisk Markets:**
|
|
141
|
+
|
|
131
142
|
- **BUY orders**: Approve USDC → `market.venue.exchange`
|
|
132
143
|
- **SELL orders**: Approve Conditional Tokens → **both** `market.venue.exchange` AND `market.venue.adapter`
|
|
133
144
|
|
|
@@ -195,14 +206,10 @@ const groupMarket = await marketFetcher.getMarket('largest-company-end-of-2025-1
|
|
|
195
206
|
const appleMarket = groupMarket.markets[0];
|
|
196
207
|
const marketDetails = await marketFetcher.getMarket(appleMarket.slug);
|
|
197
208
|
|
|
198
|
-
// 3. Create order client (
|
|
209
|
+
// 3. Create order client (userData fetched automatically from profile)
|
|
199
210
|
const orderClient = new OrderClient({
|
|
200
211
|
httpClient,
|
|
201
212
|
wallet,
|
|
202
|
-
userData: {
|
|
203
|
-
userId: (authResult.profile as any).id,
|
|
204
|
-
feeRateBps: (authResult.profile as any).rank?.feeRateBps || 300,
|
|
205
|
-
},
|
|
206
213
|
});
|
|
207
214
|
|
|
208
215
|
// 4. Place order on submarket (not group!)
|
|
@@ -220,6 +227,53 @@ const order = await orderClient.createOrder({
|
|
|
220
227
|
|
|
221
228
|
For more details, see the [NegRisk Trading Guide](./docs/orders/README.md#negrisk-markets).
|
|
222
229
|
|
|
230
|
+
### FOK Orders (Fill-or-Kill Market Orders)
|
|
231
|
+
|
|
232
|
+
FOK orders execute immediately at the best available price or cancel entirely. Unlike GTC orders that use `price` + `size`, FOK orders use `makerAmount`.
|
|
233
|
+
|
|
234
|
+
**Parameter Semantics**:
|
|
235
|
+
|
|
236
|
+
- **BUY**: `makerAmount` = total USDC to spend
|
|
237
|
+
- **SELL**: `makerAmount` = number of shares to sell
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { OrderClient, Side, OrderType } from '@limitless-exchange/sdk';
|
|
241
|
+
|
|
242
|
+
// BUY FOK - spend 50 USDC at market price
|
|
243
|
+
const buyOrder = await orderClient.createOrder({
|
|
244
|
+
tokenId: marketDetails.tokens.yes,
|
|
245
|
+
makerAmount: 50, // 50 USDC to spend
|
|
246
|
+
side: Side.BUY,
|
|
247
|
+
orderType: OrderType.FOK,
|
|
248
|
+
marketSlug: 'market-slug',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// SELL FOK - sell 120 shares at market price
|
|
252
|
+
const sellOrder = await orderClient.createOrder({
|
|
253
|
+
tokenId: marketDetails.tokens.no,
|
|
254
|
+
makerAmount: 120, // 120 shares to sell
|
|
255
|
+
side: Side.SELL,
|
|
256
|
+
orderType: OrderType.FOK,
|
|
257
|
+
marketSlug: 'market-slug',
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Check execution
|
|
261
|
+
if (buyOrder.makerMatches && buyOrder.makerMatches.length > 0) {
|
|
262
|
+
console.log(`Order filled: ${buyOrder.makerMatches.length} matches`);
|
|
263
|
+
} else {
|
|
264
|
+
console.log('Order cancelled (no liquidity)');
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Key Differences from GTC**:
|
|
269
|
+
|
|
270
|
+
- FOK uses `makerAmount` (not `price` + `size`)
|
|
271
|
+
- Executes immediately or cancels (no orderbook placement)
|
|
272
|
+
- All-or-nothing execution (no partial fills)
|
|
273
|
+
- Best for immediate execution at market price
|
|
274
|
+
|
|
275
|
+
For complete examples, see [docs/code-samples/clob-fok-order.ts](./docs/code-samples/clob-fok-order.ts).
|
|
276
|
+
|
|
223
277
|
### Error Handling & Retry
|
|
224
278
|
|
|
225
279
|
The SDK provides automatic retry logic for handling transient failures like rate limits and server errors:
|
|
@@ -264,54 +318,21 @@ For detailed documentation, see the [Error Handling & Retry Guide](./docs/api/RE
|
|
|
264
318
|
|
|
265
319
|
### Authentication
|
|
266
320
|
|
|
267
|
-
#### `MessageSigner`
|
|
268
|
-
|
|
269
|
-
Handles message signing for authentication.
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
const signer = new MessageSigner(wallet);
|
|
273
|
-
|
|
274
|
-
// Create authentication headers
|
|
275
|
-
const headers = await signer.createAuthHeaders(signingMessage);
|
|
276
|
-
|
|
277
|
-
// Sign EIP-712 typed data
|
|
278
|
-
const signature = await signer.signTypedData(domain, types, value);
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
#### `Authenticator`
|
|
282
|
-
|
|
283
|
-
Manages the authentication flow.
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
const authenticator = new Authenticator(httpClient, signer);
|
|
287
|
-
|
|
288
|
-
// Get signing message
|
|
289
|
-
const message = await authenticator.getSigningMessage();
|
|
290
|
-
|
|
291
|
-
// Authenticate
|
|
292
|
-
const result = await authenticator.authenticate({ client: 'eoa' });
|
|
293
|
-
|
|
294
|
-
// Verify authentication
|
|
295
|
-
const address = await authenticator.verifyAuth(sessionCookie);
|
|
296
|
-
|
|
297
|
-
// Logout
|
|
298
|
-
await authenticator.logout(sessionCookie);
|
|
299
|
-
```
|
|
300
|
-
|
|
301
321
|
#### `HttpClient`
|
|
302
322
|
|
|
303
|
-
HTTP client with
|
|
323
|
+
HTTP client with API key authentication.
|
|
304
324
|
|
|
305
325
|
```typescript
|
|
306
326
|
const httpClient = new HttpClient({
|
|
307
327
|
baseURL: 'https://api.limitless.exchange',
|
|
328
|
+
apiKey: process.env.LIMITLESS_API_KEY, // Optional - auto-loads from env
|
|
308
329
|
timeout: 30000,
|
|
309
330
|
});
|
|
310
331
|
|
|
311
|
-
// Set
|
|
312
|
-
httpClient.
|
|
332
|
+
// Set or update API key
|
|
333
|
+
httpClient.setApiKey('sk_live_...');
|
|
313
334
|
|
|
314
|
-
// Make requests
|
|
335
|
+
// Make requests - X-API-Key header automatically included
|
|
315
336
|
const data = await httpClient.get('/endpoint');
|
|
316
337
|
await httpClient.post('/endpoint', { data });
|
|
317
338
|
```
|
|
@@ -321,10 +342,10 @@ await httpClient.post('/endpoint', { data });
|
|
|
321
342
|
For detailed documentation, see the [docs](./docs) directory:
|
|
322
343
|
|
|
323
344
|
- **[Complete Documentation](./docs/README.md)** - Full SDK documentation
|
|
324
|
-
- **[Authentication Guide](./docs/
|
|
345
|
+
- **[Authentication Guide](./docs/api/README.md)** - API key authentication and HTTP client
|
|
325
346
|
- **[Trading & Orders](./docs/orders/README.md)** - Order creation, management, and NegRisk markets
|
|
326
347
|
- **[Market Data](./docs/markets/README.md)** - Market discovery and orderbook access
|
|
327
|
-
- **[Portfolio & Positions](./docs/portfolio/README.md)** - Position tracking and
|
|
348
|
+
- **[Portfolio & Positions](./docs/portfolio/README.md)** - Position tracking and user history
|
|
328
349
|
- **[WebSocket Streaming](./docs/websocket/README.md)** - Real-time data updates
|
|
329
350
|
- **[Error Handling & Retry](./docs/api/README.md)** - API error handling and retry mechanisms
|
|
330
351
|
- **[Logging](./docs/logging/LOGGING.md)** - Logging configuration
|
|
@@ -335,8 +356,7 @@ Production-ready code samples are available in [docs/code-samples](./docs/code-s
|
|
|
335
356
|
|
|
336
357
|
### Authentication Examples
|
|
337
358
|
|
|
338
|
-
- `basic-auth.ts` -
|
|
339
|
-
- `smart-wallet.ts` - Etherspot smart wallet integration
|
|
359
|
+
- `basic-auth.ts` - API key authentication setup
|
|
340
360
|
- `with-logging.ts` - Authentication with custom logging
|
|
341
361
|
- `auth-retry.ts` - Authentication with retry logic
|
|
342
362
|
- `error-handling.ts` - Comprehensive error handling
|
|
@@ -395,11 +415,12 @@ src/
|
|
|
395
415
|
├── types/ # TypeScript type definitions
|
|
396
416
|
│ ├── markets.ts # Market and active markets types
|
|
397
417
|
│ ├── orders.ts # Order types
|
|
398
|
-
│ ├── auth.ts #
|
|
418
|
+
│ ├── auth.ts # User profile types
|
|
399
419
|
│ └── ...
|
|
400
|
-
├──
|
|
401
|
-
│ ├──
|
|
402
|
-
│
|
|
420
|
+
├── api/ # HTTP client and API utilities
|
|
421
|
+
│ ├── http.ts # HTTP client with API key auth
|
|
422
|
+
│ ├── errors.ts # Error handling
|
|
423
|
+
│ └── retry.ts # Retry logic
|
|
403
424
|
├── markets/ # Market data modules
|
|
404
425
|
│ ├── fetcher.ts # Market and orderbook fetching
|
|
405
426
|
│ └── index.ts
|
|
@@ -428,6 +449,65 @@ docs/
|
|
|
428
449
|
|
|
429
450
|
```
|
|
430
451
|
|
|
452
|
+
## Changelog
|
|
453
|
+
|
|
454
|
+
### v1.0.2 (LTS - Long-Term Support Release)
|
|
455
|
+
|
|
456
|
+
**Release Date**: January 2026
|
|
457
|
+
|
|
458
|
+
This is the first stable, production-ready release of the Limitless Exchange TypeScript SDK, designated as a Long-Term Support (LTS) version.
|
|
459
|
+
|
|
460
|
+
#### Highlights
|
|
461
|
+
|
|
462
|
+
- ✅ **Production-Ready**: Thoroughly tested and validated against Base mainnet
|
|
463
|
+
- 🔒 **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
464
|
+
- 📚 **Well-Documented**: 17 production-ready code samples + comprehensive guides
|
|
465
|
+
- ⚡ **Performance Optimized**: Venue caching system and connection pooling
|
|
466
|
+
- 🔄 **Robust Error Handling**: Automatic retry logic with multiple strategies
|
|
467
|
+
- 🌐 **Real-Time Updates**: WebSocket support for orderbook and position streaming
|
|
468
|
+
- 🎯 **NegRisk Support**: Full support for group markets with multiple outcomes
|
|
469
|
+
|
|
470
|
+
#### Core Features
|
|
471
|
+
|
|
472
|
+
- **Authentication**: API key authentication, EIP-712 signing, EOA support
|
|
473
|
+
- **Market Data**: Active markets with sorting, orderbook access, venue caching
|
|
474
|
+
- **Order Management**: GTC and FOK orders, tick alignment, automatic signing
|
|
475
|
+
- **Portfolio**: Position tracking, user history
|
|
476
|
+
- **WebSocket**: Real-time orderbook, price updates, event streaming
|
|
477
|
+
- **Error Handling**: Decorator and wrapper retry patterns, configurable strategies
|
|
478
|
+
- **Token Approvals**: Complete setup script, CLOB and NegRisk workflows
|
|
479
|
+
|
|
480
|
+
#### Documentation Enhancements (v1.0.2)
|
|
481
|
+
|
|
482
|
+
- Added FOK order examples to README with clear `makerAmount` semantics
|
|
483
|
+
- Created comprehensive CHANGELOG.md following Keep a Changelog format
|
|
484
|
+
- All 17 code samples include step-by-step comments and error handling
|
|
485
|
+
- Detailed guides for authentication, trading, markets, portfolio, and WebSocket
|
|
486
|
+
|
|
487
|
+
For complete release notes, see [CHANGELOG.md](./CHANGELOG.md).
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### Pre-Release Versions
|
|
492
|
+
|
|
493
|
+
- **v0.0.3** - WebSocket streaming, enhanced code samples, NegRisk examples
|
|
494
|
+
- **v0.0.2** - Venue caching, retry mechanisms, portfolio fetcher
|
|
495
|
+
- **v0.0.1** - Initial release with core functionality
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## LTS Support Policy
|
|
500
|
+
|
|
501
|
+
**v1.0.2 LTS** will receive:
|
|
502
|
+
|
|
503
|
+
- Security updates and critical bug fixes
|
|
504
|
+
- Compatibility maintenance with Limitless Exchange API
|
|
505
|
+
- Community support and issue resolution
|
|
506
|
+
- Documentation updates and improvements
|
|
507
|
+
- Long-term stability for production deployments
|
|
508
|
+
|
|
509
|
+
**Recommended for production use.** We commit to maintaining backward compatibility and providing timely security updates for this LTS release.
|
|
510
|
+
|
|
431
511
|
## License
|
|
432
512
|
|
|
433
513
|
MIT - See [LICENSE](./LICENSE) file for details
|