From 09a894e9ed378aa0248cc5ecf52395131cc0e532 Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Mon, 27 Nov 2023 19:49:03 +0500 Subject: [PATCH 1/6] swapInfo usd --- package-lock.json | 4 ++-- package.json | 2 +- src/services/Aggregator/schemas/swapInfoSchema.ts | 7 +++++++ src/services/Aggregator/ws/schemas/swapInfoSchema.ts | 9 ++++++++- src/types.ts | 7 +++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index bfcfeb6..26e7112 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.23", + "version": "0.20.24", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.23", + "version": "0.20.24", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index ed34454..04d614d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.23", + "version": "0.20.24-rc1", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/schemas/swapInfoSchema.ts b/src/services/Aggregator/schemas/swapInfoSchema.ts index 76e963d..d29c82a 100644 --- a/src/services/Aggregator/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/schemas/swapInfoSchema.ts @@ -40,6 +40,13 @@ const swapInfoBase = z.object({ isThroughPoolOrCurve: z.boolean(), }).array(), assetNameMapping: z.record(z.string()).optional(), // address to ERC20 names + usd: z.object({ // USD info of this swap, nullable + aa: z.number(), // available amount in, USD + aao: z.number().optional(), // available amount out, USD + mo: z.number(), // market amount out, USD + mi: z.number().optional(), // market amount in, USD + d: z.number().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage + }).optional(), }); const swapInfoByAmountIn = swapInfoBase.extend({ diff --git a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts index aa79db8..a38e783 100644 --- a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts @@ -40,7 +40,14 @@ const swapInfoSchemaBase = baseMessageSchema.extend({ ai: z.string().toUpperCase(), // asset in ao: z.string().toUpperCase(), // asset out f: factorySchema, // factory - })) + })), + usd: z.object({ // USD info of this swap, nullable + aa: z.number(), // available amount in, USD + aao: z.number().optional(), // available amount out, USD + mo: z.number(), // market amount out, USD + mi: z.number().optional(), // market amount in, USD + d: z.number().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage + }).optional(), }); const swapInfoSchemaByAmountIn = swapInfoSchemaBase.extend({ diff --git a/src/types.ts b/src/types.ts index ecc3568..39ab935 100644 --- a/src/types.ts +++ b/src/types.ts @@ -197,6 +197,13 @@ export type SwapInfoBase = { } | undefined alternatives: SwapInfoAlternative[] assetsNameMapping?: Partial> | undefined + usdInfo?: { + availableAmountIn: number + availableAmountOut?: number + marketAmountIn: number + marketAmountOut?: number + difference: number + } } export type SwapInfoByAmountIn = SwapInfoBase & { From 643a2c846981f705b8d826684c6d3eec71e966a3 Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 28 Nov 2023 06:47:32 +0500 Subject: [PATCH 2/6] fix: types --- package.json | 2 +- src/services/Aggregator/schemas/swapInfoSchema.ts | 2 +- src/services/Aggregator/ws/schemas/swapInfoSchema.ts | 2 +- src/types.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 04d614d..3d5ece1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.24-rc1", + "version": "0.20.24-rc2", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/schemas/swapInfoSchema.ts b/src/services/Aggregator/schemas/swapInfoSchema.ts index d29c82a..85a85a9 100644 --- a/src/services/Aggregator/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/schemas/swapInfoSchema.ts @@ -45,7 +45,7 @@ const swapInfoBase = z.object({ aao: z.number().optional(), // available amount out, USD mo: z.number(), // market amount out, USD mi: z.number().optional(), // market amount in, USD - d: z.number().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage + d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage }).optional(), }); diff --git a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts index a38e783..44d1bd5 100644 --- a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts @@ -46,7 +46,7 @@ const swapInfoSchemaBase = baseMessageSchema.extend({ aao: z.number().optional(), // available amount out, USD mo: z.number(), // market amount out, USD mi: z.number().optional(), // market amount in, USD - d: z.number().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage + d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage }).optional(), }); diff --git a/src/types.ts b/src/types.ts index 39ab935..5882e9a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -202,7 +202,7 @@ export type SwapInfoBase = { availableAmountOut?: number marketAmountIn: number marketAmountOut?: number - difference: number + difference: string } } From 87f9c738a50f701227719badbeecf0be5f8cb1e1 Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 28 Nov 2023 07:16:21 +0500 Subject: [PATCH 3/6] fix: types --- src/services/Aggregator/ws/index.ts | 7 +++++++ src/types.ts | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index a50d62b..d1ce566 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -526,6 +526,13 @@ class AggregatorWS { availableAmountOut: item.aao, })), assetsNameMapping: json.anm, + usdInfo: json.usd && { + availableAmountIn: json.usd.aa, + availableAmountOut: json.usd.aao, + marketAmountOut: json.usd.mo, + marketAmountIn: json.usd.mi, + difference: json.usd.d, + }, }; switch (json.k) { // kind diff --git a/src/types.ts b/src/types.ts index 5882e9a..0e9b681 100644 --- a/src/types.ts +++ b/src/types.ts @@ -199,10 +199,10 @@ export type SwapInfoBase = { assetsNameMapping?: Partial> | undefined usdInfo?: { availableAmountIn: number - availableAmountOut?: number - marketAmountIn: number - marketAmountOut?: number - difference: string + availableAmountOut: number | undefined + marketAmountOut: number + marketAmountIn: number | undefined + difference: string | undefined } } From 111f94be1fc41839858940e7e81ad107f73bab06 Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 28 Nov 2023 07:17:49 +0500 Subject: [PATCH 4/6] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d5ece1..b3bd777 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.24-rc2", + "version": "0.20.24-rc3", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", From 5e932276e78751ef43540bf698b596806f6af12e Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 28 Nov 2023 07:24:42 +0500 Subject: [PATCH 5/6] fix: types --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 0e9b681..c72f377 100644 --- a/src/types.ts +++ b/src/types.ts @@ -197,13 +197,13 @@ export type SwapInfoBase = { } | undefined alternatives: SwapInfoAlternative[] assetsNameMapping?: Partial> | undefined - usdInfo?: { + usdInfo: { availableAmountIn: number availableAmountOut: number | undefined marketAmountOut: number marketAmountIn: number | undefined difference: string | undefined - } + } | undefined } export type SwapInfoByAmountIn = SwapInfoBase & { From 6c770f41f077bb9171b3b70f0c8ddef581607bbb Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 28 Nov 2023 07:31:20 +0500 Subject: [PATCH 6/6] fix: zod --- package.json | 2 +- src/services/Aggregator/schemas/swapInfoSchema.ts | 4 ++-- src/services/Aggregator/ws/schemas/swapInfoSchema.ts | 4 ++-- src/types.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b3bd777..2faf2a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.24-rc3", + "version": "0.20.24-rc4", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/schemas/swapInfoSchema.ts b/src/services/Aggregator/schemas/swapInfoSchema.ts index 85a85a9..049c8bc 100644 --- a/src/services/Aggregator/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/schemas/swapInfoSchema.ts @@ -41,9 +41,9 @@ const swapInfoBase = z.object({ }).array(), assetNameMapping: z.record(z.string()).optional(), // address to ERC20 names usd: z.object({ // USD info of this swap, nullable - aa: z.number(), // available amount in, USD + aa: z.number().optional(), // available amount in, USD aao: z.number().optional(), // available amount out, USD - mo: z.number(), // market amount out, USD + mo: z.number().optional(), // market amount out, USD mi: z.number().optional(), // market amount in, USD d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage }).optional(), diff --git a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts index 44d1bd5..3c8a5d4 100644 --- a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts @@ -42,9 +42,9 @@ const swapInfoSchemaBase = baseMessageSchema.extend({ f: factorySchema, // factory })), usd: z.object({ // USD info of this swap, nullable - aa: z.number(), // available amount in, USD + aa: z.number().optional(), // available amount in, USD aao: z.number().optional(), // available amount out, USD - mo: z.number(), // market amount out, USD + mo: z.number().optional(), // market amount out, USD mi: z.number().optional(), // market amount in, USD d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage }).optional(), diff --git a/src/types.ts b/src/types.ts index c72f377..7511476 100644 --- a/src/types.ts +++ b/src/types.ts @@ -198,9 +198,9 @@ export type SwapInfoBase = { alternatives: SwapInfoAlternative[] assetsNameMapping?: Partial> | undefined usdInfo: { - availableAmountIn: number + availableAmountIn: number | undefined availableAmountOut: number | undefined - marketAmountOut: number + marketAmountOut: number | undefined marketAmountIn: number | undefined difference: string | undefined } | undefined