Update orderUpdateSchema

This commit is contained in:
Mikhail Gladchenko
2023-03-16 14:52:14 +00:00
parent 56387b18a4
commit f7b8b828e5
3 changed files with 9 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import subOrderStatuses from '../../../../constants/subOrderStatuses';
import MessageType from '../MessageType';
import balancesSchema from './balancesSchema';
import baseMessageSchema from './baseMessageSchema';
import executionTypes from '../../../../constants/cfdExecutionTypes';
const baseAddressUpdate = baseMessageSchema.extend({
id: z.string(),
@@ -34,6 +35,8 @@ export const orderUpdateSchema = z.object({
S: z.enum(orderStatuses), // status
l: z.boolean().optional(), // is liquidation order
t: z.number(), // update time
E: z.enum(executionTypes).optional(), // execution type
C: z.string().optional(), // trigger condition
c: subOrderSchema.array(),
})
.transform((val) => ({
@@ -45,6 +48,8 @@ export const orderUpdateSchema = z.object({
settledAmount: o.A,
status: o.S,
liquidated: o.l,
executionType: o.E,
triggerCondition: o.C,
subOrders: o.c.map((so) => ({
pair: so.P,
exchange: so.e,
@@ -75,6 +80,8 @@ export const fullOrderSchema = z.object({
T: z.number(), // creation time / unix timestamp
t: z.number(), // update time
c: subOrderSchema.array(),
E: z.enum(executionTypes).optional(), // execution type
C: z.string().optional(), // trigger condition
}).transform((val) => ({
...val,
k: 'full' as const,
@@ -93,6 +100,8 @@ export const fullOrderSchema = z.object({
pair: o.P,
amount: o.a,
price: o.p,
executionType: o.E,
triggerCondition: o.C,
subOrders: o.c.map((so) => ({
pair: so.P,
exchange: so.e,

View File

@@ -24,8 +24,6 @@ const cfdBalanceSchema = z
sfrs: z.string(),
sfrd: z.string(),
sop: z.string().optional(),
E: z.enum(executionTypes),
C: z.string().optional(),
})
.transform((obj) => ({
instrument: obj.i,
@@ -48,8 +46,6 @@ const cfdBalanceSchema = z
shortFundingRatePerSecond: obj.sfrs,
shortFundingRatePerDay: obj.sfrd,
stopOutPrice: obj.sop,
executionType: obj.E,
triggerCondition: obj.C,
}));
const cfdBalancesSchema = z.array(cfdBalanceSchema);

View File

@@ -58,8 +58,6 @@ export type CFDBalance = {
shortFundingRatePerSecond: string
shortFundingRatePerDay: string
stopOutPrice: string | undefined
executionType: ExecutionType
triggerCondition: string | undefined
}
export type Order = {