Skip to content

Commit 1335498

Browse files
MEX-966: fix xoxno price impact mapping
Signed-off-by: Claudiu Lataretu <claudiu.lataretu@gmail.com>
1 parent 854ff95 commit 1335498

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/modules/auto-router/services/auto-router.service.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class AutoRouterService {
7070
private readonly composeTasksAbi: ComposableTasksAbiService,
7171
private readonly xoxnoAggregatorService: XoxnoAggregatorService,
7272
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
73-
) { }
73+
) {}
7474

7575
private async getAllPaths(
7676
pairs: PairModel[],
@@ -92,7 +92,7 @@ export class AutoRouterService {
9292
),
9393
Constants.oneMinute() * 10,
9494
);
95-
} catch (error) { }
95+
} catch (error) {}
9696
}
9797

9898
async swap(args: AutoRouterArgs): Promise<AutoRouteModel> {
@@ -162,15 +162,15 @@ export class AutoRouterService {
162162
const [result, tokenInPriceUSD, tokenOutPriceUSD] = await Promise.all([
163163
this.isFixedInput(swapType)
164164
? this.pairService.getAmountOut(
165-
pair.address,
166-
tokenInID,
167-
args.amountIn,
168-
)
165+
pair.address,
166+
tokenInID,
167+
args.amountIn,
168+
)
169169
: this.pairService.getAmountIn(
170-
pair.address,
171-
tokenOutID,
172-
args.amountOut,
173-
),
170+
pair.address,
171+
tokenOutID,
172+
args.amountOut,
173+
),
174174
this.pairCompute.tokenPriceUSD(tokenInID),
175175
this.pairCompute.tokenPriceUSD(tokenOutID),
176176
]);
@@ -244,17 +244,17 @@ export class AutoRouterService {
244244
try {
245245
swapRoute = this.isFixedInput(swapType)
246246
? this.autoRouterComputeService.computeBestSwapRoute(
247-
paths,
248-
pairs,
249-
args.amountIn,
250-
swapType,
251-
)
247+
paths,
248+
pairs,
249+
args.amountIn,
250+
swapType,
251+
)
252252
: this.autoRouterComputeService.computeBestSwapRoute(
253-
paths,
254-
pairs,
255-
args.amountOut,
256-
swapType,
257-
);
253+
paths,
254+
pairs,
255+
args.amountOut,
256+
swapType,
257+
);
258258

259259
[tokenInPriceUSD, tokenOutPriceUSD] = await Promise.all([
260260
this.pairCompute.tokenPriceUSD(tokenInID),
@@ -364,7 +364,7 @@ export class AutoRouterService {
364364
smartSwap: smartSwap ?? undefined,
365365
transactions:
366366
smartSwap?.source === SmartSwapSource.XOXNO &&
367-
xoxnoQuote?.transaction
367+
xoxnoQuote?.transaction
368368
? [xoxnoQuote.transaction]
369369
: undefined,
370370
});
@@ -570,7 +570,7 @@ export class AutoRouterService {
570570
if (
571571
parent.smartSwap.source === SmartSwapSource.INTERNAL &&
572572
parent.smartSwap.tokensPriceDeviationPercent >
573-
parent.maxPriceDeviationPercent
573+
parent.maxPriceDeviationPercent
574574
) {
575575
throw new Error('Spread too big!');
576576
}
@@ -703,11 +703,11 @@ export class AutoRouterService {
703703
intermediaryTokenOut,
704704
intermediaryTokenOutPriceUSD,
705705
] = [
706-
tokensMetadata[index],
707-
tokensPriceUSD[index],
708-
tokensMetadata[index + 1],
709-
tokensPriceUSD[index + 1],
710-
];
706+
tokensMetadata[index],
707+
tokensPriceUSD[index],
708+
tokensMetadata[index + 1],
709+
tokensPriceUSD[index + 1],
710+
];
711711

712712
const amountInUSD = computeValueUSD(
713713
amountIn,
@@ -778,11 +778,11 @@ export class AutoRouterService {
778778
intermediaryTokenOut,
779779
intermediaryTokenOutPriceUSD,
780780
] = [
781-
tokensMetadata.get(tokenInID),
782-
tokensPriceUSD.get(tokenInID),
783-
tokensMetadata.get(tokenOutID),
784-
tokensPriceUSD.get(tokenOutID),
785-
];
781+
tokensMetadata.get(tokenInID),
782+
tokensPriceUSD.get(tokenInID),
783+
tokensMetadata.get(tokenOutID),
784+
tokensPriceUSD.get(tokenOutID),
785+
];
786786

787787
const amountInUSD = computeValueUSD(
788788
amountIn,
@@ -799,11 +799,11 @@ export class AutoRouterService {
799799
amountOutUSD,
800800
)
801801
? new BigNumber(1).minus(
802-
amountInUSD.dividedBy(amountOutUSD),
803-
)
802+
amountInUSD.dividedBy(amountOutUSD),
803+
)
804804
: new BigNumber(1).minus(
805-
amountOutUSD.dividedBy(amountInUSD),
806-
);
805+
amountOutUSD.dividedBy(amountInUSD),
806+
);
807807

808808
if (
809809
priceDeviationPercent.toNumber() >
@@ -943,12 +943,12 @@ export class AutoRouterService {
943943
dex: 'XExchange',
944944
firstToken:
945945
pair.firstToken.identifier ===
946-
allocation.tokenRoute[i]
946+
allocation.tokenRoute[i]
947947
? pair.firstToken
948948
: pair.secondToken,
949949
secondToken:
950950
pair.firstToken.identifier ===
951-
allocation.tokenRoute[i]
951+
allocation.tokenRoute[i]
952952
? pair.secondToken
953953
: pair.firstToken,
954954
}),
@@ -1046,7 +1046,7 @@ export class AutoRouterService {
10461046
tokenOutExchangeRate,
10471047
tokenInMetadata.decimals,
10481048
).toString(),
1049-
tokensPriceDeviationPercent: quote.priceImpact,
1049+
tokensPriceDeviationPercent: quote.priceImpact / 100,
10501050
routes: await this.mapXoxnoPathsToRoutes(quote.paths),
10511051
});
10521052
}

0 commit comments

Comments
 (0)