Skip to content

Unable to set protocols (v2 or v3) for AlphaRouter.routeToRatio #772

Open
@hubagaspar91

Description

@hubagaspar91
  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

No matter what you set as protocols in the parameters of AlphaRouter.routeToRatio, it seems it gets overwritten inside the method to [Protocol.V2, Protocol.V3] (https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/alpha-router.ts#L1141).

This causes problems with our integration, where we want to specifically force to only use V3. Moreover, this seems like an unreasonable implicit behavior, and it should be configurable from the outside.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Something like this would make way more sense (with the inclusion of checks before this, to throw or return error if Protocol.Mixed is passed, as it seems from the comment that that option is not handled):

swap = await this.route(
    amountToSwap,
    outputBalance.currency,
    TradeType.EXACT_INPUT,
    undefined,
    {
      ...DEFAULT_ROUTING_CONFIG_BY_CHAIN(this.chainId),
      ...routingConfig,
      protocols: routingConfig.protocols || [Protocol.V3, Protocol.V2],
    }
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions