Skip to content

SOR - Remove graphTraversalConfig from inputs #1848

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

Merged
merged 1 commit into from
Apr 10, 2025
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
5 changes: 5 additions & 0 deletions .changeset/khaki-plants-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

SOR - Remove graphTraversalConfig from inputs
14 changes: 6 additions & 8 deletions modules/sor/sor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
import { PathWithAmount } from './lib/path';
import { getInputAmount, getOutputAmount } from './lib/utils';

const DEFAULT_MAX_DEPTH = 4;

export class SorService {
async getSorSwapPaths(args: QuerySorGetSwapPathsArgs): Promise<GqlSorGetSwapPaths> {
console.log('getSorSwaps args', JSON.stringify(args));
Expand Down Expand Up @@ -94,7 +96,7 @@ export class SorService {
const swapKind = mapSwapKind(input.swapType);

// retry with different max depth if no paths are found
let swapOptions = this.buildSwapOptions(input.graphTraversalConfig);
let swapOptions = this.buildSwapOptions(DEFAULT_MAX_DEPTH);
let paths = await SOR.getPathsWithPools(
tokenIn,
tokenOut,
Expand All @@ -107,10 +109,7 @@ export class SorService {
);

if (!paths) {
swapOptions = this.buildSwapOptions({
...swapOptions.graphTraversalConfig,
maxNonBoostedPathDepth: swapOptions.graphTraversalConfig.maxNonBoostedPathDepth! + 1,
});
swapOptions = this.buildSwapOptions(DEFAULT_MAX_DEPTH + 1);
paths = await SOR.getPathsWithPools(
tokenIn,
tokenOut,
Expand Down Expand Up @@ -140,13 +139,12 @@ export class SorService {
}
}

private buildSwapOptions(graphTraversalConfig?: GraphTraversalConfig): {
private buildSwapOptions(maxNonBoostedPathDepth: number): {
graphTraversalConfig: GraphTraversalConfig;
} {
return {
graphTraversalConfig: {
maxNonBoostedPathDepth: graphTraversalConfig?.maxNonBoostedPathDepth ?? 4,
...graphTraversalConfig,
maxNonBoostedPathDepth,
},
};
}
Expand Down
1 change: 0 additions & 1 deletion modules/sor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface GetSwapPathsInput {
protocolVersion: number;
considerPoolsWithHooks: boolean;
poolIds?: string[];
graphTraversalConfig?: GraphTraversalConfig;
callDataInput?: (GqlSwapCallDataInput & { wethIsEth: boolean }) | undefined;
}

Expand Down