@stryke-xyz/premarket-sdk 1.2.9 → 1.2.11
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@stryke-xyz/premarket-sdk","version":"1.2.
|
|
1
|
+
{"name":"@stryke-xyz/premarket-sdk","version":"1.2.11","type":"commonjs"}
|
|
@@ -309,6 +309,7 @@ function normalizePrice(price) {
|
|
|
309
309
|
_define_property(this, "statusListeners", new Set());
|
|
310
310
|
_define_property(this, "snapshotListeners", new Set());
|
|
311
311
|
_define_property(this, "deltaListeners", new Set());
|
|
312
|
+
_define_property(this, "lastPriceListeners", new Set());
|
|
312
313
|
// Reconnection state
|
|
313
314
|
_define_property(this, "shouldBeConnected", false);
|
|
314
315
|
_define_property(this, "reconnectAttempts", 0);
|
|
@@ -696,6 +697,23 @@ function normalizePrice(price) {
|
|
|
696
697
|
};
|
|
697
698
|
}
|
|
698
699
|
},
|
|
700
|
+
{
|
|
701
|
+
/**
|
|
702
|
+
* Subscribe to actual executor fill prices emitted by the depth projector's
|
|
703
|
+
* dedicated `last_price` WS message. Fires once per fill price in each flush
|
|
704
|
+
* window — does NOT fire for bid/ask-only market_state updates.
|
|
705
|
+
*
|
|
706
|
+
* @param listener Called with (marketId, tokenId, price, at) for each fill.
|
|
707
|
+
* @returns Unsubscribe function.
|
|
708
|
+
*/ key: "onLastPrice",
|
|
709
|
+
value: function onLastPrice(listener) {
|
|
710
|
+
var _this = this;
|
|
711
|
+
this.lastPriceListeners.add(listener);
|
|
712
|
+
return function() {
|
|
713
|
+
return _this.lastPriceListeners.delete(listener);
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
},
|
|
699
717
|
{
|
|
700
718
|
key: "onStatus",
|
|
701
719
|
value: function onStatus(listener) {
|
|
@@ -891,13 +909,21 @@ function normalizePrice(price) {
|
|
|
891
909
|
if (msg.prices && msg.prices.length > 0) {
|
|
892
910
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
893
911
|
try {
|
|
894
|
-
|
|
895
|
-
for(var _iterator = msg.prices[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
912
|
+
var _this, _loop = function() {
|
|
896
913
|
var entry = _step.value;
|
|
897
914
|
state.lastPrice = entry.price;
|
|
898
915
|
state.lastPriceAt = entry.at;
|
|
899
|
-
|
|
900
|
-
|
|
916
|
+
_this.emitOutOfBandUpdate(marketId, msg.tokenId, state);
|
|
917
|
+
_this.lastPriceListeners.forEach(function(listener) {
|
|
918
|
+
try {
|
|
919
|
+
listener(marketId, msg.tokenId, entry.price, entry.at);
|
|
920
|
+
} catch (e) {
|
|
921
|
+
console.error(e);
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
// Emit one DepthUpdate per price so listeners see every fill price.
|
|
926
|
+
for(var _iterator = msg.prices[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_this = this, _loop();
|
|
901
927
|
} catch (err) {
|
|
902
928
|
_didIteratorError = true;
|
|
903
929
|
_iteratorError = err;
|
|
@@ -913,11 +939,19 @@ function normalizePrice(price) {
|
|
|
913
939
|
}
|
|
914
940
|
}
|
|
915
941
|
} else if (msg.lastPrice != null) {
|
|
916
|
-
var _msg_lastPriceAt;
|
|
942
|
+
var _msg_lastPriceAt, _ref1, _msg_lastPriceAt1;
|
|
917
943
|
// Legacy single-price fallback.
|
|
918
944
|
state.lastPrice = msg.lastPrice;
|
|
919
945
|
state.lastPriceAt = (_msg_lastPriceAt = msg.lastPriceAt) !== null && _msg_lastPriceAt !== void 0 ? _msg_lastPriceAt : state.lastPriceAt;
|
|
920
946
|
this.emitOutOfBandUpdate(marketId, msg.tokenId, state);
|
|
947
|
+
var at = (_ref1 = (_msg_lastPriceAt1 = msg.lastPriceAt) !== null && _msg_lastPriceAt1 !== void 0 ? _msg_lastPriceAt1 : state.lastPriceAt) !== null && _ref1 !== void 0 ? _ref1 : Date.now();
|
|
948
|
+
this.lastPriceListeners.forEach(function(listener) {
|
|
949
|
+
try {
|
|
950
|
+
listener(marketId, msg.tokenId, msg.lastPrice, at);
|
|
951
|
+
} catch (e) {
|
|
952
|
+
console.error(e);
|
|
953
|
+
}
|
|
954
|
+
});
|
|
921
955
|
}
|
|
922
956
|
}
|
|
923
957
|
},
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@stryke-xyz/premarket-sdk","version":"1.2.
|
|
1
|
+
{"name":"@stryke-xyz/premarket-sdk","version":"1.2.11","type":"module"}
|
|
@@ -299,6 +299,7 @@ function normalizePrice(price) {
|
|
|
299
299
|
_define_property(this, "statusListeners", new Set());
|
|
300
300
|
_define_property(this, "snapshotListeners", new Set());
|
|
301
301
|
_define_property(this, "deltaListeners", new Set());
|
|
302
|
+
_define_property(this, "lastPriceListeners", new Set());
|
|
302
303
|
// Reconnection state
|
|
303
304
|
_define_property(this, "shouldBeConnected", false);
|
|
304
305
|
_define_property(this, "reconnectAttempts", 0);
|
|
@@ -686,6 +687,23 @@ function normalizePrice(price) {
|
|
|
686
687
|
};
|
|
687
688
|
}
|
|
688
689
|
},
|
|
690
|
+
{
|
|
691
|
+
/**
|
|
692
|
+
* Subscribe to actual executor fill prices emitted by the depth projector's
|
|
693
|
+
* dedicated `last_price` WS message. Fires once per fill price in each flush
|
|
694
|
+
* window — does NOT fire for bid/ask-only market_state updates.
|
|
695
|
+
*
|
|
696
|
+
* @param listener Called with (marketId, tokenId, price, at) for each fill.
|
|
697
|
+
* @returns Unsubscribe function.
|
|
698
|
+
*/ key: "onLastPrice",
|
|
699
|
+
value: function onLastPrice(listener) {
|
|
700
|
+
var _this = this;
|
|
701
|
+
this.lastPriceListeners.add(listener);
|
|
702
|
+
return function() {
|
|
703
|
+
return _this.lastPriceListeners.delete(listener);
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
},
|
|
689
707
|
{
|
|
690
708
|
key: "onStatus",
|
|
691
709
|
value: function onStatus(listener) {
|
|
@@ -881,13 +899,21 @@ function normalizePrice(price) {
|
|
|
881
899
|
if (msg.prices && msg.prices.length > 0) {
|
|
882
900
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
883
901
|
try {
|
|
884
|
-
|
|
885
|
-
for(var _iterator = msg.prices[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
902
|
+
var _this, _loop = function() {
|
|
886
903
|
var entry = _step.value;
|
|
887
904
|
state.lastPrice = entry.price;
|
|
888
905
|
state.lastPriceAt = entry.at;
|
|
889
|
-
|
|
890
|
-
|
|
906
|
+
_this.emitOutOfBandUpdate(marketId, msg.tokenId, state);
|
|
907
|
+
_this.lastPriceListeners.forEach(function(listener) {
|
|
908
|
+
try {
|
|
909
|
+
listener(marketId, msg.tokenId, entry.price, entry.at);
|
|
910
|
+
} catch (e) {
|
|
911
|
+
console.error(e);
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
// Emit one DepthUpdate per price so listeners see every fill price.
|
|
916
|
+
for(var _iterator = msg.prices[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_this = this, _loop();
|
|
891
917
|
} catch (err) {
|
|
892
918
|
_didIteratorError = true;
|
|
893
919
|
_iteratorError = err;
|
|
@@ -903,11 +929,19 @@ function normalizePrice(price) {
|
|
|
903
929
|
}
|
|
904
930
|
}
|
|
905
931
|
} else if (msg.lastPrice != null) {
|
|
906
|
-
var _msg_lastPriceAt;
|
|
932
|
+
var _msg_lastPriceAt, _ref1, _msg_lastPriceAt1;
|
|
907
933
|
// Legacy single-price fallback.
|
|
908
934
|
state.lastPrice = msg.lastPrice;
|
|
909
935
|
state.lastPriceAt = (_msg_lastPriceAt = msg.lastPriceAt) !== null && _msg_lastPriceAt !== void 0 ? _msg_lastPriceAt : state.lastPriceAt;
|
|
910
936
|
this.emitOutOfBandUpdate(marketId, msg.tokenId, state);
|
|
937
|
+
var at = (_ref1 = (_msg_lastPriceAt1 = msg.lastPriceAt) !== null && _msg_lastPriceAt1 !== void 0 ? _msg_lastPriceAt1 : state.lastPriceAt) !== null && _ref1 !== void 0 ? _ref1 : Date.now();
|
|
938
|
+
this.lastPriceListeners.forEach(function(listener) {
|
|
939
|
+
try {
|
|
940
|
+
listener(marketId, msg.tokenId, msg.lastPrice, at);
|
|
941
|
+
} catch (e) {
|
|
942
|
+
console.error(e);
|
|
943
|
+
}
|
|
944
|
+
});
|
|
911
945
|
}
|
|
912
946
|
}
|
|
913
947
|
},
|
|
@@ -106,6 +106,7 @@ export declare class MarketDepthSyncClient {
|
|
|
106
106
|
private statusListeners;
|
|
107
107
|
private snapshotListeners;
|
|
108
108
|
private deltaListeners;
|
|
109
|
+
private lastPriceListeners;
|
|
109
110
|
private shouldBeConnected;
|
|
110
111
|
private reconnectAttempts;
|
|
111
112
|
private reconnectTimeoutId;
|
|
@@ -141,6 +142,15 @@ export declare class MarketDepthSyncClient {
|
|
|
141
142
|
getLastPrice(tokenId: string): string | null;
|
|
142
143
|
onSnapshot(listener: (marketId: string, snapshots: TokenDepthSnapshot[]) => void): () => void;
|
|
143
144
|
onDelta(listener: (marketId: string, update: DepthUpdate) => void): () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Subscribe to actual executor fill prices emitted by the depth projector's
|
|
147
|
+
* dedicated `last_price` WS message. Fires once per fill price in each flush
|
|
148
|
+
* window — does NOT fire for bid/ask-only market_state updates.
|
|
149
|
+
*
|
|
150
|
+
* @param listener Called with (marketId, tokenId, price, at) for each fill.
|
|
151
|
+
* @returns Unsubscribe function.
|
|
152
|
+
*/
|
|
153
|
+
onLastPrice(listener: (marketId: string, tokenId: string, price: string, at: number) => void): () => void;
|
|
144
154
|
onStatus(listener: (status: SyncStatus) => void): () => void;
|
|
145
155
|
private _sendSubscribeMarket;
|
|
146
156
|
private handleSubscribedMarket;
|