mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Update cfd balance schema
This commit is contained in:
@@ -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",
|
||||
|
||||
3
src/constants/cfdExecutionTypes.ts
Normal file
3
src/constants/cfdExecutionTypes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const executionTypes = ['LIMIT', 'STOP_LIMIT'] as const;
|
||||
|
||||
export default executionTypes;
|
||||
@@ -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);
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user