From 37a2db3eddf80be8570f9c2d25b5cc1a838d11a5 Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Wed, 1 Mar 2023 16:22:37 +0000 Subject: [PATCH] Add new stop limit schemas --- package.json | 2 +- src/crypt/signCFDOrder.ts | 8 ++++++++ .../OrionAggregator/ws/schemas/addressUpdateSchema.ts | 4 ++++ src/types.ts | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5856d08..d7bed70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.24", + "version": "0.17.25-rc.1", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/crypt/signCFDOrder.ts b/src/crypt/signCFDOrder.ts index 358d4be..7994943 100644 --- a/src/crypt/signCFDOrder.ts +++ b/src/crypt/signCFDOrder.ts @@ -25,6 +25,7 @@ export const signCFDOrder = async ( usePersonalSign: boolean, signer: ethers.Signer, chainId: SupportedChainId, + stopPrice: BigNumber.Value | undefined, ) => { const nonce = Date.now(); const expiration = nonce + DEFAULT_EXPIRATION; @@ -51,6 +52,13 @@ export const signCFDOrder = async ( nonce, expiration, buySide: side === 'BUY' ? 1 : 0, + stopPrice: stopPrice !== undefined + ? normalizeNumber( + stopPrice, + INTERNAL_ORION_PRECISION, + BigNumber.ROUND_FLOOR, + ).toNumber() + : undefined, isPersonalSign: usePersonalSign, }; diff --git a/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts b/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts index 1850585..0f8b655 100644 --- a/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts @@ -33,6 +33,7 @@ export const orderUpdateSchema = z.object({ A: z.number(), // settled amount S: z.enum(orderStatuses), // status l: z.boolean().optional(), // is liquidation order + L: z.number().optional(), // stop limit price, t: z.number(), // update time c: subOrderSchema.array(), }) @@ -45,6 +46,7 @@ export const orderUpdateSchema = z.object({ settledAmount: o.A, status: o.S, liquidated: o.l, + stopPrice: o.L, subOrders: o.c.map((so) => ({ pair: so.P, exchange: so.e, @@ -69,6 +71,7 @@ export const fullOrderSchema = z.object({ F: z.string(), // fee asset f: z.number(), // fee l: z.boolean().optional(), // is liquidation order + L: z.number().optional(), // stop limit price, o: z.boolean(), // internal only S: z.enum(orderStatuses), // status T: z.number(), // creation time / unix timestamp @@ -84,6 +87,7 @@ export const fullOrderSchema = z.object({ feeAsset: o.F, fee: o.f, liquidated: o.l, + stopPrice: o.L, status: o.S, date: o.T, clientOrdId: o.O, diff --git a/src/types.ts b/src/types.ts index 9eb900f..f49fa51 100644 --- a/src/types.ts +++ b/src/types.ts @@ -82,6 +82,7 @@ export type CFDOrder = { nonce: number // uint64 expiration: number // uint64 buySide: 0 | 1 // uint8, 1=buy, 0=sell + stopPrice?: number | undefined // uint64 isPersonalSign: boolean // bool }