From 56387b18a4950c685c65fdf094fbf28749ad6c19 Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Thu, 16 Mar 2023 08:20:39 +0000 Subject: [PATCH] Update cfd balance schema --- package.json | 2 +- src/constants/cfdExecutionTypes.ts | 3 +++ .../OrionAggregator/ws/schemas/cfdBalancesSchema.ts | 7 ++++++- src/types.ts | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/constants/cfdExecutionTypes.ts diff --git a/package.json b/package.json index 60f3eca..5f55352 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.36", + "version": "0.17.37-rc.1", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/constants/cfdExecutionTypes.ts b/src/constants/cfdExecutionTypes.ts new file mode 100644 index 0000000..bc82566 --- /dev/null +++ b/src/constants/cfdExecutionTypes.ts @@ -0,0 +1,3 @@ +const executionTypes = ['LIMIT', 'STOP_LIMIT'] as const; + +export default executionTypes; diff --git a/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts b/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts index e7abacd..48d4a97 100644 --- a/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; import positionStatuses from '../../../../constants/positionStatuses'; +import executionTypes from '../../../../constants/cfdExecutionTypes'; const cfdBalanceSchema = z .object({ @@ -23,6 +24,8 @@ 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, @@ -44,7 +47,9 @@ const cfdBalanceSchema = z longFundingRatePerDay: obj.lfrd, shortFundingRatePerSecond: obj.sfrs, shortFundingRatePerDay: obj.sfrd, - stopOutPrice: obj.sop + stopOutPrice: obj.sop, + executionType: obj.E, + triggerCondition: obj.C, })); const cfdBalancesSchema = z.array(cfdBalanceSchema); diff --git a/src/types.ts b/src/types.ts index 891d740..b150dea 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,6 +4,7 @@ import type exchanges from './constants/exchanges'; import type subOrderStatuses from './constants/subOrderStatuses'; import type positionStatuses from './constants/positionStatuses'; import type { knownEnvs } from './config/schemas'; +import type executionTypes from './constants/cfdExecutionTypes'; export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; @@ -34,6 +35,7 @@ export type Balance = { } export type PositionStatus = typeof positionStatuses[number]; +export type ExecutionType = typeof executionTypes[number]; export type CFDBalance = { instrument: string @@ -56,6 +58,8 @@ export type CFDBalance = { shortFundingRatePerSecond: string shortFundingRatePerDay: string stopOutPrice: string | undefined + executionType: ExecutionType + triggerCondition: string | undefined } export type Order = {