mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-04-10 04:57:31 +03:00
remove exactReceive
This commit is contained in:
@@ -263,7 +263,6 @@ class Aggregator {
|
||||
);
|
||||
|
||||
getSwapInfo = (
|
||||
type: 'exactSpend' | 'exactReceive',
|
||||
assetIn: string,
|
||||
assetOut: string,
|
||||
amount: string,
|
||||
@@ -273,11 +272,8 @@ class Aggregator {
|
||||
const url = new URL(`${this.apiUrl}/api/v1/swap`);
|
||||
url.searchParams.append('assetIn', assetIn);
|
||||
url.searchParams.append('assetOut', assetOut);
|
||||
if (type === 'exactSpend') {
|
||||
url.searchParams.append('amountIn', amount);
|
||||
} else {
|
||||
url.searchParams.append('amountOut', amount);
|
||||
}
|
||||
url.searchParams.append('amountIn', amount);
|
||||
|
||||
if (exchanges !== undefined) {
|
||||
if (Array.isArray(exchanges)) {
|
||||
exchanges.forEach((exchange) => {
|
||||
|
||||
@@ -57,21 +57,8 @@ const swapInfoByAmountIn = swapInfoBase.extend({
|
||||
availableAmountIn: z.number(),
|
||||
marketAmountOut: z.number().nullable(),
|
||||
marketAmountIn: z.null(),
|
||||
}).transform((val) => ({
|
||||
...val,
|
||||
type: 'exactSpend' as const,
|
||||
}));
|
||||
});
|
||||
|
||||
const swapInfoByAmountOut = swapInfoBase.extend({
|
||||
availableAmountOut: z.number(),
|
||||
availableAmountIn: z.null(),
|
||||
marketAmountOut: z.null(),
|
||||
marketAmountIn: z.number().nullable(),
|
||||
}).transform((val) => ({
|
||||
...val,
|
||||
type: 'exactReceive' as const,
|
||||
}));
|
||||
|
||||
const swapInfoSchema = swapInfoByAmountIn.or(swapInfoByAmountOut);
|
||||
const swapInfoSchema = swapInfoByAmountIn;
|
||||
|
||||
export default swapInfoSchema;
|
||||
|
||||
@@ -544,27 +544,11 @@ class AggregatorWS {
|
||||
autoSlippage: json.sl,
|
||||
};
|
||||
|
||||
switch (json.k) { // kind
|
||||
case 'exactSpend':
|
||||
this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[json.S]?.callback({
|
||||
kind: json.k,
|
||||
marketAmountOut: json.mo,
|
||||
availableAmountIn: json.aa,
|
||||
...baseSwapInfo,
|
||||
});
|
||||
|
||||
break;
|
||||
case 'exactReceive':
|
||||
this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[json.S]?.callback({
|
||||
kind: json.k,
|
||||
...baseSwapInfo,
|
||||
marketAmountIn: json.mi,
|
||||
availableAmountOut: json.aao,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[json.S]?.callback({
|
||||
marketAmountOut: json.mo,
|
||||
availableAmountIn: json.aa,
|
||||
...baseSwapInfo,
|
||||
});
|
||||
}
|
||||
break;
|
||||
case MessageType.INITIALIZATION:
|
||||
|
||||
@@ -54,22 +54,9 @@ const swapInfoSchemaBase = baseMessageSchema.extend({
|
||||
const swapInfoSchemaByAmountIn = swapInfoSchemaBase.extend({
|
||||
mo: z.number().optional(), // market amount out
|
||||
aa: z.number(), // available amount in
|
||||
}).transform((content) => ({
|
||||
...content,
|
||||
k: 'exactSpend' as const,
|
||||
}));
|
||||
});
|
||||
|
||||
const swapInfoSchemaByAmountOut = swapInfoSchemaBase.extend({
|
||||
mi: z.number().optional(), // market amount in
|
||||
aao: z.number(), // available amount out
|
||||
}).transform((content) => ({
|
||||
...content,
|
||||
k: 'exactReceive' as const,
|
||||
}));
|
||||
|
||||
const swapInfoSchema = z.union([
|
||||
swapInfoSchemaByAmountIn,
|
||||
swapInfoSchemaByAmountOut,
|
||||
]);
|
||||
const swapInfoSchema = swapInfoSchemaByAmountIn;
|
||||
|
||||
export default swapInfoSchema;
|
||||
|
||||
Reference in New Issue
Block a user