Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding SORv2 priceImpact in basis points #585

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/beethoven/balancer-sor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class BalancerSorService {
marketSp: string;
swaps: SwapV2[];
tokenAddresses: string[];
priceImpact?: string;
}): GqlSorGetSwapsResponse {
const {
tokenIn,
Expand All @@ -164,6 +165,7 @@ export class BalancerSorService {
marketSp,
swaps,
tokenAddresses,
priceImpact: rawPriceImpact,
} = swapData;

const tokenInAmountFixed = formatFixed(tokenInAmtEvm, this.getTokenDecimals(tokenIn, tokens));
Expand Down Expand Up @@ -214,7 +216,7 @@ export class BalancerSorService {
})),
effectivePrice: effectivePrice.toString(),
effectivePriceReversed: effectivePriceReversed.toString(),
priceImpact: priceImpact.toString(),
priceImpact: rawPriceImpact ? rawPriceImpact : priceImpact.toString(),
};
}

Expand Down
2 changes: 2 additions & 0 deletions modules/sor/sorV2/sorV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SwapResultV2 implements SwapResult {
): Promise<GqlSorGetSwapsResponse> {
const sor = new BalancerSorService();
const tokens = await tokenService.getTokens();
const priceImpact = swap.priceImpact.percentage.toFixed(4);
let poolIds: string[];
if (swap.isBatchSwap) {
const swaps = swap.swaps as BatchSwapStep[];
Expand Down Expand Up @@ -130,6 +131,7 @@ class SwapResultV2 implements SwapResult {
marketSp: '0', // Daniel confirmed returning 0 should be fine here
swaps: this.mapSwaps(swap.swaps, swap.assets),
tokenAddresses: swap.assets,
priceImpact,
};
return sor.formatResponse(swapData);
}
Expand Down