Skip to content

Commit

Permalink
Merge pull request #611 from beethovenxfi/v3-canary
Browse files Browse the repository at this point in the history
fix max depth
  • Loading branch information
franzns authored Dec 21, 2023
2 parents 5e66e21 + c1ab514 commit 0d29395
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 0d29395

Please sign in to comment.