@defisaver/sdk

中文文档
1.3.39发布于 2026/11/05ISCTypeScriptESM + CJS构建来源已验证近 30 天下载 3317

Build actions and combine them into recipes for DeFi Saver smart wallets.

原始使用文档
文档目录4 节
  1. Installation
  2. Example
  3. Testing
  4. Building

DeFi Saver SDK

Build actions and combine them into recipes for DeFi Saver smart wallets.

Installation

npm install @defisaver/sdk

Example

Encode a recipe that wraps 0.1 ETH into WETH on Ethereum:

const { configure, Recipe, actions } = require('@defisaver/sdk');

async function main() {
  configure({ chainId: 1, testingMode: false });

  const recipe = new Recipe('Wrap ETH', [
    new actions.basic.WrapEthAction('100000000000000000'),
  ]);

  const [target, data] = recipe.encodeForDsProxyCall();
  const value = await recipe.getEthValue();
  console.log({ target, data, value });
}

main().catch(console.error);

Amounts use token base units as decimal strings. Here, value is the ETH amount in wei. target and data are arguments for the smart wallet's execute(address,bytes) call; encoding does not submit a transaction.

Testing

From a local checkout, install dependencies with npm ci, then run:

# Run offline tests (no RPC required)
npm run test:unit

# Run all tests, including RPC-dependent wallet tests
npm test

# Run a single test file (test/Recipe.js)
npm run test-single --name=Recipe

The full suite requires RPC in your environment or a local .env file for the wallet tests. Point it at a local or forked test chain.

Building

npm run build

Builds the package and runs lint with automatic fixes. To check lint without changing files, use npm run lint-check.

版本与发布记录

@defisaver/sdk 共发布 356 个版本,首次发布于 2021/04/12;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.39latest2026/11/057 天前
1.3.382026/11/047 天前
1.3.372026/10/2913 天前
1.3.38-semi-continuous-devdev2026/10/2815 天前
1.3.37-semi-continuous-dev2026/10/2815 天前
1.3.35-npm-token-dev2026/10/1329 天前

其他发布通道:beta → 1.0.19,dev-morpho → 1.3.14-dev-morpho-2,dev → 1.3.38-semi-continuous-dev。

关于 @defisaver/sdk 的常见问题

@defisaver/sdk 是什么?

Build actions and combine them into recipes for DeFi Saver smart wallets.

如何安装 @defisaver/sdk?

在项目目录运行 npm install @defisaver/sdk,或使用 pnpm add / yarn add / bun add。

@defisaver/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@defisaver/sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@defisaver/sdk 可以商用吗?

@defisaver/sdk 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@defisaver/sdk 的下载量有多少?

根据 npm 官方下载统计,@defisaver/sdk 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,317 次,日均约 111 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@defisaver/sdk 还在维护吗?

最新版本 1.3.39 发布于 2026/11/05(7 天前);至今共发布 356 个版本,其中过去 12 个月发布了 54 个;首次发布于 2021/04/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。