mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-25 23:27:41 +03:00
is trade buy
This commit is contained in:
@@ -268,12 +268,12 @@ class Aggregator {
|
||||
amount: string,
|
||||
instantSettlement?: boolean,
|
||||
exchanges?: string[] | 'cex' | 'pools',
|
||||
isExactReceive?: boolean,
|
||||
isTradeBuy?: boolean,
|
||||
) => {
|
||||
const url = new URL(`${this.apiUrl}/api/v1/swap`);
|
||||
url.searchParams.append('assetIn', assetIn);
|
||||
url.searchParams.append('assetOut', assetOut);
|
||||
if (isExactReceive !== true) {
|
||||
if (isTradeBuy !== true) {
|
||||
url.searchParams.append('amountIn', amount);
|
||||
} else {
|
||||
url.searchParams.append('amountOut', amount);
|
||||
|
||||
@@ -59,7 +59,7 @@ const swapInfoByAmountIn = swapInfoBase.extend({
|
||||
marketAmountIn: z.null(),
|
||||
}).transform((val) => ({
|
||||
...val,
|
||||
isExactReceive: false as const,
|
||||
isTradeBuy: false as const,
|
||||
}));
|
||||
|
||||
const swapInfoByAmountOut = swapInfoBase.extend({
|
||||
@@ -69,7 +69,7 @@ const swapInfoByAmountOut = swapInfoBase.extend({
|
||||
marketAmountIn: z.number().nullable(),
|
||||
}).transform((val) => ({
|
||||
...val,
|
||||
isExactReceive: true as const,
|
||||
isTradeBuy: true as const,
|
||||
}));
|
||||
|
||||
const swapInfoSchema = swapInfoByAmountIn.or(swapInfoByAmountOut);
|
||||
|
||||
@@ -544,10 +544,10 @@ class AggregatorWS {
|
||||
autoSlippage: json.sl,
|
||||
};
|
||||
|
||||
switch (json.er) { // exactReceive
|
||||
switch (json.tb) { // isTradeBuy
|
||||
case false:
|
||||
this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[json.S]?.callback({
|
||||
isExactReceive: false,
|
||||
isTradeBuy: false,
|
||||
marketAmountOut: json.mo,
|
||||
availableAmountIn: json.aa,
|
||||
...baseSwapInfo,
|
||||
@@ -556,7 +556,7 @@ class AggregatorWS {
|
||||
break;
|
||||
case true:
|
||||
this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[json.S]?.callback({
|
||||
isExactReceive: true,
|
||||
isTradeBuy: true,
|
||||
...baseSwapInfo,
|
||||
marketAmountIn: json.mi,
|
||||
availableAmountOut: json.aao,
|
||||
|
||||
@@ -56,7 +56,7 @@ const swapInfoSchemaByAmountIn = swapInfoSchemaBase.extend({
|
||||
aa: z.number(), // available amount in
|
||||
}).transform((content) => ({
|
||||
...content,
|
||||
er: false as const,
|
||||
tb: false as const, // isTradeBuy
|
||||
}));
|
||||
|
||||
const swapInfoSchemaByAmountOut = swapInfoSchemaBase.extend({
|
||||
@@ -64,7 +64,7 @@ const swapInfoSchemaByAmountOut = swapInfoSchemaBase.extend({
|
||||
aao: z.number(), // available amount out
|
||||
}).transform((content) => ({
|
||||
...content,
|
||||
er: true as const,
|
||||
tb: true as const, // isTradeBuy
|
||||
}));
|
||||
|
||||
const swapInfoSchema = z.union([
|
||||
|
||||
Reference in New Issue
Block a user