关于 grimoire-pendle
grimoire-pendle 是用于检查 Pendle 元数据并预检路由配置的技能,面向编写和运行 spell 的工作流。它可查询市场与代币信息,并支持 Pendle 资产符号解析及路由输出比较。
主要功能
- 01查询支持的链与聚合器
- 02列出市场和资产
- 03查询市场代币地址
- 04在构建时解析 PT、YT、SY 符号
- 05比较路由输出报价
适用场景
- 01编写 spell 前发现并选择市场
- 02获取市场对应的 PT、YT、SY 代币地址
- 03检查路由配置及报价输出
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ franalgaba/ grimoire --skill grimoire-pendle安装后在 Claude Code 中输入/grimoire-pendle确认已加载。
详细介绍
Grimoire Pendle 技能
使用此技能检查 Pendle 元数据,并在运行 spells 前预检 Pendle 路由配置。
推荐调用方式:
grimoire venue pendle ...npx -y @grimoirelabs/cli venue pendle ...(无需安装)bun run packages/cli/src/index.ts venue pendle ...(仓库本地)grimoire-pendle ...(来自@grimoirelabs/venues的直接二进制文件)
推荐的预检命令:
grimoire venue doctor --adapter pendle --chain 1 --rpc-url <rpc> --json
命令
grimoire venue pendle info [--base-url <url>] [--format <auto|json|table>]grimoire venue pendle chains [--base-url <url>] [--format <auto|json|table>]grimoire venue pendle supported-aggregators --chain <id> [--base-url <url>] [--format <auto|json|table>]grimoire venue pendle markets [--chain <id>] [--active <true|false>] [--base-url <url>] [--format <auto|json|table>]grimoire venue pendle assets [--chain <id>] [--type <PT|YT|LP|SY>] [--base-url <url>] [--format <auto|json|table>]grimoire venue pendle market-tokens --chain <id> --market <address> [--base-url <url>] [--format <auto|json|table>]
示例
grimoire venue pendle info --format table
grimoire venue pendle chains
grimoire venue pendle supported-aggregators --chain 1 --format json
grimoire venue pendle markets --chain 1 --active true --format table
grimoire venue pendle assets --chain 8453 --type PT --format table
grimoire venue pendle market-tokens --chain 8453 --market 0x... --format json
编写工作流
Pendle 要求优先查询市场。请勿在查询可用市场之前编写 Pendle spell。
-
查询市场,确定目标链和底层资产:
grimoire venue pendle markets --chain 1 --active true --format json -
选择市场——记下其地址和到期时间。每个市场都有特定的 PT/YT/SY 代币。
-
查询市场代币,获取准确的代币地址:
grimoire venue pendle market-tokens --chain 1 --market 0x... --format json -
编写 spell,使用第 3 步获取的代币地址:
pendle.add_liquidity(0x<SY_address>, params.amount) with (max_slippage=100)
常见错误
pendle.deposit(USDC, ...)——Pendle 没有deposit操作。请使用add_liquidity、mint_py、mint_sy或swap。- 使用不带地址的代币符号——PT/YT/SY 代币会通过 Pendle API 自动解析,但 USDC 等标准代币需要使用以该代币最小单位表示的原始数量。
- 缺少
enable_aggregator——某些路由需要聚合器。如果未找到路由,请在with()子句中设置enable_aggregator=true后重试。
支持的操作
| 操作 | 描述 | 输入 | 输出 |
|---|---|---|---|
swap | 在任意 Pendle 代币之间兑换 | 单个代币 | 单个代币 |
add_liquidity | 添加单边流动性 | 底层资产/SY | LP 代币 |
remove_liquidity | 移除单边流动性 | LP 代币 | 底层资产/SY |
mint_py | 使用底层资产铸造 PT + YT | 底层资产/SY | PT + YT |
redeem_py | 将 PT + YT 赎回为底层资产 | PT + YT | 底层资产/SY |
mint_sy | 将底层资产封装为 SY | 底层资产 | SY |
redeem_sy | 将 SY 解封装为底层资产 | SY | 底层资产 |
指标接口(Spell 比较)
Pendle 提供 quote_out,用于比较路由输出:
pendle_out = metric("quote_out", pendle, USDC, "asset_out=DAI,amount=1000000,slippage_bps=1000")
选择器字段:
- 必填:
asset_out - 可选:
amount(默认为输入资产的 1 个单位)、slippage_bps、enable_aggregator
Spell 约束
在 .spell 文件中编写 Pendle 操作时,请使用 with 子句:
pendle.swap(PT_TOKEN, SY_TOKEN, params.amount) with (
max_slippage=100,
require_quote=true,
)
| 约束 | 类型 | 描述 |
|---|---|---|
max_slippage | integer (bps) | 最大滑点,验证为 [0, 10000] 范围内的整数,并转换为小数后传入 API |
min_output | integer (wei) | 最小输出数量下限 |
require_quote | boolean | 如果 Pendle API 报价失败则报错 |
max_gas | integer (wei) | Gas 估算上限 |
Pendle swap 仅支持 mode: exact_in。不支持 exact_out。
当 Pendle API 返回多条路由时,适配器会选择第一条(最优)路由,并通过 onWarning 发出警告。此警告会记录在非 JSON 格式的 CLI 运行中。
PT/YT/SY 代币解析
Pendle PT、YT 和 SY 代币(例如 PT_FXSAVE、YT_EETH、SY_WSTETH)会在构建时通过 Pendle API 自动解析。你可以直接在 spells 中使用这些符号,无需提供明确的地址:
pendle.swap(PT_FXSAVE, USDC, params.amount) with (max_slippage=100)
适配器会将以下划线分隔的名称(例如 PT_FXSAVE)转换为 Pendle API 格式,并选择最匹配的结果。如果存在多个到期时间,则会选择第一个(最近的)。
若要指定到期时间或消除歧义,请改用完整的 0x 地址:
pendle.swap(0xb1e926428ebec4421cce1ec6d9ff65d27f4b4bb6, USDC, params.amount)
使用 grimoire venue pendle assets --chain <id> --type PT 查找可用代币及其地址。
备注
- 默认 API 基础 URL 为
https://api-v2.pendle.finance/core。 - 使用
--base-url或PENDLE_API_BASE_URL覆盖基础 URL。 - 自动化处理和嵌套负载请使用
--format json。 - Pendle
swap目前仅支持mode: exact_in。 - 除非明确启用,否则适配器操作默认禁用聚合器。
- 对于 Pendle 代币输出(
assetOut、outputs),请使用不带引号的地址字面量(0x...),不要使用带引号的字符串(\"0x...\")。 - 带引号的类地址代币值会触发验证器代码
QUOTED_ADDRESS_LITERAL。 max_slippage会被验证为[0, 10000]范围内的整数 bps,并在 API 请求前转换为小数(bps / 10000)。