Skip to content

Commit

Permalink
fix max depth
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Dec 21, 2023
1 parent af7332a commit c1ab514
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions modules/sor/sorV2/sorV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ export class SorV2Service implements SwapService {
{ chain, tokenIn, tokenOut, swapType, swapAmount, graphTraversalConfig }: GetSwapsInput,
maxNonBoostedPathDepth = 4,
): Promise<SwapResult> {
const MAX_INCREASED_PATH_DEPTH = maxNonBoostedPathDepth + 1;
try {
const poolsFromDb = await this.getBasePools(chain);
const tIn = await getToken(tokenIn as Address, chain);
Expand All @@ -312,15 +311,12 @@ export class SorV2Service implements SwapService {
maxNonBoostedPathDepth,
);
const swap = await sorGetSwapsWithPools(tIn, tOut, swapKind, swapAmount, poolsFromDb, config);
if (!swap && maxNonBoostedPathDepth < MAX_INCREASED_PATH_DEPTH) {
if (!swap && maxNonBoostedPathDepth < 5) {
return this.getSwapResult(arguments[0], maxNonBoostedPathDepth + 1);
}
return new SwapResultV2(swap, chain);
} catch (err: any) {
if (
err.message.includes('No potential swap paths provided') &&
maxNonBoostedPathDepth < MAX_INCREASED_PATH_DEPTH
) {
if (err.message.includes('No potential swap paths provided') && maxNonBoostedPathDepth < 5) {
return this.getSwapResult(arguments[0], maxNonBoostedPathDepth + 1);
}
console.error(
Expand Down

0 comments on commit c1ab514

Please sign in to comment.