Smart Swap
This page introduces the Smart Swap functionality provided by the Skip Go API to improve swap speed, price, and customization.
Introduction
Smart Swap refers to a feature set that improves swap speed, price, and control.
It currently allows for:
- External routers (e.g. Hallswap and Osmosis SQS) for better price execution
- Route splitting for better price execution
- EVM swaps
If you’re using the deprecated @skip-router
library, you must use version v4.0.0+ to enable Smart Swap.
We strongly reccomend using the @skip-go/client
TypeScript package, which is actively maintained.
The rest of this document will show you how to use Smart Swap with the @skip-go/client
library. The only changes you’ll notice between this context and the REST API are naming conventions.
Smart Swap Features
Set your Smart Swap settings in your skipClient
function call or REST API request body.
Feature: Use External Routers to Improve Price Execution
The Skip Go API considers multiple internal and external routers to find the route with the best price execution.
Currently supported external swap routers:
- Skip Go API’s in-house Router
- Hallswap’s Dex Aggregator
- Osmosis’s Sidecar Query Service (SQS) (Used in the Osmosis frontend)
Usage
Pass an empty smartSwapOptions
object into your route request.
That’s it! Skip Go API will now consider supported external routers and return the best available option.
Feature: Route Splitting
Route splitting involves dividing a user’s trade into multiple parts and swapping them through different pools. This reduces price impact and can increase the user’s output compared to using a single route. It works especially well when one or both tokens being swapped are commonly paired with other assets on a DEX (e.g., OSMO on Osmosis).
Usage
Pass the splitRoutes
flag in the smartSwapOptions
object.
Response Changes when using Split Routes
We’ve added a new swapType
called SmartSwapExactCoinIn
that’s returned in the routeResponse
and msgsDirectResponse
when the provided route is a split route. This new swapType
has fields that allow for multiple routes, across multiple swap venues.
export type SmartSwapExactCoinIn = {
swapVenue: SwapVenue;
swapRoutes: SwapRoute[];
};
export type SwapRoute = {
swapAmountIn: string;
denomIn: string;
swapOperations: SwapOperation[];
};
Feature: EVM Swaps
Smart Swap supports bidrectional EVM swaps: go from any asset on an EVM chain to any asset on a Cosmos chain and back again. With EVM swaps, users can onboard 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:
Network | Chain ID |
---|---|
Ethereum | 1 |
Polygon | 137 |
Optimism | 10 |
Arbitrum One | 42161 |
Base | 8453 |
BNB Chain | 56 |
Avalanche | 43114 |
Blast | 81457 |
Celo | 42220 |
Usage
Set the evmSwaps
flag to true in the smartSwapOptions
object. If using the deprecated @skip-router
library, you must be on v5.1.0+ (we strongly recommend migrating to @skip-go/client
as soon as possible).
How do EVM Swaps Change the route
Response?
When an EVM swap occurs in a route, a new operation of type evm_swap
is returned in the array of operations
in the v2/route
and v2/msgs_direct
response.
If your API use 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 use the latest Skip Go Client version and decode the operation properly.
The evm_swap
operation type is as follows:
How does this Change the /msgs
and /status
Response?
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; the swap is atomic with the bridging action (Axelar or CCTP), so the same types are used (axelar_transfer_info
and cctp_transfer_info
respectively).
Have questions or feedback? Help us get better!
Join our Discord and select the “Skip Go Developer” role to share your questions and feedback.