mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-04-06 04:57:53 +03:00
Exchanges / more error messages
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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[
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user