Exchanges / more error messages

This commit is contained in:
Aleksandr Kraiz
2022-07-04 19:07:32 +04:00
parent 620e4a5ef7
commit 48ae67c1a8
14 changed files with 91 additions and 28 deletions

View File

@@ -15,6 +15,7 @@ const swapInfoBase = z.object({
amount: z.number(),
safePrice: z.number(),
}).nullable(),
exchanges: z.array(z.string()).optional(),
price: z.number().nullable(), // spending asset price
minAmountOut: z.number(),
minAmountIn: z.number(),

View File

@@ -329,6 +329,7 @@ class OrionAggregatorWS {
minAmounOut: json.mao,
minAmounIn: json.ma,
path: json.ps,
exchanges: json.e,
poolOptimal: json.po,
...json.oi && {
orderInfo: {
@@ -399,13 +400,13 @@ class OrionAggregatorWS {
break;
case MessageType.ASSET_PAIRS_CONFIG_UPDATE: {
const pairs = json;
let priceUpdates: Partial<Record<string, AssetPairUpdate>> = {};
const priceUpdates: Partial<Record<string, AssetPairUpdate>> = {};
pairs.u.forEach(([pairName, minQty, pricePrecision]) => {
priceUpdates[pairName] = {
minQty,
pricePrecision,
}
};
});
this.subscriptions[
@@ -425,7 +426,7 @@ class OrionAggregatorWS {
prev[asset] = {
tradable, reserved, contract, wallet, allowance,
}
};
return prev;
}, {})
@@ -437,7 +438,7 @@ class OrionAggregatorWS {
const fullOrder = mapFullOrder(o);
prev.push(fullOrder);
return prev;
}, [])
: undefined;
@@ -475,10 +476,10 @@ class OrionAggregatorWS {
}
break;
case MessageType.BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATE: {
let brokerBalances: Partial<Record<string, number>> = {};
const brokerBalances: Partial<Record<string, number>> = {};
json.bb.forEach(([asset, balance]) => {
brokerBalances[asset] = balance
brokerBalances[asset] = balance;
});
this.subscriptions[

View File

@@ -13,7 +13,7 @@ const swapInfoSchemaBase = baseMessageSchema.extend({
mao: z.number(), // min amount out
ps: z.string().array(), // path
po: z.boolean(), // is swap through pool optimal
e: z.string().array().optional(), // Exchanges
p: z.number().optional(), // price
mp: z.number().optional(), // market price
oi: z.object({ // info about order equivalent to this swap

View File

@@ -1,3 +1,4 @@
import { ethers } from 'ethers';
import { z } from 'zod';
import { makePartial } from '../../../utils';
@@ -7,6 +8,12 @@ const poolsConfigSchema = z.object({
governanceAddress: z.string(),
routerAddress: z.string(),
votingAddress: z.string(),
factories: z.record(
z.string(),
z.string().refine(ethers.utils.isAddress, 'Factory should be an address'),
)
.transform(makePartial)
.optional(),
pools: z.record(
z.string(),
z.object({