Update cfd balance schema

This commit is contained in:
Mikhail Gladchenko
2023-03-16 08:20:39 +00:00
parent 422aacaa38
commit 56387b18a4
4 changed files with 14 additions and 2 deletions

View File

@@ -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",

View File

@@ -0,0 +1,3 @@
const executionTypes = ['LIMIT', 'STOP_LIMIT'] as const;
export default executionTypes;

View File

@@ -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);

View File

@@ -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> = T extends object ? {
[P in keyof T]?: DeepPartial<T[P]>;
@@ -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 = {