Convienience class to find routes through a set of Whirlpools and execute a swap across them. The router only supports up to 2-hop trades between pools and does not support arbitrage trades between the same token.

Deprecated

WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.

interface WhirlpoolRouter {
    findAllRoutes(trade, opts?, fetchOpts?): Promise<TradeRoute[]>;
    findBestRoute(trade, opts?, selectionOpts?, fetchOpts?): Promise<null | ExecutableRoute>;
    swap(trade, slippage, resolvedAtas): Promise<TransactionBuilder>;
}

Methods

  • Finds all possible routes for a trade and select the best route that is executable under the current execution environment.

    Parameters

    Returns Promise<null | ExecutableRoute>

    The best ExecutableRoute that can be used to execute a swap. If no executable route is found, null is returned.

    Deprecated

    WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.

  • Construct a TransactionBuilder to help execute a trade route.

    Parameters

    • trade: TradeRoute

      The trade route to execute.

    • slippage: Percentage

      The slippage tolerance for the trade.

    • resolvedAtas: null | AtaAccountInfo[]

      The ATA accounts that the executing wallet owns / needed by the execution. If not provided, the router will attempt to resolve them.

    Returns Promise<TransactionBuilder>

    A TransactionBuilderthat can be used to execute the trade. If provvided from ExecutableRoute, plug the AddressLookupTableAccounts into builder to lower the transaction size.

    Deprecated

    WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.

Generated using TypeDoc