no dep cycle

This commit is contained in:
Aleksandr Kraiz
2022-12-14 21:07:38 +04:00
parent de3f07703e
commit e69082319e
3 changed files with 65 additions and 69 deletions

View File

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

View File

@@ -11,10 +11,11 @@ import {
import UnsubscriptionType from './UnsubscriptionType';
import {
SwapInfoByAmountIn, SwapInfoByAmountOut, SwapInfoBase,
FullOrder, OrderUpdate, AssetPairUpdate, OrderbookItem, Balance, Exchange,
AssetPairUpdate, OrderbookItem, Balance, Exchange,
} from '../../../types';
import unsubscriptionDoneSchema from './schemas/unsubscriptionDoneSchema';
import assetPairConfigSchema from './schemas/assetPairConfigSchema';
import { fullOrderSchema, orderUpdateSchema } from './schemas/addressUpdateSchema';
// import errorSchema from './schemas/errorSchema';
const UNSUBSCRIBE = 'u';
@@ -71,7 +72,7 @@ type AddressUpdateUpdate = {
Balance
>
>,
order?: OrderUpdate | FullOrder
order?: z.infer<typeof orderUpdateSchema> | z.infer<typeof fullOrderSchema>
}
type AddressUpdateInitial = {
@@ -82,7 +83,7 @@ type AddressUpdateInitial = {
Balance
>
>,
orders?: FullOrder[] // The field is not defined if the user has no orders
orders?: z.infer<typeof fullOrderSchema>[] // The field is not defined if the user has no orders
}
type AddressUpdateSubscription = {
@@ -441,7 +442,7 @@ class OrionAggregatorWS {
switch (json.k) { // message kind
case 'i': { // initial
const fullOrders = json.o
? json.o.reduce<FullOrder[]>((prev, o) => {
? json.o.reduce<z.infer<typeof fullOrderSchema>[]>((prev, o) => {
prev.push(o);
return prev;
@@ -458,7 +459,7 @@ class OrionAggregatorWS {
}
break;
case 'u': { // update
let orderUpdate: OrderUpdate | FullOrder | undefined;
let orderUpdate: z.infer<typeof orderUpdateSchema> | z.infer<typeof fullOrderSchema> | undefined;
if (json.o) {
const firstOrder = json.o[0];
orderUpdate = firstOrder;

View File

@@ -1,18 +1,6 @@
import BigNumber from 'bignumber.js';
import { z } from 'zod';
import exchanges from './constants/exchanges';
import subOrderStatuses from './constants/subOrderStatuses';
import { fullOrderSchema, orderUpdateSchema } from './services/OrionAggregator/ws/schemas/addressUpdateSchema';
export type OrderbookItem = {
price: string,
amount: string,
exchanges: string[],
vob: {
side: 'BUY' | 'SELL',
pairName: string
}[]
}
export type AssetPairUpdate = {
minQty: number,
@@ -29,9 +17,6 @@ export type SubOrder = {
side: 'BUY' | 'SELL',
subOrdQty: number
}
export type FullOrder = z.infer<typeof fullOrderSchema>;
export type OrderUpdate = z.infer<typeof orderUpdateSchema>;
export type Balance = {
tradable: string,
@@ -84,54 +69,6 @@ export interface Pair {
vol24h: string;
}
export type SwapInfoAlternative = {
exchanges: string[],
path: string[],
marketAmountOut?: number,
marketAmountIn?: number,
marketPrice: number,
availableAmountIn?: number,
availableAmountOut?: number,
}
export type SwapInfoBase = {
swapRequestId: string,
assetIn: string,
assetOut: string,
amountIn: number,
amountOut: number,
minAmountIn: number,
minAmountOut: number,
path: string[],
exchanges?: string[],
poolOptimal: boolean,
price?: number,
marketPrice?: number,
orderInfo?: {
pair: string,
side: 'BUY' | 'SELL',
amount: number,
safePrice: number,
},
alternatives: SwapInfoAlternative[],
}
export type SwapInfoByAmountIn = SwapInfoBase & {
kind: 'exactSpend',
availableAmountIn?: number,
marketAmountOut?: number,
}
export type SwapInfoByAmountOut = SwapInfoBase & {
kind: 'exactReceive',
marketAmountIn?: number,
availableAmountOut?: number,
}
export type SwapInfo = SwapInfoByAmountIn | SwapInfoByAmountOut;
export enum SupportedChainId {
MAINNET = '1',
ROPSTEN = '3',
@@ -193,3 +130,61 @@ export type BalanceIssue = {
}
export type Exchange = typeof exchanges[number];
export type OrderbookItem = {
price: string,
amount: string,
exchanges: Exchange[],
vob: {
side: 'BUY' | 'SELL',
pairName: string
}[]
}
export type SwapInfoAlternative = {
exchanges: Exchange[],
path: string[],
marketAmountOut?: number,
marketAmountIn?: number,
marketPrice: number,
availableAmountIn?: number,
availableAmountOut?: number,
}
export type SwapInfoBase = {
swapRequestId: string,
assetIn: string,
assetOut: string,
amountIn: number,
amountOut: number,
minAmountIn: number,
minAmountOut: number,
path: string[],
exchanges?: string[],
poolOptimal: boolean,
price?: number,
marketPrice?: number,
orderInfo?: {
pair: string,
side: 'BUY' | 'SELL',
amount: number,
safePrice: number,
},
alternatives: SwapInfoAlternative[],
}
export type SwapInfoByAmountIn = SwapInfoBase & {
kind: 'exactSpend',
availableAmountIn?: number,
marketAmountOut?: number,
}
export type SwapInfoByAmountOut = SwapInfoBase & {
kind: 'exactReceive',
marketAmountIn?: number,
availableAmountOut?: number,
}
export type SwapInfo = SwapInfoByAmountIn | SwapInfoByAmountOut;