mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-22 21:59:44 +03:00
feat: add kind to update pair callback
This commit is contained in:
@@ -87,7 +87,10 @@ type PairsConfigSubscription = {
|
|||||||
|
|
||||||
type PairConfigSubscription = {
|
type PairConfigSubscription = {
|
||||||
payload: string,
|
payload: string,
|
||||||
callback: (data: AssetPairUpdate) => void,
|
callback: ({ kind, data }: {
|
||||||
|
kind: 'initial' | 'update',
|
||||||
|
data: AssetPairUpdate,
|
||||||
|
}) => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
type AggregatedOrderbookSubscription = {
|
type AggregatedOrderbookSubscription = {
|
||||||
@@ -418,10 +421,18 @@ class OrionAggregatorWS {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType.ASSET_PAIR_CONFIG_UPDATE: {
|
case MessageType.ASSET_PAIR_CONFIG_UPDATE: {
|
||||||
const pair = json;
|
const pair = json.u;
|
||||||
const [, minQty, pricePrecision] = pair.u;
|
const [, minQty, pricePrecision] = pair;
|
||||||
|
|
||||||
this.subscriptions[SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE]?.[json.id]?.callback({ minQty, pricePrecision });
|
this.subscriptions[
|
||||||
|
SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE
|
||||||
|
]?.[json.id]?.callback({
|
||||||
|
data: {
|
||||||
|
minQty,
|
||||||
|
pricePrecision,
|
||||||
|
},
|
||||||
|
kind: json.k === 'i' ? 'initial' : 'update',
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import baseMessageSchema from './baseMessageSchema';
|
|||||||
const assetPairConfigSchema = baseMessageSchema.extend({
|
const assetPairConfigSchema = baseMessageSchema.extend({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
T: z.literal(MessageType.ASSET_PAIR_CONFIG_UPDATE),
|
T: z.literal(MessageType.ASSET_PAIR_CONFIG_UPDATE),
|
||||||
|
k: z.enum(['i', 'u']),
|
||||||
u: z.tuple([
|
u: z.tuple([
|
||||||
z.string(), // pairName
|
z.string(), // pairName
|
||||||
z.number(), // minQty
|
z.number(), // minQty
|
||||||
|
|||||||
Reference in New Issue
Block a user