介绍
Smart Swap 是一组用于提升兑换速度、价格表现和控制能力的功能。 当前支持:- 使用外部路由以优化价格执行(例如 Hallswap 和 Osmosis SQS)
- 路由拆分,用于优化价格执行
- EVM 兑换
@skip-go/client 库使用 Smart Swap。你会发现它与 REST API 的唯一区别是命名约定。
Smart Swap 功能
在你的skipClient 函数调用或 REST API 请求体中设置 Smart Swap 配置。
功能:使用外部路由以优化价格执行
Skip Go API 会综合多个内部和外部路由器,以找到价格执行效果最佳的路由。 当前支持的外部兑换路由器:- Skip Go API 自研路由器
- Hallswap 的 DEX 聚合器
- Osmosis 的 Sidecar Query Service(SQS,Osmosis 前端正在使用)
用法
将一个空的smartSwapOptions 对象传入路由请求。
功能:路由拆分
路由拆分指将用户的一笔交易分成多个部分,并通过不同的资金池进行兑换。这样可以降低价格冲击,并且相比只使用单一路由,可能提高用户最终得到的输出数量。当待兑换的一个或两个代币在 DEX 上经常与其他资产配对时(例如 Osmosis 上的 OSMO),这一功能尤其有效。用法
在smartSwapOptions 对象中传入 splitRoutes 标志。
使用拆分路由时的响应变化
我们新增了一种名为SmartSwapExactCoinIn 的 swapType。当返回的路由为拆分路由时,它会出现在 routeResponse 和 msgsDirectResponse 中。这个新的 swapType 包含允许跨多个兑换场所使用多条路由的字段。
功能:EVM 兑换
Smart Swap 支持双向 EVM 兑换:你可以从任意 EVM 链上的任意资产兑换到任意 Cosmos 链上的任意资产,也可以反向兑换回来。借助 EVM 兑换,用户只需 1 笔交易,就能从广泛的 EVM 资产接入你的 IBC 互联链,其中也包括散户偏爱持有的 memecoin。 目前,API 支持在 Velodrome(Optimism)和 Aerodrome(Base)上进行 EVM 兑换,也支持在以下链上的官方 Uniswap V3 部署上进行兑换:| 网络 | 链 ID |
|---|---|
| 以太坊 | 1 |
| Polygon | 137 |
| Optimism | 10 |
| Arbitrum One | 42161 |
| Base | 8453 |
| BNB Chain | 56 |
| Avalanche | 43114 |
| Blast | 81457 |
| Celo | 42220 |
用法
在smartSwapOptions 对象中将 evmSwaps 标志设置为 true。如果你使用已弃用的 @skip-router 库,则必须使用 v5.1.0 及以上版本(我们强烈建议尽快迁移到 @skip-go/client)。
EVM 兑换会如何改变 route 响应?
当路由中发生 EVM 兑换时,v2/route 和 v2/msgs_direct 响应里的 operations 数组中会返回一个新的 evm_swap 类型操作。
evm_swap 操作类型如下:
这会如何改变 /msgs 和 /status 响应?
没有特别的新变化。用于 EVM 兑换的 msg_type 与我们所有 EVM 交易使用的 evm_tx 类型相同。同样,也没有新的 transfer_event 类型;兑换与桥接操作(Axelar 或 CCTP)是原子完成的,因此仍分别使用相同的类型(axelar_transfer_info 和 cctp_transfer_info)。
有问题或反馈?欢迎帮助我们做得更好!加入我们的 Discord,并选择“Skip Go Developer”角色来分享你的问题和反馈。
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
@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 yourskipClient 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 emptysmartSwapOptions object into your route request.
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 thesplitRoutes flag in the smartSwapOptions object.
Response Changes when using Split Routes
We’ve added a newswapType 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.
Feature: EVM Swaps
Smart Swap supports bidirectional 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 EVM swapping on Velodrome (Optimism) & Aerodrome (Base), and 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 theevmSwaps 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.
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.