updated schemas, updated version

This commit is contained in:
Demid
2023-01-10 13:54:40 +03:00
parent d6f6061a66
commit af70f5c3e0
5 changed files with 45 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.16.0-rc.12",
"version": "0.16.0-rc.13",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -9,7 +9,7 @@ import errorSchema from './schemas/errorSchema';
import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema';
import { OrionAggregatorWS } from './ws';
import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema';
import { Exchange, SignedCancelOrderRequest, SignedOrder } from '../../types';
import {Exchange, SignedCancelOrderRequest, SignedCFDOrder, SignedOrder} from '../../types';
import { pairConfigSchema } from './schemas';
import {
aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema,
@@ -34,6 +34,7 @@ class OrionAggregator {
this.getTradeProfits = this.getTradeProfits.bind(this);
this.placeAtomicSwap = this.placeAtomicSwap.bind(this);
this.placeOrder = this.placeOrder.bind(this);
this.placeCFDOrder = this.placeCFDOrder.bind(this);
this.cancelOrder = this.cancelOrder.bind(this);
this.checkWhitelisted = this.checkWhitelisted.bind(this);
this.getLockedBalance = this.getLockedBalance.bind(this);
@@ -172,6 +173,35 @@ class OrionAggregator {
errorSchema,
);
placeCFDOrder = (
signedOrder: SignedCFDOrder
) => {
const headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
};
return fetchWithValidation(
`${this.apiUrl}/api/v1/order/futures`,
z.object({
orderId: z.string(),
placementRequests: z.array(
z.object({
amount: z.number(),
brokerAddress: z.string(),
exchange: z.string(),
}),
).optional(),
}),
{
headers,
method: 'POST',
body: JSON.stringify(signedOrder),
},
errorSchema,
);
};
getSwapInfo = (
type: 'exactSpend' | 'exactReceive',
assetIn: string,

View File

@@ -2,12 +2,12 @@ import { z } from 'zod';
const cfdBalanceSchema = z.object({
i: z.string(),
b: z.number(),
p: z.number(),
pp: z.number(),
fr: z.number(),
sfrl: z.number(),
lfrl: z.number(),
b: z.string(),
p: z.string(),
pp: z.string(),
fr: z.string(),
sfrl: z.string(),
lfrl: z.string(),
})
.transform((obj) => ({
instrument: obj.i,

View File

@@ -7,5 +7,6 @@ export { default as initMessageSchema } from './initMessageSchema';
export { default as pingPongMessageSchema } from './pingPongMessageSchema';
export { default as swapInfoSchema } from './swapInfoSchema';
export { default as balancesSchema } from './balancesSchema';
export { default as cfdBalancesSchema } from './cfdBalancesSchema';
export * from './orderBookSchema';

View File

@@ -28,12 +28,12 @@ export type Balance = {
export type CFDBalance = {
instrument: string,
balance: number,
position: number,
positionPrice: number,
fundingRate: number,
lastShortFundingRate: number,
lastLongFundingRate: number,
balance: string,
position: string,
positionPrice: string,
fundingRate: string,
lastShortFundingRate: string,
lastLongFundingRate: string,
}
export interface Order {