微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🍣

安全高效的 DEX 聚合交易 SDK

sushiswap-sdk · vlatest
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
专业技能 安全 A 级 作者 Unknown 公开目录收录
657 下载 150 安装 2.9k 收藏 8.7k 浏览

简介

基于 SushiSwap 官方 API 的 TypeScript 开发套件,提供强类型代币操作与交易生成功能,帮助开发者安全集成去中心化兑换能力。

原始描述

>

通过你的 Agent 添加

安装目录:sushiswap-sdk-5737/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/sushiswap-sdk-5737/
Codex CLI~/.codex/skills/sushiswap-sdk-5737/
DeepSeek Harness~/.agents/skills/sushiswap-sdk-5737/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

SushiSwap SDK 是 SushiSwap Aggregator API 的 TypeScript 封装层,核心功能包括:

  1. 强类型原语:提供 Token、Amount、Price、Fraction 等类型,消除 JavaScript 浮点运算误差
  2. 报价与执行:getQuote() 获取兑换报价,getSwap() 生成可执行交易数据
  3. 网络支持:通过 SWAP_API_SUPPORTED_CHAIN_IDS 动态查询支持的链,避免硬编码

使用流程

  • 安装依赖:sushi + viem(以太坊交互库)
  • 从 sushi/evm 导入所需方法
  • 验证输入参数(chainId、代币地址、金额、滑点)
  • 调用 API 获取结果,直接用于交易模拟或执行

关键约束

  • 必须指定 referrer:所有 getQuote()/getSwap() 调用需明确标识集成方
  • 默认 80/20 手续费分成:集成方获 80%,SushiSwap 获 20%;自定义分成需官方合作

显著优点

  • 类型安全:完整 TypeScript 类型覆盖,编译期捕获错误
  • API 封装:比原始 HTTP 请求更简洁,自动处理序列化和错误格式化
  • DeFi 生态兼容:基于 viem 构建,与以太坊工具链深度整合
  • 零可执行代码风险:纯文档型 Skill,无隐藏逻辑

潜在缺点与局限性

  • 依赖外部 API:路由和定价完全依赖 SushiSwap 服务端,存在单点故障
  • 网络支持变动:SWAP_API_SUPPORTED_CHAIN_IDS 可能变化,需避免长期缓存
  • T3 来源可信度:由个人开发者维护(0xmasayoshi),非 SushiSwap 官方直接发布
  • 无自定义手续费:普通用户无法修改 80/20 分成比例

适合人群

  • DeFi 协议开发者:需要集成 DEX 聚合功能的 dApp 团队
  • 量化交易工具构建者:需要程序化获取报价和执行交易
  • TypeScript/Node.js 开发者:偏好强类型、SDK 封装而非裸 HTTP 调用
  • 学习目的用户:了解 DeFi SDK 设计模式和最佳实践

常规风险

风险类型 说明 缓解措施
依赖冒名攻击 npm 包名拼写相似(如 sushl) 从官方 registry 安装,验证包名
API 服务中断 SushiSwap API 不可用 实现降级逻辑,测试网预演
私钥泄露 示例代码使用环境变量存储私钥 使用硬件钱包/密钥管理服务,测试网先行
滑点损失 市场波动导致实际兑换率偏离 合理设置 maxSlippage,大额拆分执行
合约风险 SushiSwap 智能合约漏洞 关注官方安全审计和漏洞公告

技能正文


name: sushiswap-sdk description: > TypeScript SDK for interacting with the SushiSwap Aggregator and related primitives. This SDK is a typed wrapper over the SushiSwap API, providing ergonomic helpers for token amounts, prices, quotes, and swap transaction generation.

USE THIS SKILL WHEN:

  • Building TypeScript or JavaScript applications
  • You want strongly typed token, amount, and fraction primitives
  • You need to request swap quotes or executable swap transactions via code
  • You want safer arithmetic, formatting, and comparisons without floating point errors
  • You prefer SDK-based integration over raw HTTP requests

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:

pnpm add sushi viem
npm add sushi viem
yarn add sushi viem
bun add sushi viem

How To Use

  1. Import the appropriate SushiSwap SDK helpers from sushi/evm
  2. 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
  4. Always include a valid referrer value
  5. Validate inputs (chainId, token addresses, amount, slippage) before execution
  6. 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:

import { SWAP_API_SUPPORTED_CHAIN_IDS } from 'sushi/evm'
  • 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 getSwap()
  • 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

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

finance-accountingdevelopment-engineeringbackendapiblockchain

同类 Skill