Introduction

Smart Swap refers to a broad range of functionality we’re building out to improve swap speed, price, and customization.

At this time, the main use case for smart swap is improving trade execution price by enabling third-party routers (e.g. Hallswap) and trade splitting. But much more is on the way!

This doc covers:

  • All the different features Smart Swap enables
  • Describes how to use each of them

@skip-router 4.0.0+ required

If you’re using the deprecated @skip-router library, you must use v4.0.0 or later to use Smart Swap.

We advise all integators to use the new @skip-go/core TypeScript Package, which is being actively maintained and developed.

How to Use Smart Swap

All Smart Swap features are controlled with a single configuration object:

  1. @skip-go/core Package: smartSwapOptions object passed inSkipRouter.route options SkipRouter.msgsDirect options
  2. REST API: smart_swap_options parameter passed in /v2/fungible/route and /v2/fungible/msgs_direct

Read on for more info about the individual features and how to use each of them.

(For the rest of this doc, examples will show how to use Smart Swap with the @skip-go/core library by configuring it on SkipRouter.route. The only changes you’ll notice between this context and the REST API is naming conventions)

Smart Swap Features

Feature: Use 3rd-party routers to improve price

What is it

The Skip Go API searches over multiple 1st and 3rd-party routers to find the route that gives you best execution. This has a chance of improving the price at which your user’s swap executes.

The swap routers currently supported are:

  1. Skip Go API’s in-house Router
  2. Hallswap’s Dex Aggregator
  3. Osmosis’s Sidecar Query Service (SQS) (Used in the Osmosis frontend)

How to use it

Just pass the smartSwapOptions object into your route request. You’re not required to activate a particular flag.

TypeScript
const route = await skipClient.route({
  smartSwapOptions: {}, // smart swap object
  sourceAssetDenom: "uusdc",
  sourceAssetChainID: "noble-1",
  destAssetDenom: "utia",
  destAssetChainID: "celestia",
  amountIn: "1000000", // 1 uusdc
  cumulativeAffiliateFeeBPS: "0"
}

That’s it! Skip Go API will now consider all routers we have available and give your user the best one.

Feature: Route Splitting

What is it

Route splitting is a technique in swap optimization where a user’s trade is split into several parts and swapped through separate pools. It can help lower price impact and increase output for the user, compared to swapping with a single route. This technique is especially effective when one or both of the tokens the user is swapping is a commonly paired asset on a DEX (e.g. OSMO is paired with almost everything on Osmosis).

How to use it

Just pass the splitRoutes flag in the smartSwapOptions object.

TypeScript
const route = await skipClient.route({
  smartSwapOptions: {
    splitRoutes: true
  }, // smart swap object
  sourceAssetDenom: "uusdc",
  sourceAssetChainID: "noble-1",
  destAssetDenom: "utia",
  destAssetChainID: "celestia",
  amountIn: "1000000", // 1 uusdc
  cumulativeAffiliateFeeBPS: "0"
}

Feature: EVM Swaps

What is it

The API supports swapping on an EVM chain, followed by a CCTP/Axelar transfer over to the Cosmos ecosystem. This allows a user to onboard on to your IBC connected chain in 1 transaction from a broad range of EVM assets, including the memecoins retail loves to hold!

Currently, the API supports swapping on official Uniswap V3 deployments on the following chains (and their respective chain IDs):

  1. Ethereum (1)
  2. Polygon (137)
  3. Optimism (10)
  4. Arbitrum One (42161)
  5. Base (8453)
  6. BNB Chain (56)
  7. Avalanche (43114)
  8. Blast (81457)
  9. Celo (42220) - SOON

How to use it

Just set the evmSwaps flag to true in the smartSwapOptions object. If using the deprecated @skip-router library, you must be on version 5.1.0 or above (we advise you migrate over to @skip-go/core as soon as possible).

What to expect from the route response

When an EVM swap occurs in a route, a new operation type evm_swap is returned in the array of operations in the v2/route and v2/msgs_direct responses. If your API usage follows the v2/route then v2/msgs call pattern, this new operation type must be passed to the v2/msgs endpoint, so make sure you are on the latest Skip Go Core version and/or are decoding the operation properly. The evm_swap operation type is as follows:

What to expect differently from the /msgs and /status responses

Nothing new in particular! The msg_type used for EVM swaps is the same evm_tx type used for all of our EVM transactions. Similarly, there is no new transfer_event type to be aware of, since the swap is atomic with the bridging action (Axelar or CCTP), the same types are used (axelar_transfer_info and cctp_transfer_info respectively).

Response Changes using Smart Swap

We’ve added a new swapType called SmartSwapExactCoinIn you can expect to be returned in the routeResponse and msgsDirectResponse to take advantage of the new capabilities Smart Swaps offers! This new swap type has fields that allow for multiple routes, across multiple swap venues.

  • Note: this new SmartSwapExactCoinIn type will currently only be returned if the route provided back is a split route.
type
export type SmartSwapExactCoinIn = {
  swapVenue: SwapVenue;
  swapRoutes: SwapRoute[];
};

export type SwapRoute = {
  swapAmountIn: string;
  denomIn: string;
  swapOperations: SwapOperation[];
};

Want to help us get better? Have questions or feedback?

You can reach us easily by joining our Discord and grabbing the “Skip Go Developer” role.