@stryke-xyz/premarket-sdk 1.1.0 → 1.1.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/dist/cjs/api/orderbook-api/index.js +140 -4
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/shared/types.js +6 -2
- package/dist/esm/api/orderbook-api/index.js +140 -4
- package/dist/esm/package.json +1 -1
- package/dist/esm/shared/types.js +6 -2
- package/dist/types/api/orderbook-api/index.d.ts +20 -3
- package/dist/types/shared/types.d.ts +87 -21
- package/package.json +1 -1
|
@@ -104,6 +104,45 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
104
104
|
function _non_iterable_rest() {
|
|
105
105
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
106
106
|
}
|
|
107
|
+
function _object_spread(target) {
|
|
108
|
+
for(var i = 1; i < arguments.length; i++){
|
|
109
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
110
|
+
var ownKeys = Object.keys(source);
|
|
111
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
112
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
113
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
ownKeys.forEach(function(key) {
|
|
117
|
+
_define_property(target, key, source[key]);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function ownKeys(object, enumerableOnly) {
|
|
123
|
+
var keys = Object.keys(object);
|
|
124
|
+
if (Object.getOwnPropertySymbols) {
|
|
125
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
126
|
+
if (enumerableOnly) {
|
|
127
|
+
symbols = symbols.filter(function(sym) {
|
|
128
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
keys.push.apply(keys, symbols);
|
|
132
|
+
}
|
|
133
|
+
return keys;
|
|
134
|
+
}
|
|
135
|
+
function _object_spread_props(target, source) {
|
|
136
|
+
source = source != null ? source : {};
|
|
137
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
138
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
139
|
+
} else {
|
|
140
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
141
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return target;
|
|
145
|
+
}
|
|
107
146
|
function _sliced_to_array(arr, i) {
|
|
108
147
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
109
148
|
}
|
|
@@ -222,6 +261,53 @@ function _ts_generator(thisArg, body) {
|
|
|
222
261
|
// ORDERBOOK API CLIENT
|
|
223
262
|
// ============================================================================
|
|
224
263
|
// ============================================================================
|
|
264
|
+
// SIGNATURE NORMALIZATION
|
|
265
|
+
// ============================================================================
|
|
266
|
+
/**
|
|
267
|
+
* Wire shape expected by orderbook-pg: split EIP-2098 compact signature.
|
|
268
|
+
* `r` is the standard r component (32 bytes hex). `vs` packs s + recovery bit
|
|
269
|
+
* (v-27) into the most-significant bit, per EIP-2098.
|
|
270
|
+
*/ /**
|
|
271
|
+
* Accepts either:
|
|
272
|
+
* - a 65-byte concatenated hex signature `0x{r:32}{s:32}{v:1}` (what
|
|
273
|
+
* `walletClient.signTypedData` and `signSimpleAccountOrder` return), or
|
|
274
|
+
* - an already-split `{ r, vs }` payload.
|
|
275
|
+
*
|
|
276
|
+
* Returns the EIP-2098 split form the backend's signature recovery expects.
|
|
277
|
+
*/ function toCompactSignature(signature) {
|
|
278
|
+
if ((typeof signature === "undefined" ? "undefined" : _type_of(signature)) === "object" && signature !== null) {
|
|
279
|
+
return {
|
|
280
|
+
r: signature.r,
|
|
281
|
+
vs: signature.vs
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
var hex = signature.startsWith("0x") ? signature.slice(2) : signature;
|
|
285
|
+
if (hex.length !== 130) {
|
|
286
|
+
throw new Error("Invalid signature length: expected 65 bytes (130 hex chars), got ".concat(hex.length));
|
|
287
|
+
}
|
|
288
|
+
var r = "0x".concat(hex.slice(0, 64));
|
|
289
|
+
var sHex = hex.slice(64, 128);
|
|
290
|
+
var vByte = parseInt(hex.slice(128, 130), 16);
|
|
291
|
+
if (vByte !== 27 && vByte !== 28) {
|
|
292
|
+
throw new Error("Invalid signature v byte: expected 27 or 28, got ".concat(vByte));
|
|
293
|
+
}
|
|
294
|
+
var recoveryBit = vByte - 27;
|
|
295
|
+
// Pack recoveryBit into the high bit of s to form vs.
|
|
296
|
+
var sBytes = new Uint8Array(32);
|
|
297
|
+
for(var i = 0; i < 32; i++){
|
|
298
|
+
sBytes[i] = parseInt(sHex.slice(i * 2, i * 2 + 2), 16);
|
|
299
|
+
}
|
|
300
|
+
if (recoveryBit === 1) sBytes[0] |= 0x80;
|
|
301
|
+
var vs = "0x";
|
|
302
|
+
for(var i1 = 0; i1 < 32; i1++){
|
|
303
|
+
vs += sBytes[i1].toString(16).padStart(2, "0");
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
r: r,
|
|
307
|
+
vs: vs
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
// ============================================================================
|
|
225
311
|
// ORDERBOOK API CLASS
|
|
226
312
|
// ============================================================================
|
|
227
313
|
/**
|
|
@@ -419,9 +505,13 @@ function _ts_generator(thisArg, body) {
|
|
|
419
505
|
* activity WS for the eventual fill.
|
|
420
506
|
*/ function createOrder(params, bearerToken) {
|
|
421
507
|
return _async_to_generator(function() {
|
|
508
|
+
var wireParams;
|
|
422
509
|
return _ts_generator(this, function(_state) {
|
|
423
510
|
switch(_state.label){
|
|
424
511
|
case 0:
|
|
512
|
+
wireParams = _object_spread_props(_object_spread({}, params), {
|
|
513
|
+
signature: toCompactSignature(params.signature)
|
|
514
|
+
});
|
|
425
515
|
return [
|
|
426
516
|
4,
|
|
427
517
|
this.requestEnvelope("/orderbook/api/orders", {
|
|
@@ -430,7 +520,7 @@ function _ts_generator(thisArg, body) {
|
|
|
430
520
|
"Content-Type": "application/json",
|
|
431
521
|
Authorization: "Bearer ".concat(bearerToken)
|
|
432
522
|
},
|
|
433
|
-
body: JSON.stringify(
|
|
523
|
+
body: JSON.stringify(wireParams)
|
|
434
524
|
}, "Failed to create order")
|
|
435
525
|
];
|
|
436
526
|
case 1:
|
|
@@ -505,6 +595,45 @@ function _ts_generator(thisArg, body) {
|
|
|
505
595
|
}).call(this);
|
|
506
596
|
}
|
|
507
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
|
+
},
|
|
508
637
|
{
|
|
509
638
|
key: "getMarkets",
|
|
510
639
|
value: // ============================================================================
|
|
@@ -697,16 +826,23 @@ function _ts_generator(thisArg, body) {
|
|
|
697
826
|
// HISTORY METHODS
|
|
698
827
|
// ============================================================================
|
|
699
828
|
/**
|
|
700
|
-
* Returns grouped user history across mint, redeem, unwind,
|
|
701
|
-
|
|
829
|
+
* Returns grouped user history across mint, redeem, unwind, withdraw,
|
|
830
|
+
* rollover, transfer, fill, and cancel events.
|
|
831
|
+
*/ function getUserHistories(userAddress, opts) {
|
|
702
832
|
return _async_to_generator(function() {
|
|
833
|
+
var limit, marketId, tokenId;
|
|
703
834
|
return _ts_generator(this, function(_state) {
|
|
704
835
|
switch(_state.label){
|
|
705
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;
|
|
706
840
|
return [
|
|
707
841
|
4,
|
|
708
842
|
this.requestEnvelope(this.buildUrl("/premarket/api/users/".concat(encodeURIComponent(userAddress), "/history"), {
|
|
709
|
-
limit: limit
|
|
843
|
+
limit: limit,
|
|
844
|
+
marketId: marketId,
|
|
845
|
+
tokenId: tokenId
|
|
710
846
|
}), undefined, "Failed to fetch history")
|
|
711
847
|
];
|
|
712
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.1","type":"commonjs"}
|
package/dist/cjs/shared/types.js
CHANGED
|
@@ -12,6 +12,10 @@ Object.defineProperty(exports, "OrderStatus", {
|
|
|
12
12
|
// ORDER TYPES
|
|
13
13
|
// ============================================================================
|
|
14
14
|
/**
|
|
15
|
+
* Wire-format split signature (EIP-2098 compact pair). Used internally when
|
|
16
|
+
* posting orders to orderbook-pg, which expects { r, vs } rather than the
|
|
17
|
+
* 65-byte concatenated hex returned by viem.
|
|
18
|
+
*/ /**
|
|
15
19
|
* Option parameters for legacy OptionTokenFactory
|
|
16
20
|
* Used for calculating option token IDs
|
|
17
21
|
*/ var OrderStatus = /*#__PURE__*/ function(OrderStatus) {
|
|
@@ -27,10 +31,10 @@ Object.defineProperty(exports, "OrderStatus", {
|
|
|
27
31
|
// ============================================================================
|
|
28
32
|
// POSITION & PNL TYPES
|
|
29
33
|
// ============================================================================
|
|
30
|
-
// ============================================================================
|
|
34
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ // ============================================================================
|
|
31
35
|
// HISTORY TYPES
|
|
32
36
|
// ============================================================================
|
|
33
|
-
/** 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 */ // ============================================================================
|
|
34
38
|
// DEPTH TYPES
|
|
35
39
|
// ============================================================================
|
|
36
40
|
// Note: DepthLevel is exported from sync/clients/order-client.ts
|
|
@@ -94,6 +94,45 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
94
94
|
function _non_iterable_rest() {
|
|
95
95
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
96
96
|
}
|
|
97
|
+
function _object_spread(target) {
|
|
98
|
+
for(var i = 1; i < arguments.length; i++){
|
|
99
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
100
|
+
var ownKeys = Object.keys(source);
|
|
101
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
102
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
103
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
ownKeys.forEach(function(key) {
|
|
107
|
+
_define_property(target, key, source[key]);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return target;
|
|
111
|
+
}
|
|
112
|
+
function ownKeys(object, enumerableOnly) {
|
|
113
|
+
var keys = Object.keys(object);
|
|
114
|
+
if (Object.getOwnPropertySymbols) {
|
|
115
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
116
|
+
if (enumerableOnly) {
|
|
117
|
+
symbols = symbols.filter(function(sym) {
|
|
118
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
keys.push.apply(keys, symbols);
|
|
122
|
+
}
|
|
123
|
+
return keys;
|
|
124
|
+
}
|
|
125
|
+
function _object_spread_props(target, source) {
|
|
126
|
+
source = source != null ? source : {};
|
|
127
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
128
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
129
|
+
} else {
|
|
130
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
131
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return target;
|
|
135
|
+
}
|
|
97
136
|
function _sliced_to_array(arr, i) {
|
|
98
137
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
138
|
}
|
|
@@ -212,6 +251,53 @@ function _ts_generator(thisArg, body) {
|
|
|
212
251
|
// ORDERBOOK API CLIENT
|
|
213
252
|
// ============================================================================
|
|
214
253
|
// ============================================================================
|
|
254
|
+
// SIGNATURE NORMALIZATION
|
|
255
|
+
// ============================================================================
|
|
256
|
+
/**
|
|
257
|
+
* Wire shape expected by orderbook-pg: split EIP-2098 compact signature.
|
|
258
|
+
* `r` is the standard r component (32 bytes hex). `vs` packs s + recovery bit
|
|
259
|
+
* (v-27) into the most-significant bit, per EIP-2098.
|
|
260
|
+
*/ /**
|
|
261
|
+
* Accepts either:
|
|
262
|
+
* - a 65-byte concatenated hex signature `0x{r:32}{s:32}{v:1}` (what
|
|
263
|
+
* `walletClient.signTypedData` and `signSimpleAccountOrder` return), or
|
|
264
|
+
* - an already-split `{ r, vs }` payload.
|
|
265
|
+
*
|
|
266
|
+
* Returns the EIP-2098 split form the backend's signature recovery expects.
|
|
267
|
+
*/ function toCompactSignature(signature) {
|
|
268
|
+
if ((typeof signature === "undefined" ? "undefined" : _type_of(signature)) === "object" && signature !== null) {
|
|
269
|
+
return {
|
|
270
|
+
r: signature.r,
|
|
271
|
+
vs: signature.vs
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
var hex = signature.startsWith("0x") ? signature.slice(2) : signature;
|
|
275
|
+
if (hex.length !== 130) {
|
|
276
|
+
throw new Error("Invalid signature length: expected 65 bytes (130 hex chars), got ".concat(hex.length));
|
|
277
|
+
}
|
|
278
|
+
var r = "0x".concat(hex.slice(0, 64));
|
|
279
|
+
var sHex = hex.slice(64, 128);
|
|
280
|
+
var vByte = parseInt(hex.slice(128, 130), 16);
|
|
281
|
+
if (vByte !== 27 && vByte !== 28) {
|
|
282
|
+
throw new Error("Invalid signature v byte: expected 27 or 28, got ".concat(vByte));
|
|
283
|
+
}
|
|
284
|
+
var recoveryBit = vByte - 27;
|
|
285
|
+
// Pack recoveryBit into the high bit of s to form vs.
|
|
286
|
+
var sBytes = new Uint8Array(32);
|
|
287
|
+
for(var i = 0; i < 32; i++){
|
|
288
|
+
sBytes[i] = parseInt(sHex.slice(i * 2, i * 2 + 2), 16);
|
|
289
|
+
}
|
|
290
|
+
if (recoveryBit === 1) sBytes[0] |= 0x80;
|
|
291
|
+
var vs = "0x";
|
|
292
|
+
for(var i1 = 0; i1 < 32; i1++){
|
|
293
|
+
vs += sBytes[i1].toString(16).padStart(2, "0");
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
r: r,
|
|
297
|
+
vs: vs
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
// ============================================================================
|
|
215
301
|
// ORDERBOOK API CLASS
|
|
216
302
|
// ============================================================================
|
|
217
303
|
/**
|
|
@@ -409,9 +495,13 @@ function _ts_generator(thisArg, body) {
|
|
|
409
495
|
* activity WS for the eventual fill.
|
|
410
496
|
*/ function createOrder(params, bearerToken) {
|
|
411
497
|
return _async_to_generator(function() {
|
|
498
|
+
var wireParams;
|
|
412
499
|
return _ts_generator(this, function(_state) {
|
|
413
500
|
switch(_state.label){
|
|
414
501
|
case 0:
|
|
502
|
+
wireParams = _object_spread_props(_object_spread({}, params), {
|
|
503
|
+
signature: toCompactSignature(params.signature)
|
|
504
|
+
});
|
|
415
505
|
return [
|
|
416
506
|
4,
|
|
417
507
|
this.requestEnvelope("/orderbook/api/orders", {
|
|
@@ -420,7 +510,7 @@ function _ts_generator(thisArg, body) {
|
|
|
420
510
|
"Content-Type": "application/json",
|
|
421
511
|
Authorization: "Bearer ".concat(bearerToken)
|
|
422
512
|
},
|
|
423
|
-
body: JSON.stringify(
|
|
513
|
+
body: JSON.stringify(wireParams)
|
|
424
514
|
}, "Failed to create order")
|
|
425
515
|
];
|
|
426
516
|
case 1:
|
|
@@ -495,6 +585,45 @@ function _ts_generator(thisArg, body) {
|
|
|
495
585
|
}).call(this);
|
|
496
586
|
}
|
|
497
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
|
+
},
|
|
498
627
|
{
|
|
499
628
|
key: "getMarkets",
|
|
500
629
|
value: // ============================================================================
|
|
@@ -687,16 +816,23 @@ function _ts_generator(thisArg, body) {
|
|
|
687
816
|
// HISTORY METHODS
|
|
688
817
|
// ============================================================================
|
|
689
818
|
/**
|
|
690
|
-
* Returns grouped user history across mint, redeem, unwind,
|
|
691
|
-
|
|
819
|
+
* Returns grouped user history across mint, redeem, unwind, withdraw,
|
|
820
|
+
* rollover, transfer, fill, and cancel events.
|
|
821
|
+
*/ function getUserHistories(userAddress, opts) {
|
|
692
822
|
return _async_to_generator(function() {
|
|
823
|
+
var limit, marketId, tokenId;
|
|
693
824
|
return _ts_generator(this, function(_state) {
|
|
694
825
|
switch(_state.label){
|
|
695
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;
|
|
696
830
|
return [
|
|
697
831
|
4,
|
|
698
832
|
this.requestEnvelope(this.buildUrl("/premarket/api/users/".concat(encodeURIComponent(userAddress), "/history"), {
|
|
699
|
-
limit: limit
|
|
833
|
+
limit: limit,
|
|
834
|
+
marketId: marketId,
|
|
835
|
+
tokenId: tokenId
|
|
700
836
|
}), undefined, "Failed to fetch history")
|
|
701
837
|
];
|
|
702
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.1","type":"module"}
|
package/dist/esm/shared/types.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
// ORDER TYPES
|
|
3
3
|
// ============================================================================
|
|
4
4
|
/**
|
|
5
|
+
* Wire-format split signature (EIP-2098 compact pair). Used internally when
|
|
6
|
+
* posting orders to orderbook-pg, which expects { r, vs } rather than the
|
|
7
|
+
* 65-byte concatenated hex returned by viem.
|
|
8
|
+
*/ /**
|
|
5
9
|
* Option parameters for legacy OptionTokenFactory
|
|
6
10
|
* Used for calculating option token IDs
|
|
7
11
|
*/ export var OrderStatus = /*#__PURE__*/ function(OrderStatus) {
|
|
@@ -17,10 +21,10 @@
|
|
|
17
21
|
// ============================================================================
|
|
18
22
|
// POSITION & PNL TYPES
|
|
19
23
|
// ============================================================================
|
|
20
|
-
// ============================================================================
|
|
24
|
+
/** PnL contribution from limit-order trades */ /** PnL contribution from redemption / exercise settlements */ // ============================================================================
|
|
21
25
|
// HISTORY TYPES
|
|
22
26
|
// ============================================================================
|
|
23
|
-
/** 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 */ // ============================================================================
|
|
24
28
|
// DEPTH TYPES
|
|
25
29
|
// ============================================================================
|
|
26
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
|
*/
|
|
@@ -13,6 +13,15 @@ export interface Order {
|
|
|
13
13
|
tokenId: string;
|
|
14
14
|
}
|
|
15
15
|
export type OrderSignature = `0x${string}`;
|
|
16
|
+
/**
|
|
17
|
+
* Wire-format split signature (EIP-2098 compact pair). Used internally when
|
|
18
|
+
* posting orders to orderbook-pg, which expects { r, vs } rather than the
|
|
19
|
+
* 65-byte concatenated hex returned by viem.
|
|
20
|
+
*/
|
|
21
|
+
export interface SplitOrderSignature {
|
|
22
|
+
r: string;
|
|
23
|
+
vs: string;
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* Option parameters for legacy OptionTokenFactory
|
|
18
27
|
* Used for calculating option token IDs
|
|
@@ -217,11 +226,16 @@ export interface UserPosition {
|
|
|
217
226
|
totalCost: string;
|
|
218
227
|
totalProceeds: string;
|
|
219
228
|
realizedPnL: string;
|
|
229
|
+
/** PnL contribution from limit-order trades */
|
|
230
|
+
tradePnl: string;
|
|
231
|
+
/** PnL contribution from redemption / exercise settlements */
|
|
232
|
+
redeemExercisePnl: string;
|
|
220
233
|
updatedAt: string;
|
|
221
234
|
}
|
|
222
235
|
export interface TradingPnL {
|
|
223
236
|
id: string;
|
|
224
237
|
asset: `0x${string}`;
|
|
238
|
+
marketId: string | null;
|
|
225
239
|
tokenId: string | null;
|
|
226
240
|
totalBought: string;
|
|
227
241
|
totalSold: string;
|
|
@@ -230,10 +244,16 @@ export interface TradingPnL {
|
|
|
230
244
|
realizedPnL: string;
|
|
231
245
|
updatedAt: string;
|
|
232
246
|
}
|
|
247
|
+
export interface SettlementPnL {
|
|
248
|
+
tokenId: string;
|
|
249
|
+
totalProceeds: string;
|
|
250
|
+
realizedPnL: string;
|
|
251
|
+
updatedAt: string;
|
|
252
|
+
}
|
|
233
253
|
export interface UserPnL {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
254
|
+
tradePnl: string;
|
|
255
|
+
redeemExercisePnl: string;
|
|
256
|
+
totalPnl: string;
|
|
237
257
|
}
|
|
238
258
|
export interface TokenPnL {
|
|
239
259
|
tokenId: string;
|
|
@@ -243,27 +263,16 @@ export interface TokenPnL {
|
|
|
243
263
|
totalProceeds: string;
|
|
244
264
|
realizedPnL: string;
|
|
245
265
|
} | null;
|
|
246
|
-
trading:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
realizedPnL: string;
|
|
252
|
-
} | null;
|
|
253
|
-
positionPnL: string;
|
|
254
|
-
tradingPnL: string;
|
|
255
|
-
totalPnL: string;
|
|
266
|
+
trading: TradingPnL | null;
|
|
267
|
+
redeemExercise: SettlementPnL | null;
|
|
268
|
+
tradePnl: string;
|
|
269
|
+
redeemExercisePnl: string;
|
|
270
|
+
totalPnl: string;
|
|
256
271
|
}
|
|
257
272
|
export interface Erc20PnL {
|
|
258
273
|
tokenAddress: `0x${string}`;
|
|
259
|
-
trading:
|
|
260
|
-
|
|
261
|
-
totalSold: string;
|
|
262
|
-
totalSpent: string;
|
|
263
|
-
totalReceived: string;
|
|
264
|
-
realizedPnL: string;
|
|
265
|
-
} | null;
|
|
266
|
-
totalPnL: string;
|
|
274
|
+
trading: TradingPnL | null;
|
|
275
|
+
totalPnl: string;
|
|
267
276
|
}
|
|
268
277
|
export interface MintHistoryItem {
|
|
269
278
|
id: string;
|
|
@@ -289,6 +298,8 @@ export interface RedeemHistoryItem {
|
|
|
289
298
|
balance: string;
|
|
290
299
|
profit: string;
|
|
291
300
|
fees: string;
|
|
301
|
+
/** Net proceeds after fees (profit - fees), as a string */
|
|
302
|
+
netProceeds: string;
|
|
292
303
|
finalTick: string;
|
|
293
304
|
transactionHash: `0x${string}`;
|
|
294
305
|
blockNumber: string;
|
|
@@ -332,6 +343,7 @@ export interface OrderFillHistoryItem {
|
|
|
332
343
|
takerAsset: `0x${string}`;
|
|
333
344
|
makingAmount: string;
|
|
334
345
|
takingAmount: string;
|
|
346
|
+
makerFee: string;
|
|
335
347
|
tradeType: string;
|
|
336
348
|
optionTokenId: string | null;
|
|
337
349
|
role?: "maker" | "taker";
|
|
@@ -344,12 +356,66 @@ export interface OrderFillHistoryItem {
|
|
|
344
356
|
}
|
|
345
357
|
/** Recent trade item as returned by getMarketRecentTrades */
|
|
346
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
|
+
}
|
|
347
404
|
export interface UserHistories {
|
|
348
405
|
mints: MintHistoryItem[];
|
|
349
406
|
redeems: RedeemHistoryItem[];
|
|
350
407
|
unwinds: UnwindHistoryItem[];
|
|
408
|
+
withdraws: WithdrawHistoryItem[];
|
|
409
|
+
rollovers: RolloverHistoryItem[];
|
|
351
410
|
transfers: TransferHistoryItem[];
|
|
352
411
|
fills: OrderFillHistoryItem[];
|
|
412
|
+
cancels: OrderCancelHistoryItem[];
|
|
413
|
+
}
|
|
414
|
+
export interface PaginatedOrdersResponse {
|
|
415
|
+
orders: StoredOrder[];
|
|
416
|
+
count: number;
|
|
417
|
+
hasMore: boolean;
|
|
418
|
+
nextOffset: number;
|
|
353
419
|
}
|
|
354
420
|
export type AuthChallenge = {
|
|
355
421
|
readonly domain: {
|