@stryke-xyz/premarket-sdk 1.1.1 → 1.1.3
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 +49 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/shared/types.js +2 -2
- package/dist/esm/api/orderbook-api/index.js +49 -3
- package/dist/esm/package.json +1 -1
- package/dist/esm/shared/types.js +2 -2
- package/dist/types/api/orderbook-api/index.d.ts +20 -3
- package/dist/types/shared/types.d.ts +78 -21
- package/package.json +1 -1
|
@@ -595,6 +595,45 @@ function _ts_generator(thisArg, body) {
|
|
|
595
595
|
}).call(this);
|
|
596
596
|
}
|
|
597
597
|
},
|
|
598
|
+
{
|
|
599
|
+
key: "getUserOrdersAllMarkets",
|
|
600
|
+
value: /**
|
|
601
|
+
* Returns a user's open orders across **all** markets, paginated.
|
|
602
|
+
*
|
|
603
|
+
* When `marketId` is omitted, the order-queue service switches to
|
|
604
|
+
* paginated mode and requires `maker`. Pass `limit` (1–1000, default
|
|
605
|
+
* 1000) and `offset` (default 0) to page through results.
|
|
606
|
+
*/ function getUserOrdersAllMarkets(maker, opts) {
|
|
607
|
+
return _async_to_generator(function() {
|
|
608
|
+
var data;
|
|
609
|
+
return _ts_generator(this, function(_state) {
|
|
610
|
+
switch(_state.label){
|
|
611
|
+
case 0:
|
|
612
|
+
return [
|
|
613
|
+
4,
|
|
614
|
+
this.requestEnvelope(this.buildUrl("/orderbook/api/orders", {
|
|
615
|
+
maker: maker,
|
|
616
|
+
limit: opts === null || opts === void 0 ? void 0 : opts.limit,
|
|
617
|
+
offset: opts === null || opts === void 0 ? void 0 : opts.offset,
|
|
618
|
+
status: opts === null || opts === void 0 ? void 0 : opts.status
|
|
619
|
+
}), undefined, "Failed to fetch orders")
|
|
620
|
+
];
|
|
621
|
+
case 1:
|
|
622
|
+
data = _state.sent();
|
|
623
|
+
return [
|
|
624
|
+
2,
|
|
625
|
+
data !== null && data !== void 0 ? data : {
|
|
626
|
+
orders: [],
|
|
627
|
+
count: 0,
|
|
628
|
+
hasMore: false,
|
|
629
|
+
nextOffset: 0
|
|
630
|
+
}
|
|
631
|
+
];
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}).call(this);
|
|
635
|
+
}
|
|
636
|
+
},
|
|
598
637
|
{
|
|
599
638
|
key: "getMarkets",
|
|
600
639
|
value: // ============================================================================
|
|
@@ -787,16 +826,23 @@ function _ts_generator(thisArg, body) {
|
|
|
787
826
|
// HISTORY METHODS
|
|
788
827
|
// ============================================================================
|
|
789
828
|
/**
|
|
790
|
-
* Returns grouped user history across mint, redeem, unwind,
|
|
791
|
-
|
|
829
|
+
* Returns grouped user history across mint, redeem, unwind, withdraw,
|
|
830
|
+
* rollover, transfer, fill, and cancel events.
|
|
831
|
+
*/ function getUserHistories(userAddress, opts) {
|
|
792
832
|
return _async_to_generator(function() {
|
|
833
|
+
var limit, marketId, tokenId;
|
|
793
834
|
return _ts_generator(this, function(_state) {
|
|
794
835
|
switch(_state.label){
|
|
795
836
|
case 0:
|
|
837
|
+
limit = typeof opts === "number" ? opts : opts === null || opts === void 0 ? void 0 : opts.limit;
|
|
838
|
+
marketId = (typeof opts === "undefined" ? "undefined" : _type_of(opts)) === "object" ? opts.marketId : undefined;
|
|
839
|
+
tokenId = (typeof opts === "undefined" ? "undefined" : _type_of(opts)) === "object" ? opts.tokenId : undefined;
|
|
796
840
|
return [
|
|
797
841
|
4,
|
|
798
842
|
this.requestEnvelope(this.buildUrl("/premarket/api/users/".concat(encodeURIComponent(userAddress), "/history"), {
|
|
799
|
-
limit: limit
|
|
843
|
+
limit: limit,
|
|
844
|
+
marketId: marketId,
|
|
845
|
+
tokenId: tokenId
|
|
800
846
|
}), undefined, "Failed to fetch history")
|
|
801
847
|
];
|
|
802
848
|
case 1:
|
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.3","type":"commonjs"}
|
package/dist/cjs/shared/types.js
CHANGED
|
@@ -31,10 +31,10 @@ Object.defineProperty(exports, "OrderStatus", {
|
|
|
31
31
|
// ============================================================================
|
|
32
32
|
// POSITION & PNL TYPES
|
|
33
33
|
// ============================================================================
|
|
34
|
-
// ============================================================================
|
|
34
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ // ============================================================================
|
|
35
35
|
// HISTORY TYPES
|
|
36
36
|
// ============================================================================
|
|
37
|
-
/** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */ // ============================================================================
|
|
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 */ // ============================================================================
|
|
38
38
|
// DEPTH TYPES
|
|
39
39
|
// ============================================================================
|
|
40
40
|
// Note: DepthLevel is exported from sync/clients/order-client.ts
|
|
@@ -585,6 +585,45 @@ function _ts_generator(thisArg, body) {
|
|
|
585
585
|
}).call(this);
|
|
586
586
|
}
|
|
587
587
|
},
|
|
588
|
+
{
|
|
589
|
+
key: "getUserOrdersAllMarkets",
|
|
590
|
+
value: /**
|
|
591
|
+
* Returns a user's open orders across **all** markets, paginated.
|
|
592
|
+
*
|
|
593
|
+
* When `marketId` is omitted, the order-queue service switches to
|
|
594
|
+
* paginated mode and requires `maker`. Pass `limit` (1–1000, default
|
|
595
|
+
* 1000) and `offset` (default 0) to page through results.
|
|
596
|
+
*/ function getUserOrdersAllMarkets(maker, opts) {
|
|
597
|
+
return _async_to_generator(function() {
|
|
598
|
+
var data;
|
|
599
|
+
return _ts_generator(this, function(_state) {
|
|
600
|
+
switch(_state.label){
|
|
601
|
+
case 0:
|
|
602
|
+
return [
|
|
603
|
+
4,
|
|
604
|
+
this.requestEnvelope(this.buildUrl("/orderbook/api/orders", {
|
|
605
|
+
maker: maker,
|
|
606
|
+
limit: opts === null || opts === void 0 ? void 0 : opts.limit,
|
|
607
|
+
offset: opts === null || opts === void 0 ? void 0 : opts.offset,
|
|
608
|
+
status: opts === null || opts === void 0 ? void 0 : opts.status
|
|
609
|
+
}), undefined, "Failed to fetch orders")
|
|
610
|
+
];
|
|
611
|
+
case 1:
|
|
612
|
+
data = _state.sent();
|
|
613
|
+
return [
|
|
614
|
+
2,
|
|
615
|
+
data !== null && data !== void 0 ? data : {
|
|
616
|
+
orders: [],
|
|
617
|
+
count: 0,
|
|
618
|
+
hasMore: false,
|
|
619
|
+
nextOffset: 0
|
|
620
|
+
}
|
|
621
|
+
];
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}).call(this);
|
|
625
|
+
}
|
|
626
|
+
},
|
|
588
627
|
{
|
|
589
628
|
key: "getMarkets",
|
|
590
629
|
value: // ============================================================================
|
|
@@ -777,16 +816,23 @@ function _ts_generator(thisArg, body) {
|
|
|
777
816
|
// HISTORY METHODS
|
|
778
817
|
// ============================================================================
|
|
779
818
|
/**
|
|
780
|
-
* Returns grouped user history across mint, redeem, unwind,
|
|
781
|
-
|
|
819
|
+
* Returns grouped user history across mint, redeem, unwind, withdraw,
|
|
820
|
+
* rollover, transfer, fill, and cancel events.
|
|
821
|
+
*/ function getUserHistories(userAddress, opts) {
|
|
782
822
|
return _async_to_generator(function() {
|
|
823
|
+
var limit, marketId, tokenId;
|
|
783
824
|
return _ts_generator(this, function(_state) {
|
|
784
825
|
switch(_state.label){
|
|
785
826
|
case 0:
|
|
827
|
+
limit = typeof opts === "number" ? opts : opts === null || opts === void 0 ? void 0 : opts.limit;
|
|
828
|
+
marketId = (typeof opts === "undefined" ? "undefined" : _type_of(opts)) === "object" ? opts.marketId : undefined;
|
|
829
|
+
tokenId = (typeof opts === "undefined" ? "undefined" : _type_of(opts)) === "object" ? opts.tokenId : undefined;
|
|
786
830
|
return [
|
|
787
831
|
4,
|
|
788
832
|
this.requestEnvelope(this.buildUrl("/premarket/api/users/".concat(encodeURIComponent(userAddress), "/history"), {
|
|
789
|
-
limit: limit
|
|
833
|
+
limit: limit,
|
|
834
|
+
marketId: marketId,
|
|
835
|
+
tokenId: tokenId
|
|
790
836
|
}), undefined, "Failed to fetch history")
|
|
791
837
|
];
|
|
792
838
|
case 1:
|
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.3","type":"module"}
|
package/dist/esm/shared/types.js
CHANGED
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
// ============================================================================
|
|
22
22
|
// POSITION & PNL TYPES
|
|
23
23
|
// ============================================================================
|
|
24
|
-
// ============================================================================
|
|
24
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ // ============================================================================
|
|
25
25
|
// HISTORY TYPES
|
|
26
26
|
// ============================================================================
|
|
27
|
-
/** true = ask (maker sells), false = bid (maker buys); from API when available */ /** Recent trade item as returned by getMarketRecentTrades */ // ============================================================================
|
|
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 */ // ============================================================================
|
|
28
28
|
// DEPTH TYPES
|
|
29
29
|
// ============================================================================
|
|
30
30
|
// 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, UserPosition, TradingPnL, UserPnL, TokenPnL, Erc20PnL, UserHistories, OrderbookApiConfig, MarketTradeItem, AuthChallenge } from "../../shared/types.js";
|
|
2
|
+
import type { StoredOrder, CreateOrderParams, CreateOrderResult, MarketsResponse, MarketResponse, UserPosition, TradingPnL, UserPnL, TokenPnL, Erc20PnL, UserHistories, OrderbookApiConfig, PaginatedOrdersResponse, MarketTradeItem, AuthChallenge } from "../../shared/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Unified HTTP client for orderbook, market, position, and history endpoints.
|
|
5
5
|
*/
|
|
@@ -39,6 +39,18 @@ export declare class OrderbookApi {
|
|
|
39
39
|
* Convenience wrapper around `getOrders(marketId, maker)`.
|
|
40
40
|
*/
|
|
41
41
|
getUserOrders(maker: string, marketId: string): Promise<StoredOrder[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a user's open orders across **all** markets, paginated.
|
|
44
|
+
*
|
|
45
|
+
* When `marketId` is omitted, the order-queue service switches to
|
|
46
|
+
* paginated mode and requires `maker`. Pass `limit` (1–1000, default
|
|
47
|
+
* 1000) and `offset` (default 0) to page through results.
|
|
48
|
+
*/
|
|
49
|
+
getUserOrdersAllMarkets(maker: string, opts?: {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
status?: "all";
|
|
53
|
+
}): Promise<PaginatedOrdersResponse>;
|
|
42
54
|
/**
|
|
43
55
|
* Returns the paginated market catalog from the premarket API.
|
|
44
56
|
*/
|
|
@@ -72,9 +84,14 @@ export declare class OrderbookApi {
|
|
|
72
84
|
*/
|
|
73
85
|
getErc20PnL(userAddress: string, tokenAddress: string): Promise<Erc20PnL>;
|
|
74
86
|
/**
|
|
75
|
-
* Returns grouped user history across mint, redeem, unwind,
|
|
87
|
+
* Returns grouped user history across mint, redeem, unwind, withdraw,
|
|
88
|
+
* rollover, transfer, fill, and cancel events.
|
|
76
89
|
*/
|
|
77
|
-
getUserHistories(userAddress: string,
|
|
90
|
+
getUserHistories(userAddress: string, opts?: {
|
|
91
|
+
limit?: number;
|
|
92
|
+
marketId?: string;
|
|
93
|
+
tokenId?: string;
|
|
94
|
+
}): Promise<UserHistories>;
|
|
78
95
|
/**
|
|
79
96
|
* Returns the user's mint history feed.
|
|
80
97
|
*/
|
|
@@ -226,11 +226,16 @@ export interface UserPosition {
|
|
|
226
226
|
totalCost: string;
|
|
227
227
|
totalProceeds: string;
|
|
228
228
|
realizedPnL: string;
|
|
229
|
+
/** PnL contribution from limit-order trades */
|
|
230
|
+
tradePnl: string;
|
|
231
|
+
/** PnL contribution from redemption / exercise settlements */
|
|
232
|
+
redeemExercisePnl: string;
|
|
229
233
|
updatedAt: string;
|
|
230
234
|
}
|
|
231
235
|
export interface TradingPnL {
|
|
232
236
|
id: string;
|
|
233
237
|
asset: `0x${string}`;
|
|
238
|
+
marketId: string | null;
|
|
234
239
|
tokenId: string | null;
|
|
235
240
|
totalBought: string;
|
|
236
241
|
totalSold: string;
|
|
@@ -239,10 +244,16 @@ export interface TradingPnL {
|
|
|
239
244
|
realizedPnL: string;
|
|
240
245
|
updatedAt: string;
|
|
241
246
|
}
|
|
247
|
+
export interface SettlementPnL {
|
|
248
|
+
tokenId: string;
|
|
249
|
+
totalProceeds: string;
|
|
250
|
+
realizedPnL: string;
|
|
251
|
+
updatedAt: string;
|
|
252
|
+
}
|
|
242
253
|
export interface UserPnL {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
254
|
+
tradePnl: string;
|
|
255
|
+
redeemExercisePnl: string;
|
|
256
|
+
totalPnl: string;
|
|
246
257
|
}
|
|
247
258
|
export interface TokenPnL {
|
|
248
259
|
tokenId: string;
|
|
@@ -252,27 +263,16 @@ export interface TokenPnL {
|
|
|
252
263
|
totalProceeds: string;
|
|
253
264
|
realizedPnL: string;
|
|
254
265
|
} | null;
|
|
255
|
-
trading:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
realizedPnL: string;
|
|
261
|
-
} | null;
|
|
262
|
-
positionPnL: string;
|
|
263
|
-
tradingPnL: string;
|
|
264
|
-
totalPnL: string;
|
|
266
|
+
trading: TradingPnL | null;
|
|
267
|
+
redeemExercise: SettlementPnL | null;
|
|
268
|
+
tradePnl: string;
|
|
269
|
+
redeemExercisePnl: string;
|
|
270
|
+
totalPnl: string;
|
|
265
271
|
}
|
|
266
272
|
export interface Erc20PnL {
|
|
267
273
|
tokenAddress: `0x${string}`;
|
|
268
|
-
trading:
|
|
269
|
-
|
|
270
|
-
totalSold: string;
|
|
271
|
-
totalSpent: string;
|
|
272
|
-
totalReceived: string;
|
|
273
|
-
realizedPnL: string;
|
|
274
|
-
} | null;
|
|
275
|
-
totalPnL: string;
|
|
274
|
+
trading: TradingPnL | null;
|
|
275
|
+
totalPnl: string;
|
|
276
276
|
}
|
|
277
277
|
export interface MintHistoryItem {
|
|
278
278
|
id: string;
|
|
@@ -298,6 +298,8 @@ export interface RedeemHistoryItem {
|
|
|
298
298
|
balance: string;
|
|
299
299
|
profit: string;
|
|
300
300
|
fees: string;
|
|
301
|
+
/** Net proceeds after fees (profit - fees), as a string */
|
|
302
|
+
netProceeds: string;
|
|
301
303
|
finalTick: string;
|
|
302
304
|
transactionHash: `0x${string}`;
|
|
303
305
|
blockNumber: string;
|
|
@@ -341,6 +343,7 @@ export interface OrderFillHistoryItem {
|
|
|
341
343
|
takerAsset: `0x${string}`;
|
|
342
344
|
makingAmount: string;
|
|
343
345
|
takingAmount: string;
|
|
346
|
+
makerFee: string;
|
|
344
347
|
tradeType: string;
|
|
345
348
|
optionTokenId: string | null;
|
|
346
349
|
role?: "maker" | "taker";
|
|
@@ -353,12 +356,66 @@ export interface OrderFillHistoryItem {
|
|
|
353
356
|
}
|
|
354
357
|
/** Recent trade item as returned by getMarketRecentTrades */
|
|
355
358
|
export type MarketTradeItem = OrderFillHistoryItem;
|
|
359
|
+
export interface WithdrawHistoryItem {
|
|
360
|
+
id: string;
|
|
361
|
+
marketId: string;
|
|
362
|
+
prmTokenId: string;
|
|
363
|
+
account: `0x${string}`;
|
|
364
|
+
amount: string;
|
|
365
|
+
loss: string;
|
|
366
|
+
lossUsdc: string;
|
|
367
|
+
finalTick: string;
|
|
368
|
+
collateral: string;
|
|
369
|
+
netProceeds: string;
|
|
370
|
+
transactionHash: `0x${string}`;
|
|
371
|
+
blockNumber: string;
|
|
372
|
+
timestamp: string;
|
|
373
|
+
}
|
|
374
|
+
export interface RolloverHistoryItem {
|
|
375
|
+
id: string;
|
|
376
|
+
marketId: string;
|
|
377
|
+
oldMarketId: string | null;
|
|
378
|
+
newMarketId: string | null;
|
|
379
|
+
oldPrmTokenId: string;
|
|
380
|
+
newPrmTokenId: string;
|
|
381
|
+
newOPrmTokenId: string | null;
|
|
382
|
+
account: `0x${string}`;
|
|
383
|
+
oldExpiry: string;
|
|
384
|
+
newExpiry: string;
|
|
385
|
+
oldAmount: string;
|
|
386
|
+
residualCollateral: string;
|
|
387
|
+
rolloverFee: string;
|
|
388
|
+
netRolloverCollateral: string;
|
|
389
|
+
newAmount: string;
|
|
390
|
+
transactionHash: `0x${string}`;
|
|
391
|
+
blockNumber: string;
|
|
392
|
+
timestamp: string;
|
|
393
|
+
}
|
|
394
|
+
export interface OrderCancelHistoryItem {
|
|
395
|
+
id: string;
|
|
396
|
+
marketId: string;
|
|
397
|
+
tokenId: string;
|
|
398
|
+
orderHash: `0x${string}`;
|
|
399
|
+
maker: `0x${string}`;
|
|
400
|
+
transactionHash: `0x${string}`;
|
|
401
|
+
blockNumber: string;
|
|
402
|
+
timestamp: string;
|
|
403
|
+
}
|
|
356
404
|
export interface UserHistories {
|
|
357
405
|
mints: MintHistoryItem[];
|
|
358
406
|
redeems: RedeemHistoryItem[];
|
|
359
407
|
unwinds: UnwindHistoryItem[];
|
|
408
|
+
withdraws: WithdrawHistoryItem[];
|
|
409
|
+
rollovers: RolloverHistoryItem[];
|
|
360
410
|
transfers: TransferHistoryItem[];
|
|
361
411
|
fills: OrderFillHistoryItem[];
|
|
412
|
+
cancels: OrderCancelHistoryItem[];
|
|
413
|
+
}
|
|
414
|
+
export interface PaginatedOrdersResponse {
|
|
415
|
+
orders: StoredOrder[];
|
|
416
|
+
count: number;
|
|
417
|
+
hasMore: boolean;
|
|
418
|
+
nextOffset: number;
|
|
362
419
|
}
|
|
363
420
|
export type AuthChallenge = {
|
|
364
421
|
readonly domain: {
|