@limitless-exchange/sdk 1.0.3 → 1.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 +105 -33
- package/dist/index.d.mts +479 -51
- package/dist/index.d.ts +479 -51
- package/dist/index.js +550 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +539 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -167,63 +167,113 @@ interface UserData {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
171
|
-
* Allows users to inject their own logging implementation.
|
|
172
|
-
*
|
|
170
|
+
* API token, HMAC auth, and partner capability types.
|
|
173
171
|
* @public
|
|
174
172
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
*/
|
|
183
|
-
info(message: string, meta?: Record<string, any>): void;
|
|
184
|
-
/**
|
|
185
|
-
* Log warning messages
|
|
186
|
-
*/
|
|
187
|
-
warn(message: string, meta?: Record<string, any>): void;
|
|
188
|
-
/**
|
|
189
|
-
* Log error messages
|
|
190
|
-
*/
|
|
191
|
-
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
173
|
+
/**
|
|
174
|
+
* HMAC credentials for scoped API-token authentication.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
interface HMACCredentials {
|
|
178
|
+
tokenId: string;
|
|
179
|
+
secret: string;
|
|
192
180
|
}
|
|
193
181
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* @internal
|
|
182
|
+
* Profile reference embedded in API-token responses.
|
|
183
|
+
* @public
|
|
198
184
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
warn(): void;
|
|
203
|
-
error(): void;
|
|
185
|
+
interface ApiTokenProfile {
|
|
186
|
+
id: number;
|
|
187
|
+
account: string;
|
|
204
188
|
}
|
|
205
189
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```typescript
|
|
211
|
-
* import { ConsoleLogger } from '@limitless-exchange/sdk';
|
|
212
|
-
*
|
|
213
|
-
* const logger = new ConsoleLogger('debug');
|
|
214
|
-
* const authenticator = new Authenticator(httpClient, signer, logger);
|
|
215
|
-
* ```
|
|
216
|
-
*
|
|
190
|
+
* Request payload for self-service token derivation.
|
|
191
|
+
* `label` is token metadata only and does not affect any profile display name.
|
|
217
192
|
* @public
|
|
218
193
|
*/
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
194
|
+
interface DeriveApiTokenInput {
|
|
195
|
+
label?: string;
|
|
196
|
+
scopes?: string[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* One-time token derivation response.
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
interface DeriveApiTokenResponse {
|
|
203
|
+
apiKey: string;
|
|
204
|
+
secret: string;
|
|
205
|
+
tokenId: string;
|
|
206
|
+
createdAt: string;
|
|
207
|
+
scopes: string[];
|
|
208
|
+
profile: ApiTokenProfile;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Active token list item.
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
interface ApiToken {
|
|
215
|
+
tokenId: string;
|
|
216
|
+
label: string | null;
|
|
217
|
+
scopes: string[];
|
|
218
|
+
createdAt: string;
|
|
219
|
+
lastUsedAt: string | null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Partner self-service capability config.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
interface PartnerCapabilities {
|
|
226
|
+
partnerProfileId: number;
|
|
227
|
+
tokenManagementEnabled: boolean;
|
|
228
|
+
allowedScopes: string[];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Update partner capabilities request.
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
interface UpdatePartnerCapabilitiesInput {
|
|
235
|
+
tokenManagementEnabled: boolean;
|
|
236
|
+
allowedScopes: string[];
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Scope constants.
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
declare const ScopeTrading = "trading";
|
|
243
|
+
declare const ScopeAccountCreation = "account_creation";
|
|
244
|
+
declare const ScopeDelegatedSigning = "delegated_signing";
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Partner-account creation types.
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
/**
|
|
251
|
+
* Partner-owned profile creation payload.
|
|
252
|
+
* `displayName` is the public profile name for the created partner account.
|
|
253
|
+
* If omitted, the backend defaults it to the created or verified account address.
|
|
254
|
+
* The backend currently enforces a maximum length of 44 characters.
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
interface CreatePartnerAccountInput {
|
|
258
|
+
displayName?: string;
|
|
259
|
+
createServerWallet?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* EOA verification headers for partner-account creation.
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
interface CreatePartnerAccountEOAHeaders {
|
|
266
|
+
account: string;
|
|
267
|
+
signingMessage: string;
|
|
268
|
+
signature: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Partner-account creation response.
|
|
272
|
+
* @public
|
|
273
|
+
*/
|
|
274
|
+
interface PartnerAccountResponse {
|
|
275
|
+
profileId: number;
|
|
276
|
+
account: string;
|
|
227
277
|
}
|
|
228
278
|
|
|
229
279
|
/**
|
|
@@ -245,6 +295,8 @@ declare enum Side {
|
|
|
245
295
|
declare enum OrderType {
|
|
246
296
|
/** Fill-or-Kill: Execute immediately or cancel */
|
|
247
297
|
FOK = "FOK",
|
|
298
|
+
/** Fill-And-Kill: Limit-like order that fills what it can and kills the remainder */
|
|
299
|
+
FAK = "FAK",
|
|
248
300
|
/** Good-Til-Cancelled: Remain on orderbook until filled or cancelled */
|
|
249
301
|
GTC = "GTC"
|
|
250
302
|
}
|
|
@@ -374,12 +426,49 @@ interface GTCOrderArgs extends BaseOrderArgs {
|
|
|
374
426
|
* Number of shares to trade
|
|
375
427
|
*/
|
|
376
428
|
size: number;
|
|
429
|
+
/**
|
|
430
|
+
* When true, rejects the order if it would immediately match.
|
|
431
|
+
* Supported only for GTC orders.
|
|
432
|
+
* @defaultValue false
|
|
433
|
+
*/
|
|
434
|
+
postOnly?: boolean;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Arguments for FAK (Fill-And-Kill) limit orders.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* FAK orders use the same price/size construction as GTC, but the unmatched
|
|
441
|
+
* remainder is killed instead of resting on the orderbook. PostOnly is not
|
|
442
|
+
* supported for FAK and is rejected by the API.
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```typescript
|
|
446
|
+
* // BUY: Fill up to 10 shares at 0.55 price, kill remainder
|
|
447
|
+
* {
|
|
448
|
+
* tokenId: '123...',
|
|
449
|
+
* price: 0.55,
|
|
450
|
+
* size: 10,
|
|
451
|
+
* side: Side.BUY
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
interface FAKOrderArgs extends BaseOrderArgs {
|
|
458
|
+
/**
|
|
459
|
+
* Price per share (0.0 to 1.0)
|
|
460
|
+
*/
|
|
461
|
+
price: number;
|
|
462
|
+
/**
|
|
463
|
+
* Number of shares to trade
|
|
464
|
+
*/
|
|
465
|
+
size: number;
|
|
377
466
|
}
|
|
378
467
|
/**
|
|
379
468
|
* Union type for all order arguments.
|
|
380
469
|
* @public
|
|
381
470
|
*/
|
|
382
|
-
type OrderArgs = FOKOrderArgs | GTCOrderArgs;
|
|
471
|
+
type OrderArgs = FOKOrderArgs | GTCOrderArgs | FAKOrderArgs;
|
|
383
472
|
/**
|
|
384
473
|
* Unsigned order payload.
|
|
385
474
|
* @public
|
|
@@ -469,6 +558,11 @@ interface NewOrderPayload {
|
|
|
469
558
|
* Owner ID from user profile
|
|
470
559
|
*/
|
|
471
560
|
ownerId: number;
|
|
561
|
+
/**
|
|
562
|
+
* When true, rejects the order if it would immediately match.
|
|
563
|
+
* Supported only for GTC orders.
|
|
564
|
+
*/
|
|
565
|
+
postOnly?: boolean;
|
|
472
566
|
}
|
|
473
567
|
/**
|
|
474
568
|
* Clean order data returned from API.
|
|
@@ -506,8 +600,11 @@ interface CreatedOrder {
|
|
|
506
600
|
signatureType: number;
|
|
507
601
|
/**
|
|
508
602
|
* Unique salt for order identification
|
|
603
|
+
*
|
|
604
|
+
* @remarks
|
|
605
|
+
* May be returned as a string when value exceeds JavaScript safe integer range.
|
|
509
606
|
*/
|
|
510
|
-
salt: number;
|
|
607
|
+
salt: number | string;
|
|
511
608
|
/**
|
|
512
609
|
* Maker address
|
|
513
610
|
*/
|
|
@@ -615,6 +712,122 @@ interface OrderSigningConfig {
|
|
|
615
712
|
contractAddress: string;
|
|
616
713
|
}
|
|
617
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Delegated-order creation parameters.
|
|
717
|
+
* @public
|
|
718
|
+
*/
|
|
719
|
+
interface CreateDelegatedOrderParams {
|
|
720
|
+
marketSlug: string;
|
|
721
|
+
orderType: OrderType;
|
|
722
|
+
onBehalfOf: number;
|
|
723
|
+
feeRateBps?: number;
|
|
724
|
+
args: OrderArgs;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Order submission payload where signature may be omitted.
|
|
728
|
+
* @public
|
|
729
|
+
*/
|
|
730
|
+
interface DelegatedOrderSubmission {
|
|
731
|
+
salt: number;
|
|
732
|
+
maker: string;
|
|
733
|
+
signer: string;
|
|
734
|
+
taker: string;
|
|
735
|
+
tokenId: string;
|
|
736
|
+
makerAmount: number;
|
|
737
|
+
takerAmount: number;
|
|
738
|
+
expiration: string;
|
|
739
|
+
nonce: number;
|
|
740
|
+
feeRateBps: number;
|
|
741
|
+
side: Side;
|
|
742
|
+
signatureType: SignatureType;
|
|
743
|
+
price?: number;
|
|
744
|
+
signature?: string;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* POST /orders payload for delegated flows.
|
|
748
|
+
* @public
|
|
749
|
+
*/
|
|
750
|
+
interface CreateDelegatedOrderRequest {
|
|
751
|
+
order: DelegatedOrderSubmission;
|
|
752
|
+
orderType: OrderType;
|
|
753
|
+
marketSlug: string;
|
|
754
|
+
ownerId: number;
|
|
755
|
+
onBehalfOf?: number;
|
|
756
|
+
postOnly?: boolean;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Cancel endpoint response.
|
|
760
|
+
* @public
|
|
761
|
+
*/
|
|
762
|
+
interface CancelResponse {
|
|
763
|
+
message: string;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Re-export of the normal order response for delegated-create helpers.
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
type DelegatedOrderResponse = OrderResponse;
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Logger interface for SDK integration.
|
|
773
|
+
* Allows users to inject their own logging implementation.
|
|
774
|
+
*
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
interface ILogger {
|
|
778
|
+
/**
|
|
779
|
+
* Log debug information (verbose, development only)
|
|
780
|
+
*/
|
|
781
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
782
|
+
/**
|
|
783
|
+
* Log informational messages
|
|
784
|
+
*/
|
|
785
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
786
|
+
/**
|
|
787
|
+
* Log warning messages
|
|
788
|
+
*/
|
|
789
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
790
|
+
/**
|
|
791
|
+
* Log error messages
|
|
792
|
+
*/
|
|
793
|
+
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* No-op logger (default) - does nothing.
|
|
797
|
+
* Zero performance overhead when logging is not needed.
|
|
798
|
+
*
|
|
799
|
+
* @internal
|
|
800
|
+
*/
|
|
801
|
+
declare class NoOpLogger implements ILogger {
|
|
802
|
+
debug(): void;
|
|
803
|
+
info(): void;
|
|
804
|
+
warn(): void;
|
|
805
|
+
error(): void;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Simple console logger for development.
|
|
809
|
+
* Can be used as a starting point or for debugging.
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* import { ConsoleLogger } from '@limitless-exchange/sdk';
|
|
814
|
+
*
|
|
815
|
+
* const logger = new ConsoleLogger('debug');
|
|
816
|
+
* const authenticator = new Authenticator(httpClient, signer, logger);
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* @public
|
|
820
|
+
*/
|
|
821
|
+
declare class ConsoleLogger implements ILogger {
|
|
822
|
+
private level;
|
|
823
|
+
constructor(level?: 'debug' | 'info' | 'warn' | 'error');
|
|
824
|
+
private shouldLog;
|
|
825
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
826
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
827
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
828
|
+
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
829
|
+
}
|
|
830
|
+
|
|
618
831
|
/**
|
|
619
832
|
* Portfolio and position types for Limitless Exchange.
|
|
620
833
|
* @module types/portfolio
|
|
@@ -1582,6 +1795,13 @@ interface WebSocketConfig {
|
|
|
1582
1795
|
* and the LIMITLESS_API_KEY environment variable.
|
|
1583
1796
|
*/
|
|
1584
1797
|
apiKey?: string;
|
|
1798
|
+
/**
|
|
1799
|
+
* HMAC credentials for authenticated subscriptions.
|
|
1800
|
+
*
|
|
1801
|
+
* @remarks
|
|
1802
|
+
* When configured alongside `apiKey`, this client uses HMAC headers for authenticated subscriptions.
|
|
1803
|
+
*/
|
|
1804
|
+
hmacCredentials?: HMACCredentials;
|
|
1585
1805
|
/**
|
|
1586
1806
|
* Auto-reconnect on connection loss (default: true)
|
|
1587
1807
|
*/
|
|
@@ -1769,6 +1989,42 @@ interface TransactionEvent {
|
|
|
1769
1989
|
/** Trade side (optional) */
|
|
1770
1990
|
side?: 'BUY' | 'SELL';
|
|
1771
1991
|
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Market-created websocket event payload.
|
|
1994
|
+
*
|
|
1995
|
+
* @public
|
|
1996
|
+
*/
|
|
1997
|
+
interface MarketCreatedEvent {
|
|
1998
|
+
/** Market slug identifier */
|
|
1999
|
+
slug: string;
|
|
2000
|
+
/** Human-readable market title */
|
|
2001
|
+
title: string;
|
|
2002
|
+
/** Market venue type */
|
|
2003
|
+
type: 'AMM' | 'CLOB';
|
|
2004
|
+
/** Group market slug when this market belongs to a group */
|
|
2005
|
+
groupSlug?: string;
|
|
2006
|
+
/** Category identifiers when provided by the backend */
|
|
2007
|
+
categoryIds?: number[];
|
|
2008
|
+
/** Market creation timestamp */
|
|
2009
|
+
createdAt: Date | number | string;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Market-resolved websocket event payload.
|
|
2013
|
+
*
|
|
2014
|
+
* @public
|
|
2015
|
+
*/
|
|
2016
|
+
interface MarketResolvedEvent {
|
|
2017
|
+
/** Market slug identifier */
|
|
2018
|
+
slug: string;
|
|
2019
|
+
/** Market venue type */
|
|
2020
|
+
type: 'AMM' | 'CLOB';
|
|
2021
|
+
/** Winning outcome label */
|
|
2022
|
+
winningOutcome: 'YES' | 'NO';
|
|
2023
|
+
/** Winning outcome index */
|
|
2024
|
+
winningIndex: 0 | 1;
|
|
2025
|
+
/** Resolution timestamp */
|
|
2026
|
+
resolutionDate: Date | number | string;
|
|
2027
|
+
}
|
|
1772
2028
|
/**
|
|
1773
2029
|
* WebSocket event types.
|
|
1774
2030
|
* @public
|
|
@@ -1814,6 +2070,14 @@ interface WebSocketEvents {
|
|
|
1814
2070
|
* Market updates
|
|
1815
2071
|
*/
|
|
1816
2072
|
market: (data: MarketUpdate) => void;
|
|
2073
|
+
/**
|
|
2074
|
+
* Market-created lifecycle events.
|
|
2075
|
+
*/
|
|
2076
|
+
marketCreated: (data: MarketCreatedEvent) => void;
|
|
2077
|
+
/**
|
|
2078
|
+
* Market-resolved lifecycle events.
|
|
2079
|
+
*/
|
|
2080
|
+
marketResolved: (data: MarketResolvedEvent) => void;
|
|
1817
2081
|
/**
|
|
1818
2082
|
* Position updates
|
|
1819
2083
|
*/
|
|
@@ -1879,6 +2143,13 @@ interface HttpClientConfig {
|
|
|
1879
2143
|
* Required for authenticated endpoints (portfolio, orders, etc.)
|
|
1880
2144
|
*/
|
|
1881
2145
|
apiKey?: string;
|
|
2146
|
+
/**
|
|
2147
|
+
* HMAC credentials for scoped API-token authentication.
|
|
2148
|
+
*
|
|
2149
|
+
* @remarks
|
|
2150
|
+
* When configured alongside `apiKey`, this client uses HMAC headers for authenticated requests.
|
|
2151
|
+
*/
|
|
2152
|
+
hmacCredentials?: HMACCredentials;
|
|
1882
2153
|
/**
|
|
1883
2154
|
* Optional logger for debugging
|
|
1884
2155
|
* @defaultValue NoOpLogger (no logging)
|
|
@@ -1967,6 +2238,7 @@ interface HttpRawResponse<T = any> {
|
|
|
1967
2238
|
declare class HttpClient {
|
|
1968
2239
|
private client;
|
|
1969
2240
|
private apiKey?;
|
|
2241
|
+
private hmacCredentials?;
|
|
1970
2242
|
private logger;
|
|
1971
2243
|
/**
|
|
1972
2244
|
* Creates a new HTTP client instance.
|
|
@@ -1995,10 +2267,39 @@ declare class HttpClient {
|
|
|
1995
2267
|
* @param apiKey - API key value
|
|
1996
2268
|
*/
|
|
1997
2269
|
setApiKey(apiKey: string): void;
|
|
2270
|
+
/**
|
|
2271
|
+
* Returns the configured API key, if any.
|
|
2272
|
+
*/
|
|
2273
|
+
getApiKey(): string | undefined;
|
|
1998
2274
|
/**
|
|
1999
2275
|
* Clears the API key.
|
|
2000
2276
|
*/
|
|
2001
2277
|
clearApiKey(): void;
|
|
2278
|
+
/**
|
|
2279
|
+
* Sets HMAC credentials for scoped API-token authentication.
|
|
2280
|
+
*/
|
|
2281
|
+
setHMACCredentials(credentials: HMACCredentials): void;
|
|
2282
|
+
/**
|
|
2283
|
+
* Clears HMAC credentials.
|
|
2284
|
+
*/
|
|
2285
|
+
clearHMACCredentials(): void;
|
|
2286
|
+
/**
|
|
2287
|
+
* Returns a copy of the configured HMAC credentials, if any.
|
|
2288
|
+
*/
|
|
2289
|
+
getHMACCredentials(): HMACCredentials | undefined;
|
|
2290
|
+
/**
|
|
2291
|
+
* Returns the logger attached to this HTTP client.
|
|
2292
|
+
*/
|
|
2293
|
+
getLogger(): ILogger;
|
|
2294
|
+
/**
|
|
2295
|
+
* Returns true when cookie/header-based auth is configured on the underlying client.
|
|
2296
|
+
* This is primarily used for custom authenticated flows that don't use API keys or HMAC.
|
|
2297
|
+
*/
|
|
2298
|
+
private hasConfiguredHeaderAuth;
|
|
2299
|
+
/**
|
|
2300
|
+
* Ensures the client has some authenticated transport configured.
|
|
2301
|
+
*/
|
|
2302
|
+
requireAuth(operation: string): void;
|
|
2002
2303
|
/**
|
|
2003
2304
|
* Performs a GET request.
|
|
2004
2305
|
*
|
|
@@ -2007,6 +2308,10 @@ declare class HttpClient {
|
|
|
2007
2308
|
* @returns Promise resolving to the response data
|
|
2008
2309
|
*/
|
|
2009
2310
|
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Performs a GET request with identity-token authentication.
|
|
2313
|
+
*/
|
|
2314
|
+
getWithIdentity<T = any>(url: string, identityToken: string, config?: AxiosRequestConfig): Promise<T>;
|
|
2010
2315
|
/**
|
|
2011
2316
|
* Performs a GET request and returns raw response metadata.
|
|
2012
2317
|
*
|
|
@@ -2027,6 +2332,18 @@ declare class HttpClient {
|
|
|
2027
2332
|
* @returns Promise resolving to the response data
|
|
2028
2333
|
*/
|
|
2029
2334
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
2335
|
+
/**
|
|
2336
|
+
* Performs a POST request with identity-token authentication.
|
|
2337
|
+
*/
|
|
2338
|
+
postWithIdentity<T = any>(url: string, identityToken: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
2339
|
+
/**
|
|
2340
|
+
* Performs a POST request with additional per-request headers.
|
|
2341
|
+
*/
|
|
2342
|
+
postWithHeaders<T = any>(url: string, data?: any, headers?: Record<string, string>, config?: AxiosRequestConfig): Promise<T>;
|
|
2343
|
+
/**
|
|
2344
|
+
* Performs a PATCH request.
|
|
2345
|
+
*/
|
|
2346
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
2030
2347
|
/**
|
|
2031
2348
|
* Performs a DELETE request.
|
|
2032
2349
|
*
|
|
@@ -2039,6 +2356,9 @@ declare class HttpClient {
|
|
|
2039
2356
|
* @returns Promise resolving to the response data
|
|
2040
2357
|
*/
|
|
2041
2358
|
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
2359
|
+
private getRequestPath;
|
|
2360
|
+
private getRequestBodyForSignature;
|
|
2361
|
+
private maskSensitiveHeaders;
|
|
2042
2362
|
}
|
|
2043
2363
|
|
|
2044
2364
|
/**
|
|
@@ -2646,6 +2966,58 @@ declare class RetryableClient {
|
|
|
2646
2966
|
[key: string]: any;
|
|
2647
2967
|
}
|
|
2648
2968
|
|
|
2969
|
+
/**
|
|
2970
|
+
* Builds the canonical HMAC message used by the API-token auth flow.
|
|
2971
|
+
* @public
|
|
2972
|
+
*/
|
|
2973
|
+
declare function buildHMACMessage(timestamp: string, method: string, path: string, body: string): string;
|
|
2974
|
+
/**
|
|
2975
|
+
* Computes a base64 HMAC-SHA256 request signature from a base64 secret.
|
|
2976
|
+
* @public
|
|
2977
|
+
*/
|
|
2978
|
+
declare function computeHMACSignature(secret: string, timestamp: string, method: string, path: string, body: string): string;
|
|
2979
|
+
|
|
2980
|
+
/**
|
|
2981
|
+
* Partner self-service API-token operations.
|
|
2982
|
+
* @public
|
|
2983
|
+
*/
|
|
2984
|
+
declare class ApiTokenService {
|
|
2985
|
+
private readonly httpClient;
|
|
2986
|
+
private readonly logger;
|
|
2987
|
+
constructor(httpClient: HttpClient, logger?: ILogger);
|
|
2988
|
+
deriveToken(identityToken: string, input: DeriveApiTokenInput): Promise<DeriveApiTokenResponse>;
|
|
2989
|
+
listTokens(): Promise<ApiToken[]>;
|
|
2990
|
+
getCapabilities(identityToken: string): Promise<PartnerCapabilities>;
|
|
2991
|
+
revokeToken(tokenId: string): Promise<string>;
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* Partner-owned profile creation API.
|
|
2996
|
+
* @public
|
|
2997
|
+
*/
|
|
2998
|
+
declare class PartnerAccountService {
|
|
2999
|
+
private static readonly DISPLAY_NAME_MAX_LENGTH;
|
|
3000
|
+
private readonly httpClient;
|
|
3001
|
+
private readonly logger;
|
|
3002
|
+
constructor(httpClient: HttpClient, logger?: ILogger);
|
|
3003
|
+
createAccount(input: CreatePartnerAccountInput, eoaHeaders?: CreatePartnerAccountEOAHeaders): Promise<PartnerAccountResponse>;
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* Delegated partner-order operations.
|
|
3008
|
+
* @public
|
|
3009
|
+
*/
|
|
3010
|
+
declare class DelegatedOrderService {
|
|
3011
|
+
private readonly httpClient;
|
|
3012
|
+
private readonly logger;
|
|
3013
|
+
constructor(httpClient: HttpClient, logger?: ILogger);
|
|
3014
|
+
createOrder(params: CreateDelegatedOrderParams): Promise<DelegatedOrderResponse>;
|
|
3015
|
+
cancel(orderId: string): Promise<string>;
|
|
3016
|
+
cancelOnBehalfOf(orderId: string, onBehalfOf: number): Promise<string>;
|
|
3017
|
+
cancelAll(marketSlug: string): Promise<string>;
|
|
3018
|
+
cancelAllOnBehalfOf(marketSlug: string, onBehalfOf: number): Promise<string>;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
2649
3021
|
/**
|
|
2650
3022
|
* Default API endpoints and configuration constants.
|
|
2651
3023
|
* @public
|
|
@@ -2719,6 +3091,20 @@ declare const CONTRACT_ADDRESSES: {
|
|
|
2719
3091
|
*/
|
|
2720
3092
|
declare function getContractAddress(contractType: 'USDC' | 'CTF', chainId?: number): string;
|
|
2721
3093
|
|
|
3094
|
+
/**
|
|
3095
|
+
* Numeric parsing helpers for API payloads that may return numbers as strings.
|
|
3096
|
+
*/
|
|
3097
|
+
/**
|
|
3098
|
+
* Converts number-like values to finite numbers.
|
|
3099
|
+
* Returns undefined when value is not numeric.
|
|
3100
|
+
*/
|
|
3101
|
+
declare function toFiniteNumber(value: unknown): number | undefined;
|
|
3102
|
+
/**
|
|
3103
|
+
* Converts number-like values to finite integers.
|
|
3104
|
+
* Returns undefined when value is not a safe integer.
|
|
3105
|
+
*/
|
|
3106
|
+
declare function toFiniteInteger(value: unknown): number | undefined;
|
|
3107
|
+
|
|
2722
3108
|
/**
|
|
2723
3109
|
* Order builder for constructing unsigned order payloads.
|
|
2724
3110
|
* @module orders/builder
|
|
@@ -3689,6 +4075,17 @@ declare class WebSocketClient {
|
|
|
3689
4075
|
* If already connected, this will trigger a reconnection with the new API key.
|
|
3690
4076
|
*/
|
|
3691
4077
|
setApiKey(apiKey: string): void;
|
|
4078
|
+
/**
|
|
4079
|
+
* Sets HMAC credentials for authenticated subscriptions.
|
|
4080
|
+
*
|
|
4081
|
+
* @remarks
|
|
4082
|
+
* When configured alongside `apiKey`, this client uses HMAC headers for authenticated subscriptions.
|
|
4083
|
+
*/
|
|
4084
|
+
setHMACCredentials(hmacCredentials: NonNullable<WebSocketConfig['hmacCredentials']>): void;
|
|
4085
|
+
/**
|
|
4086
|
+
* Clears HMAC credentials.
|
|
4087
|
+
*/
|
|
4088
|
+
clearHMACCredentials(): void;
|
|
3692
4089
|
/**
|
|
3693
4090
|
* Reconnects with new authentication credentials.
|
|
3694
4091
|
* @internal
|
|
@@ -3821,4 +4218,35 @@ declare class WebSocketClient {
|
|
|
3821
4218
|
private getChannelFromKey;
|
|
3822
4219
|
}
|
|
3823
4220
|
|
|
3824
|
-
|
|
4221
|
+
/**
|
|
4222
|
+
* Root OOP entrypoint for the SDK.
|
|
4223
|
+
*
|
|
4224
|
+
* @remarks
|
|
4225
|
+
* This mirrors the Go SDK shape: one shared transport plus composed domain services.
|
|
4226
|
+
*
|
|
4227
|
+
* @public
|
|
4228
|
+
*/
|
|
4229
|
+
declare class Client {
|
|
4230
|
+
http: HttpClient;
|
|
4231
|
+
markets: MarketFetcher;
|
|
4232
|
+
portfolio: PortfolioFetcher;
|
|
4233
|
+
pages: MarketPageFetcher;
|
|
4234
|
+
apiTokens: ApiTokenService;
|
|
4235
|
+
partnerAccounts: PartnerAccountService;
|
|
4236
|
+
delegatedOrders: DelegatedOrderService;
|
|
4237
|
+
constructor(config?: HttpClientConfig);
|
|
4238
|
+
/**
|
|
4239
|
+
* Creates a root client around an existing shared HTTP client.
|
|
4240
|
+
*/
|
|
4241
|
+
static fromHttpClient(httpClient: HttpClient): Client;
|
|
4242
|
+
/**
|
|
4243
|
+
* Creates a regular EIP-712 order client reusing the shared transport and market cache.
|
|
4244
|
+
*/
|
|
4245
|
+
newOrderClient(walletOrPrivateKey: ethers.Wallet | string, config?: Omit<OrderClientConfig, 'httpClient' | 'wallet'>): OrderClient;
|
|
4246
|
+
/**
|
|
4247
|
+
* Creates a WebSocket client reusing shared auth where possible.
|
|
4248
|
+
*/
|
|
4249
|
+
newWebSocketClient(config?: WebSocketConfig): WebSocketClient;
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4252
|
+
export { type AMMPosition, APIError, type ActiveMarketsParams, type ActiveMarketsResponse, type ActiveMarketsSortBy, type AmmPriceEntry, type ApiToken, type ApiTokenProfile, ApiTokenService, AuthenticationError, BASE_SEPOLIA_CHAIN_ID, type BaseOrderArgs, type BreadcrumbItem, type CLOBPosition, CONTRACT_ADDRESSES, type CancelResponse, Client, type CollateralToken, ConsoleLogger, type CreateDelegatedOrderParams, type CreateDelegatedOrderRequest, type CreatePartnerAccountEOAHeaders, type CreatePartnerAccountInput, type CreatedOrder, type CursorPagination, DEFAULT_API_URL, DEFAULT_CHAIN_ID, DEFAULT_WS_URL, type DelegatedOrderResponse, DelegatedOrderService, type DelegatedOrderSubmission, type DeriveApiTokenInput, type DeriveApiTokenResponse, type FAKOrderArgs, type FOKOrderArgs, type FillEvent, type FilterGroup, type FilterGroupOption, type GTCOrderArgs, type HMACCredentials, type HistoryEntry, type HistoryResponse, HttpClient, type HttpClientConfig, type HttpRawResponse, type ILogger, type LatestTrade, Market, type MarketCreatedEvent, type MarketCreator, MarketFetcher, type Market$1 as MarketInterface, type MarketMetadata, type MarketOutcome, type MarketPage, MarketPageFetcher, type MarketPageFilterPrimitive, type MarketPageFilterValue, type MarketPageMarketsCursorResponse, type MarketPageMarketsOffsetResponse, type MarketPageMarketsParams, type MarketPageMarketsResponse, type MarketPageSort, type MarketPageSortField, type MarketResolvedEvent, type MarketSettings, type MarketTokens, type MarketUpdate, type MarketsResponse, type ModeInfo, type NavigationNode, type NewOrderPayload, type NewPriceData, NoOpLogger, type OffsetPagination, type OrderArgs, type OrderBook, OrderBuilder, OrderClient, type OrderClientConfig, type OrderMatch, type OrderResponse, OrderSigner, type OrderSigningConfig, OrderType, type OrderUpdate, OrderValidationError, type OrderbookData, type OrderbookEntry, type OrderbookUpdate, type PartnerAccountResponse, PartnerAccountService, type PartnerCapabilities, PortfolioFetcher, type PortfolioPositionsResponse, type PortfolioSummary, type Position, type PositionMarket, type PositionSide, type PriceOracleMetadata, type PriceUpdate, type PropertyKey, type PropertyOption, RateLimitError, type ReferralData, RetryConfig, type RetryConfigOptions, RetryableClient, SIGNING_MESSAGE_TEMPLATE, ScopeAccountCreation, ScopeDelegatedSigning, ScopeTrading, Side, SignatureType, type SignedOrder, type SubscriptionChannel, type SubscriptionOptions, type TokenBalance, type TradeEvent, type TradePrices, type TradingMode, type TransactionEvent, type UnsignedOrder, type UpdatePartnerCapabilitiesInput, type UserData, type UserProfile, type UserRank, ValidationError, type Venue, WebSocketClient, type WebSocketConfig, type WebSocketEvents, WebSocketState, ZERO_ADDRESS, buildHMACMessage, computeHMACSignature, getContractAddress, retryOnErrors, toFiniteInteger, toFiniteNumber, validateOrderArgs, validateSignedOrder, validateUnsignedOrder, withRetry };
|