@stryke-xyz/premarket-sdk 1.1.4 → 1.1.6
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/dist/cjs/api/orderbook-api/index.js +6 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/shared/types.js +9 -2
- package/dist/esm/api/orderbook-api/index.js +6 -3
- package/dist/esm/package.json +1 -1
- package/dist/esm/shared/types.js +9 -2
- package/dist/types/api/orderbook-api/index.d.ts +8 -5
- package/dist/types/shared/types.d.ts +61 -8
- package/package.json +1 -1
|
@@ -708,7 +708,9 @@ function _ts_generator(thisArg, body) {
|
|
|
708
708
|
// USER POSITION & PNL METHODS
|
|
709
709
|
// ============================================================================
|
|
710
710
|
/**
|
|
711
|
-
* Returns
|
|
711
|
+
* Returns enriched user positions including market name, instrument name,
|
|
712
|
+
* logo, collateral info, PnL, and role (isOPrm / isOpen).
|
|
713
|
+
* Also includes a `grouped` array keyed by market.
|
|
712
714
|
*/ function getUserPositions(userAddress) {
|
|
713
715
|
return _async_to_generator(function() {
|
|
714
716
|
return _ts_generator(this, function(_state) {
|
|
@@ -826,8 +828,9 @@ function _ts_generator(thisArg, body) {
|
|
|
826
828
|
// HISTORY METHODS
|
|
827
829
|
// ============================================================================
|
|
828
830
|
/**
|
|
829
|
-
* Returns grouped user history
|
|
830
|
-
*
|
|
831
|
+
* Returns grouped + enriched user history. Every event carries marketName,
|
|
832
|
+
* instrumentName, logoUri, collateralDecimals, collateralToken, and a `type`
|
|
833
|
+
* discriminator. The `timeline` field is a flat chronological list of all events.
|
|
831
834
|
*/ function getUserHistories(userAddress, opts) {
|
|
832
835
|
return _async_to_generator(function() {
|
|
833
836
|
var limit, marketId, tokenId;
|
package/dist/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@stryke-xyz/premarket-sdk","version":"1.1.
|
|
1
|
+
{"name":"@stryke-xyz/premarket-sdk","version":"1.1.6","type":"commonjs"}
|
package/dist/cjs/shared/types.js
CHANGED
|
@@ -31,10 +31,17 @@ Object.defineProperty(exports, "OrderStatus", {
|
|
|
31
31
|
// ============================================================================
|
|
32
32
|
// POSITION & PNL TYPES
|
|
33
33
|
// ============================================================================
|
|
34
|
-
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */
|
|
34
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ /**
|
|
35
|
+
* Market/instrument metadata the API attaches to positions and history events.
|
|
36
|
+
* All fields are optional so existing decoders stay backward-compatible.
|
|
37
|
+
*/ /** Position enriched with market/instrument context returned by /positions. */ /** true when holding > 0 */ /** true = oPRM (outcome position), false = PRM (write/minted) */ /** Flat list sorted by updatedAt desc. */ /** Same positions grouped by market for convenient access. */ // ============================================================================
|
|
35
38
|
// HISTORY TYPES
|
|
36
39
|
// ============================================================================
|
|
37
|
-
/** Net proceeds after fees (profit - fees), as a string */ /** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */
|
|
40
|
+
/** Net proceeds after fees (profit - fees), as a string */ /** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */ /**
|
|
41
|
+
* All of the above merged and sorted chronologically (newest first).
|
|
42
|
+
* Each event has a `type` discriminator field.
|
|
43
|
+
* Populated by /history — may be absent on sub-routes like /history/mints.
|
|
44
|
+
*/ // ============================================================================
|
|
38
45
|
// DEPTH TYPES
|
|
39
46
|
// ============================================================================
|
|
40
47
|
// Note: DepthLevel is exported from sync/clients/order-client.ts
|
|
@@ -698,7 +698,9 @@ function _ts_generator(thisArg, body) {
|
|
|
698
698
|
// USER POSITION & PNL METHODS
|
|
699
699
|
// ============================================================================
|
|
700
700
|
/**
|
|
701
|
-
* Returns
|
|
701
|
+
* Returns enriched user positions including market name, instrument name,
|
|
702
|
+
* logo, collateral info, PnL, and role (isOPrm / isOpen).
|
|
703
|
+
* Also includes a `grouped` array keyed by market.
|
|
702
704
|
*/ function getUserPositions(userAddress) {
|
|
703
705
|
return _async_to_generator(function() {
|
|
704
706
|
return _ts_generator(this, function(_state) {
|
|
@@ -816,8 +818,9 @@ function _ts_generator(thisArg, body) {
|
|
|
816
818
|
// HISTORY METHODS
|
|
817
819
|
// ============================================================================
|
|
818
820
|
/**
|
|
819
|
-
* Returns grouped user history
|
|
820
|
-
*
|
|
821
|
+
* Returns grouped + enriched user history. Every event carries marketName,
|
|
822
|
+
* instrumentName, logoUri, collateralDecimals, collateralToken, and a `type`
|
|
823
|
+
* discriminator. The `timeline` field is a flat chronological list of all events.
|
|
821
824
|
*/ function getUserHistories(userAddress, opts) {
|
|
822
825
|
return _async_to_generator(function() {
|
|
823
826
|
var limit, marketId, tokenId;
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@stryke-xyz/premarket-sdk","version":"1.1.
|
|
1
|
+
{"name":"@stryke-xyz/premarket-sdk","version":"1.1.6","type":"module"}
|
package/dist/esm/shared/types.js
CHANGED
|
@@ -21,10 +21,17 @@
|
|
|
21
21
|
// ============================================================================
|
|
22
22
|
// POSITION & PNL TYPES
|
|
23
23
|
// ============================================================================
|
|
24
|
-
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */
|
|
24
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ /**
|
|
25
|
+
* Market/instrument metadata the API attaches to positions and history events.
|
|
26
|
+
* All fields are optional so existing decoders stay backward-compatible.
|
|
27
|
+
*/ /** Position enriched with market/instrument context returned by /positions. */ /** true when holding > 0 */ /** true = oPRM (outcome position), false = PRM (write/minted) */ /** Flat list sorted by updatedAt desc. */ /** Same positions grouped by market for convenient access. */ // ============================================================================
|
|
25
28
|
// HISTORY TYPES
|
|
26
29
|
// ============================================================================
|
|
27
|
-
/** Net proceeds after fees (profit - fees), as a string */ /** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */
|
|
30
|
+
/** Net proceeds after fees (profit - fees), as a string */ /** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */ /**
|
|
31
|
+
* All of the above merged and sorted chronologically (newest first).
|
|
32
|
+
* Each event has a `type` discriminator field.
|
|
33
|
+
* Populated by /history — may be absent on sub-routes like /history/mints.
|
|
34
|
+
*/ // ============================================================================
|
|
28
35
|
// DEPTH TYPES
|
|
29
36
|
// ============================================================================
|
|
30
37
|
// Note: DepthLevel is exported from sync/clients/order-client.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, Hex } from "viem";
|
|
2
|
-
import type { StoredOrder, CreateOrderParams, CreateOrderResult, MarketsResponse, MarketResponse,
|
|
2
|
+
import type { StoredOrder, CreateOrderParams, CreateOrderResult, MarketsResponse, MarketResponse, TradingPnL, UserPnL, TokenPnL, Erc20PnL, UserHistories, EnrichedPositionsResponse, OrderbookApiConfig, PaginatedOrdersResponse, MarketTradeItem, AuthChallenge } from "../../shared/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Unified HTTP client for orderbook, market, position, and history endpoints.
|
|
5
5
|
*/
|
|
@@ -64,9 +64,11 @@ export declare class OrderbookApi {
|
|
|
64
64
|
*/
|
|
65
65
|
getMarket(marketId: string): Promise<MarketResponse["data"] | null>;
|
|
66
66
|
/**
|
|
67
|
-
* Returns
|
|
67
|
+
* Returns enriched user positions including market name, instrument name,
|
|
68
|
+
* logo, collateral info, PnL, and role (isOPrm / isOpen).
|
|
69
|
+
* Also includes a `grouped` array keyed by market.
|
|
68
70
|
*/
|
|
69
|
-
getUserPositions(userAddress: string): Promise<
|
|
71
|
+
getUserPositions(userAddress: string): Promise<EnrichedPositionsResponse>;
|
|
70
72
|
/**
|
|
71
73
|
* Returns realized trading PnL for limit-order activity.
|
|
72
74
|
*/
|
|
@@ -84,8 +86,9 @@ export declare class OrderbookApi {
|
|
|
84
86
|
*/
|
|
85
87
|
getErc20PnL(userAddress: string, tokenAddress: string): Promise<Erc20PnL>;
|
|
86
88
|
/**
|
|
87
|
-
* Returns grouped user history
|
|
88
|
-
*
|
|
89
|
+
* Returns grouped + enriched user history. Every event carries marketName,
|
|
90
|
+
* instrumentName, logoUri, collateralDecimals, collateralToken, and a `type`
|
|
91
|
+
* discriminator. The `timeline` field is a flat chronological list of all events.
|
|
89
92
|
*/
|
|
90
93
|
getUserHistories(userAddress: string, opts?: {
|
|
91
94
|
limit?: number;
|
|
@@ -232,6 +232,44 @@ export interface UserPosition {
|
|
|
232
232
|
redeemExercisePnl: string;
|
|
233
233
|
updatedAt: string;
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Market/instrument metadata the API attaches to positions and history events.
|
|
237
|
+
* All fields are optional so existing decoders stay backward-compatible.
|
|
238
|
+
*/
|
|
239
|
+
export interface EventEnrichment {
|
|
240
|
+
marketId?: string | null;
|
|
241
|
+
marketName?: string;
|
|
242
|
+
instrumentName?: string;
|
|
243
|
+
logoUri?: string | null;
|
|
244
|
+
collateralDecimals?: number;
|
|
245
|
+
collateralToken?: string;
|
|
246
|
+
}
|
|
247
|
+
/** Position enriched with market/instrument context returned by /positions. */
|
|
248
|
+
export interface EnrichedPosition extends UserPosition, EventEnrichment {
|
|
249
|
+
/** true when holding > 0 */
|
|
250
|
+
isOpen: boolean;
|
|
251
|
+
/** true = oPRM (outcome position), false = PRM (write/minted) */
|
|
252
|
+
isOPrm: boolean;
|
|
253
|
+
marketId: string;
|
|
254
|
+
marketName: string;
|
|
255
|
+
instrumentName: string;
|
|
256
|
+
logoUri: string | null;
|
|
257
|
+
collateralDecimals: number;
|
|
258
|
+
collateralToken: string;
|
|
259
|
+
}
|
|
260
|
+
export interface EnrichedPositionsResponse {
|
|
261
|
+
/** Flat list sorted by updatedAt desc. */
|
|
262
|
+
positions: EnrichedPosition[];
|
|
263
|
+
/** Same positions grouped by market for convenient access. */
|
|
264
|
+
grouped: Array<{
|
|
265
|
+
marketId: string;
|
|
266
|
+
marketName: string;
|
|
267
|
+
logoUri: string | null;
|
|
268
|
+
collateralDecimals: number;
|
|
269
|
+
collateralToken: string;
|
|
270
|
+
positions: EnrichedPosition[];
|
|
271
|
+
}>;
|
|
272
|
+
}
|
|
235
273
|
export interface TradingPnL {
|
|
236
274
|
id: string;
|
|
237
275
|
asset: `0x${string}`;
|
|
@@ -274,7 +312,7 @@ export interface Erc20PnL {
|
|
|
274
312
|
trading: TradingPnL | null;
|
|
275
313
|
totalPnl: string;
|
|
276
314
|
}
|
|
277
|
-
export interface MintHistoryItem {
|
|
315
|
+
export interface MintHistoryItem extends EventEnrichment {
|
|
278
316
|
id: string;
|
|
279
317
|
marketId: string;
|
|
280
318
|
prmTokenId: string;
|
|
@@ -289,8 +327,9 @@ export interface MintHistoryItem {
|
|
|
289
327
|
transactionHash: `0x${string}`;
|
|
290
328
|
blockNumber: string;
|
|
291
329
|
timestamp: string;
|
|
330
|
+
type?: "mint";
|
|
292
331
|
}
|
|
293
|
-
export interface RedeemHistoryItem {
|
|
332
|
+
export interface RedeemHistoryItem extends EventEnrichment {
|
|
294
333
|
id: string;
|
|
295
334
|
oPrmTokenId: string;
|
|
296
335
|
prmTokenId: string;
|
|
@@ -304,8 +343,9 @@ export interface RedeemHistoryItem {
|
|
|
304
343
|
transactionHash: `0x${string}`;
|
|
305
344
|
blockNumber: string;
|
|
306
345
|
timestamp: string;
|
|
346
|
+
type?: "redeem";
|
|
307
347
|
}
|
|
308
|
-
export interface UnwindHistoryItem {
|
|
348
|
+
export interface UnwindHistoryItem extends EventEnrichment {
|
|
309
349
|
id: string;
|
|
310
350
|
marketId: string;
|
|
311
351
|
prmTokenId: string;
|
|
@@ -320,8 +360,9 @@ export interface UnwindHistoryItem {
|
|
|
320
360
|
transactionHash: `0x${string}`;
|
|
321
361
|
blockNumber: string;
|
|
322
362
|
timestamp: string;
|
|
363
|
+
type?: "unwind";
|
|
323
364
|
}
|
|
324
|
-
export interface TransferHistoryItem {
|
|
365
|
+
export interface TransferHistoryItem extends EventEnrichment {
|
|
325
366
|
id: string;
|
|
326
367
|
vaultId: string;
|
|
327
368
|
caller: `0x${string}`;
|
|
@@ -333,8 +374,9 @@ export interface TransferHistoryItem {
|
|
|
333
374
|
transactionHash: `0x${string}`;
|
|
334
375
|
blockNumber: string;
|
|
335
376
|
timestamp: string;
|
|
377
|
+
type?: "transfer";
|
|
336
378
|
}
|
|
337
|
-
export interface OrderFillHistoryItem {
|
|
379
|
+
export interface OrderFillHistoryItem extends EventEnrichment {
|
|
338
380
|
id: string;
|
|
339
381
|
orderHash: `0x${string}`;
|
|
340
382
|
maker: `0x${string}`;
|
|
@@ -353,10 +395,11 @@ export interface OrderFillHistoryItem {
|
|
|
353
395
|
timestamp: string;
|
|
354
396
|
/** true = ask (maker sells), false = bid (maker buys); from API when available */
|
|
355
397
|
isAsk?: boolean;
|
|
398
|
+
type?: "fill";
|
|
356
399
|
}
|
|
357
400
|
/** Recent trade item as returned by getMarketRecentTrades */
|
|
358
401
|
export type MarketTradeItem = OrderFillHistoryItem;
|
|
359
|
-
export interface WithdrawHistoryItem {
|
|
402
|
+
export interface WithdrawHistoryItem extends EventEnrichment {
|
|
360
403
|
id: string;
|
|
361
404
|
marketId: string;
|
|
362
405
|
prmTokenId: string;
|
|
@@ -370,8 +413,9 @@ export interface WithdrawHistoryItem {
|
|
|
370
413
|
transactionHash: `0x${string}`;
|
|
371
414
|
blockNumber: string;
|
|
372
415
|
timestamp: string;
|
|
416
|
+
type?: "withdraw";
|
|
373
417
|
}
|
|
374
|
-
export interface RolloverHistoryItem {
|
|
418
|
+
export interface RolloverHistoryItem extends EventEnrichment {
|
|
375
419
|
id: string;
|
|
376
420
|
marketId: string;
|
|
377
421
|
oldMarketId: string | null;
|
|
@@ -390,8 +434,9 @@ export interface RolloverHistoryItem {
|
|
|
390
434
|
transactionHash: `0x${string}`;
|
|
391
435
|
blockNumber: string;
|
|
392
436
|
timestamp: string;
|
|
437
|
+
type?: "rollover";
|
|
393
438
|
}
|
|
394
|
-
export interface OrderCancelHistoryItem {
|
|
439
|
+
export interface OrderCancelHistoryItem extends EventEnrichment {
|
|
395
440
|
id: string;
|
|
396
441
|
marketId: string;
|
|
397
442
|
tokenId: string;
|
|
@@ -400,7 +445,9 @@ export interface OrderCancelHistoryItem {
|
|
|
400
445
|
transactionHash: `0x${string}`;
|
|
401
446
|
blockNumber: string;
|
|
402
447
|
timestamp: string;
|
|
448
|
+
type?: "cancel";
|
|
403
449
|
}
|
|
450
|
+
export type AnyHistoryEvent = MintHistoryItem | RedeemHistoryItem | UnwindHistoryItem | WithdrawHistoryItem | RolloverHistoryItem | TransferHistoryItem | OrderFillHistoryItem | OrderCancelHistoryItem;
|
|
404
451
|
export interface UserHistories {
|
|
405
452
|
mints: MintHistoryItem[];
|
|
406
453
|
redeems: RedeemHistoryItem[];
|
|
@@ -410,6 +457,12 @@ export interface UserHistories {
|
|
|
410
457
|
transfers: TransferHistoryItem[];
|
|
411
458
|
fills: OrderFillHistoryItem[];
|
|
412
459
|
cancels: OrderCancelHistoryItem[];
|
|
460
|
+
/**
|
|
461
|
+
* All of the above merged and sorted chronologically (newest first).
|
|
462
|
+
* Each event has a `type` discriminator field.
|
|
463
|
+
* Populated by /history — may be absent on sub-routes like /history/mints.
|
|
464
|
+
*/
|
|
465
|
+
timeline?: AnyHistoryEvent[];
|
|
413
466
|
}
|
|
414
467
|
export interface PaginatedOrdersResponse {
|
|
415
468
|
orders: StoredOrder[];
|