OP-2818 [Swap] Show order route path and benefits in Swap UI

Updated SwapInfo schemas for WS and REST.
This commit is contained in:
Mikhail Gladchenko
2022-12-13 16:25:26 +00:00
parent 60a2bc0bcd
commit ab59310645
3 changed files with 24 additions and 1 deletions

View File

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

View File

@@ -20,6 +20,20 @@ const swapInfoBase = z.object({
minAmountOut: z.number(),
minAmountIn: z.number(),
marketPrice: z.number().nullable(), // spending asset market price
alternatives: z.object({ // execution alternatives
exchanges: z.string().array(),
path: z.object({
units: z.object({
assetPair: z.string(),
action: z.string(),
}).array(),
}),
marketAmountOut: z.number().nullable(),
marketAmountIn: z.number().nullable(),
marketPrice: z.number(),
availableAmountIn: z.number().nullable(),
availableAmountOut: z.number().nullable(),
}).array(),
});
const swapInfoByAmountIn = swapInfoBase.extend({

View File

@@ -22,6 +22,15 @@ const swapInfoSchemaBase = baseMessageSchema.extend({
a: z.number(), // amount
sp: z.number(), // safe price (with safe deviation but without slippage)
}).optional(),
as: z.object({ // execution alternatives
e: z.string().array(), // exchanges
ps: z.string().array(), // path
mo: z.number().nullable(), // market amount out
mi: z.number().nullable(), // market amount in
mp: z.number(), // market price
aa: z.number().nullable(), // available amount in
aao: z.number().nullable(), // available amount out
}).array(),
});
const swapInfoSchemaByAmountIn = swapInfoSchemaBase.extend({