Add new stop limit schemas

This commit is contained in:
Mikhail Gladchenko
2023-03-01 16:22:37 +00:00
parent a7c74abb64
commit 37a2db3edd
4 changed files with 14 additions and 1 deletions

View File

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

View File

@@ -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,
};

View File

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

View File

@@ -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
}