SushiSwap SDK Integration
The SushiSwap SDK is a TypeScript wrapper around the SushiSwap API.
It provides strongly typed primitives and utilities for working with
tokens, prices, swap quotes, and transaction generation.
This SDK does not replace the API — it builds on top of it with safer,
more expressive abstractions.
Installation
Install the required packages using your package manager of choice:
CODEBLOCK0
CODEBLOCK1
CODEBLOCK2
CODEBLOCK3
How To Use
- 1. Import the appropriate SushiSwap SDK helpers from INLINECODE0
- Select the correct SDK method based on user intent:
- Swap quote →
getQuote()
- Swap execution →
getSwap()
- 3. Provide all required parameters exactly as defined by the SDK types
- Always include a valid
referrer value - Validate inputs (chainId, token addresses, amount, slippage) before execution
- Use returned transaction data exactly as provided for simulation or execution
The SDK is a thin wrapper over the SushiSwap REST API — all routing, pricing, and calldata generation is still performed by the API.
Supported Networks
The SushiSwap SDK exposes the list of supported swap networks via:
CODEBLOCK4
- - Agents and integrators should always check this list before attempting to:
- Fetch a quote
- Generate swap transaction data
- - If a requested chainId is not included:
- The agent must fail early or prompt the user to select a supported network
- Agents must not attempt to guess or hardcode supported chains
This list reflects the networks currently supported by the SushiSwap Aggregator API. The supported networks may change over time and should not be cached indefinitely.
--
Mandatory referrer Parameter
- - The
referrer parameter must be specified when calling getQuote() or INLINECODE7 - The agent or integrator must identify themselves using this field
- Swap-related SDK calls must not be executed without a
referrer value - The SDK must not auto-generate or omit this value on behalf of the integrator
Fee Customization
The SushiSwap SDK supports customized swap fees when using getQuote() or getSwap().
Default fee model
- - Swap-related requests follow an 80/20 fee split by default
-
80% to the integrator (referrer)
-
20% to SushiSwap
- - This split applies unless explicitly overridden by SushiSwap
Custom fee splits
- - Alternative fee splits require a partnership with SushiSwap
- Agents and integrators should not assume custom splits are available. If users request alternative fee splits, agents should direct them to the SushiSwap
team rather than attempting to modify request parameters.
Additional Reference
For detailed SDK examples & execution flow, see:
references/REFERENCE.md
SushiSwap SDK 集成
SushiSwap SDK 是一个围绕 SushiSwap API 的 TypeScript 封装器。
它提供了强类型原语和实用工具,用于处理
代币、价格、兑换报价和交易生成。
该 SDK 不 替代 API —— 它在此基础上构建了更安全、
更具表现力的抽象。
安装
使用你选择的包管理器安装所需包:
bash
pnpm add sushi viem
bash
npm add sushi viem
bash
yarn add sushi viem
bash
bun add sushi viem
使用方法
- 1. 从 sushi/evm 导入适当的 SushiSwap SDK 辅助工具
- 根据用户意图选择正确的 SDK 方法:
- 兑换报价 → getQuote()
- 兑换执行 → getSwap()
- 3. 严格按照 SDK 类型定义提供所有必需参数
- 始终包含有效的 referrer 值
- 在执行前验证输入(chainId、代币地址、数量、滑点)
- 按原样使用返回的交易数据进行模拟或执行
SDK 是 SushiSwap REST API 的轻量封装器 —— 所有路由、定价和调用数据生成仍由 API 执行。
支持的网络
SushiSwap SDK 通过以下方式公开支持的兑换网络列表:
ts
import { SWAPAPISUPPORTEDCHAINIDS } from sushi/evm
- - 代理和集成商在尝试以下操作前应始终检查此列表:
- 获取报价
- 生成兑换交易数据
- 代理必须提前失败或提示用户选择支持的网络
- 代理不得尝试猜测或硬编码支持的网络
此列表反映了 SushiSwap 聚合器 API 当前支持的网络。支持的网络可能随时间变化,不应无限期缓存。
--
强制 referrer 参数
- - 调用 getQuote() 或 getSwap() 时必须指定 referrer 参数
- 代理或集成商必须使用此字段标识自身
- 没有 referrer 值时不得执行与兑换相关的 SDK 调用
- SDK 不得代表集成商自动生成或省略此值
费用定制
使用 getQuote() 或 getSwap() 时,SushiSwap SDK 支持自定义兑换费用。
默认费用模型
- - 与兑换相关的请求默认遵循 80/20 费用分配
-
80% 归集成商(推荐人)
-
20% 归 SushiSwap
- - 除非 SushiSwap 明确覆盖,否则此分配适用
自定义费用分配
- - 替代费用分配需要与 SushiSwap 建立合作关系
- 代理和集成商不应假设自定义分配可用。如果用户请求替代费用分配,代理应引导他们联系 SushiSwap
团队,而不是尝试修改请求参数。
附加参考
有关详细的 SDK 示例和执行流程,请参阅:
references/REFERENCE.md