mcpField
S
simple-earn

simple-earn

github.com/binance其他1.1k1.1k 次安装2 天前更新
代码仓库

关于 simple-earn

面向管理 Binance Simple Earn、BFUSD 和 RWUSD 产品的用户,通过已认证的 API 处理账户、订阅、赎回及历史记录请求。部分端点需要 API 密钥和密钥签名,结果以 JSON 返回。

主要功能

  1. 01查询 Simple Earn 账户与持仓
  2. 02查看灵活及锁定产品列表
  3. 03预览并执行订阅或赎回
  4. 04设置自动申购与赎回选项
  5. 05查询奖励、利率及交易历史

适用场景

  1. 01检查产品额度与账户持仓
  2. 02订阅或赎回 Earn 产品
  3. 03查看 BFUSD 或 RWUSD 历史
  4. 04调整自动申购和赎回去向

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/binance/binance-skills-hub --skill simple-earn

安装后在 Claude Code 中输入/simple-earn确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

CHANGELOG.md
LICENSE.md
references/
authentication.md

详细介绍

Binance Simple-earn 技能

通过经过身份验证的 API 端点在 Binance 上发起 Simple-earn 请求。某些端点需要 API key 和 secret key。以 JSON 格式返回结果。

快速参考

端点描述必填可选身份验证
/sapi/v1/bfusd/account (GET)获取 BFUSD 账户(USER_DATA)NonerecvWindow是
/sapi/v1/bfusd/quota (GET)获取 BFUSD 额度详情(USER_DATA)NonerecvWindow是
/sapi/v1/bfusd/redeem (POST)赎回 BFUSD(TRADE)amount, typerecvWindow是
/sapi/v1/bfusd/subscribe (POST)申购 BFUSD(TRADE)asset, amountrecvWindow是
/sapi/v1/bfusd/history/rateHistory (GET)获取 BFUSD 利率历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/bfusd/history/redemptionHistory (GET)获取 BFUSD 赎回历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/bfusd/history/rewardsHistory (GET)获取 BFUSD 奖励历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/bfusd/history/subscriptionHistory (GET)获取 BFUSD 申购历史记录(USER_DATA)Noneasset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/personalLeftQuota (GET)获取活期个人剩余额度(USER_DATA)productIdrecvWindow是
/sapi/v1/simple-earn/flexible/position (GET)获取活期产品持仓(USER_DATA)Noneasset, productId, current, size, recvWindow是
/sapi/v1/simple-earn/locked/personalLeftQuota (GET)获取定期个人剩余额度(USER_DATA)projectIdrecvWindow是
/sapi/v1/simple-earn/locked/position (GET)获取定期产品持仓Noneasset, positionId, projectId, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/list (GET)获取 Simple Earn 活期产品列表(USER_DATA)Noneasset, current, size, recvWindow是
/sapi/v1/simple-earn/locked/list (GET)获取 Simple Earn 定期产品列表(USER_DATA)Noneasset, current, size, recvWindow是
/sapi/v1/simple-earn/account (GET)Simple 账户(USER_DATA)NonerecvWindow是
/sapi/v1/simple-earn/flexible/subscriptionPreview (GET)获取活期申购预览(USER_DATA)productId, amountrecvWindow是
/sapi/v1/simple-earn/locked/subscriptionPreview (GET)获取定期申购预览(USER_DATA)projectId, amountautoSubscribe, recvWindow是
/sapi/v1/simple-earn/flexible/redeem (POST)赎回活期产品(TRADE)productIdredeemAll, amount, destAccount, recvWindow是
/sapi/v1/simple-earn/locked/redeem (POST)赎回定期产品(TRADE)positionIdrecvWindow是
/sapi/v1/simple-earn/flexible/setAutoSubscribe (POST)设置活期自动申购(USER_DATA)productId, autoSubscriberecvWindow是
/sapi/v1/simple-earn/locked/setAutoSubscribe (POST)设置定期自动申购(USER_DATA)positionId, autoSubscriberecvWindow是
/sapi/v1/simple-earn/locked/setRedeemOption (POST)设置定期产品赎回选项(USER_DATA)positionId, redeemTorecvWindow是
/sapi/v1/simple-earn/flexible/subscribe (POST)申购活期产品(TRADE)productId, amountautoSubscribe, sourceAccount, recvWindow是
/sapi/v1/simple-earn/locked/subscribe (POST)申购定期产品(TRADE)projectId, amountautoSubscribe, sourceAccount, redeemTo, recvWindow是
/sapi/v1/simple-earn/flexible/history/collateralRecord (GET)获取抵押记录(USER_DATA)NoneproductId, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/history/redemptionRecord (GET)获取活期赎回记录(USER_DATA)NoneproductId, redeemId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/history/rewardsRecord (GET)获取活期奖励历史记录(USER_DATA)typeproductId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/history/subscriptionRecord (GET)获取活期申购记录(USER_DATA)NoneproductId, purchaseId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/locked/history/redemptionRecord (GET)获取定期赎回记录(USER_DATA)NonepositionId, redeemId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/locked/history/rewardsRecord (GET)获取定期奖励历史记录(USER_DATA)NonepositionId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/locked/history/subscriptionRecord (GET)获取定期申购记录(USER_DATA)NonepurchaseId, asset, startTime, endTime, current, size, recvWindow是
/sapi/v1/simple-earn/flexible/history/rateHistory (GET)获取利率历史记录(USER_DATA)productIdaprPeriod, startTime, endTime, current, size, recvWindow是
/sapi/v1/rwusd/quota (GET)获取 RWUSD 额度详情(USER_DATA)NonerecvWindow是
/sapi/v1/rwusd/account (GET)获取 RWUSD 账户(USER_DATA)NonerecvWindow是
/sapi/v1/rwusd/redeem (POST)赎回 RWUSD(TRADE)amount, typerecvWindow是
/sapi/v1/rwusd/subscribe (POST)申购 RWUSD(TRADE)asset, amountrecvWindow是
/sapi/v1/rwusd/history/rateHistory (GET)获取 RWUSD 利率历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/rwusd/history/redemptionHistory (GET)获取 RWUSD 赎回历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/rwusd/history/rewardsHistory (GET)获取 RWUSD 奖励历史记录(USER_DATA)NonestartTime, endTime, current, size, recvWindow是
/sapi/v1/rwusd/history/subscriptionHistory (GET)获取 RWUSD 申购历史记录(USER_DATA)Noneasset, startTime, endTime, current, size, recvWindow是

参数

通用参数
  • recvWindow:值不能大于 60000(毫秒)(例如,5000)
  • amount:金额(例如,1.0)
  • type:FAST 或 STANDARD,默认为 STANDARD(例如,s)
  • asset:USDT 或 USDC(以符合条件者为准)
  • startTime:(例如,1623319461670)
  • endTime:(例如,1641782889000)
  • current:当前查询页码。从 1 开始。默认值:1(例如,1)
  • size:每页结果数。默认值:10,最大值:100(例如,10)
  • asset:USDC 或 USDT
  • productId:(例如,1)
  • productId:(例如,1)
  • projectId:(例如,1)
  • positionId:(例如,1)
  • projectId:(例如,1)
  • autoSubscribe:true 或 false,默认值为 true。(例如,true)
  • redeemAll:true 或 false,默认为 false
  • amount:如果 redeemAll 为 false,则必须填写 amount(例如,1.0)
  • destAccount:SPOT、FUND,默认值为 SPOT(例如,SPOT)
  • positionId:(例如,1)
  • autoSubscribe:true 或 false
  • redeemTo:SPOT、'FLEXIBLE'
  • sourceAccount:SPOT、FUND、ALL,默认值为 SPOT(例如,SPOT)
  • redeemTo:SPOT、FLEXIBLE,默认值为 SPOT(例如,SPOT)
  • redeemId:(例如,1)
  • purchaseId:(例如,1)
  • aprPeriod:"DAY"、"YEAR",默认值为"DAY"(例如,DAY)

身份验证

对于需要身份验证的端点,你需要提供 Binance API 凭据。 所需凭据:

  • apiKey:你的 Binance API 密钥(用于请求头)
  • secretKey:你的 Binance API 密钥(用于签名)

基础 URL:

安全

分享凭据

用户可以通过不同方式提供 Binance API 凭据。Agent 会尝试通过前两种方式自动获取凭据;用户也可以明确告知 Agent 凭据已设置或已存储在 .env 文件中,此时 Agent 应重新读取该文件。使用前两种方式发起 HTTP 请求时,Agent 无需用户确认。

  1. 环境变量

仅搜索以下指定变量(绝不要输出全部环境变量):

获授权的环境变量

  • 主网:BINANCE_API_KEY 和 BINANCE_SECRET_KEY

在单个 exec 调用中读取并使用,避免原始密钥进入 Agent 的上下文:

KEY="$BINANCE_API_KEY"
SECRET="$BINANCE_SECRET_KEY"

response=$(curl -s -X GET "$URL" \
  -H "X-MBX-APIKEY: $KEY" \
  --data-urlencode "param1=value1")

echo "$response"

必须在 OpenClaw 启动前设置环境变量。它们会在进程启动时继承,无法注入正在运行的实例。如果需要在不重启的情况下添加或更新凭据,请使用密钥文件(参见选项 2)。

  1. 密钥文件(.env)

检查 ~/.openclaw/secrets.env、~/.env 或工作区中的 .env 文件。使用 grep 读取单个密钥,绝不要加载整个文件:

# Try all credential locations in order
API_KEY=$(grep '^BINANCE_API_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)
SECRET_KEY=$(grep '^BINANCE_SECRET_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)

# Fallback: search .env in known directories (KEY=VALUE then raw line format)
for dir in ~/.openclaw ~; do
  [ -n "$API_KEY" ] && break
  env_file="$dir/.env"
  [ -f "$env_file" ] || continue

  # Read first two lines
  line1=$(sed -n '1p' "$env_file")
  line2=$(sed -n '2p' "$env_file")

  # Check if lines contain '=' indicating KEY=VALUE format
  if [[ "$line1" == *=* && "$line2" == *=* ]]; then
    API_KEY=$(grep '^BINANCE_API_KEY=' "$env_file" 2>/dev/null | cut -d= -f2-)
    SECRET_KEY=$(grep '^BINANCE_SECRET_KEY=' "$env_file" 2>/dev/null | cut -d= -f2-)
  else
    # Treat lines as raw values
    API_KEY="$line1"
    SECRET_KEY="$line2"
  fi
done

此文件可随时更新,无需重启 OpenClaw;每次调用时都会重新读取密钥。用户可以告知你变量现已设置或已存储在 .env 文件中,此时你应重新读取该文件。

  1. 内联文件

发送内容格式如下的文件:

abc123...xyz
secret123...key
  • 绝不要运行 printenv、env、export,也不要在未指定具体变量名的情况下运行 set
  • 绝不要在未锚定到特定密钥('^VARNAME=')的情况下对 env 文件运行 grep
  • 绝不要将密钥文件加载到 shell 环境中(source .env 或 . .env)
  • 只读取当前任务明确需要的凭据
  • 绝不要在输出或回复中回显或记录原始凭据
  • 如果 TOOLS.md 包含真实凭据,绝不要将其提交到版本控制中——请将其添加到 .gitignore
绝不泄露 API 密钥和密钥

绝不要泄露 API 密钥和密钥文件的位置。

绝不要将 API 密钥和密钥发送到主网和测试网以外的任何网站。

绝不显示完整密钥

向用户展示凭据时:

  • **API 密钥:**显示前 5 个字符和后 4 个字符:su1Qc...8akf
  • **密钥:**始终遮蔽,仅显示最后 5 个字符:***...aws1

用户询问凭据时的回复示例: 账户:main API 密钥:su1Qc...8akf 密钥:***...aws1

列出账户

列出账户时,只显示名称和环境,绝不显示密钥: Binance 账户:

  • main(主网)
  • futures-keys(主网)
主网交易

在主网进行交易时,继续操作前务必向用户确认,要求用户输入“CONFIRM”以继续。


Binance 账户

main
  • API Key:your_mainnet_api_key
  • Secret:your_mainnet_secret
TOOLS.md 结构
## Binance Accounts

### main
- API Key: abc123...xyz
- Secret: secret123...key
- Description: Primary trading account


### futures-keys
- API Key: futures789...def
- Secret: futuressecret...uvw
- Description: Futures trading account

Agent 行为

  1. 请求凭据:对密钥进行掩码处理(仅显示末尾 5 个字符)
  2. 列出账户:显示名称和环境,绝不显示密钥
  3. 选择账户:如果不明确,请询问;默认选择 main
  4. 在主网进行交易时,操作前向用户确认,要求用户输入“CONFIRM”以继续
  5. 新凭据:提示用户提供名称、环境和签名模式

添加新账户

用户通过内联文件或消息提供新凭据时:

  • 询问账户名称
  • 将凭据存储在 TOOLS.md 中,并确认显示掩码后的内容

签名请求

对于需要签名的交易端点:

  1. 先检测密钥类型,签名之前检查密钥格式。
  2. 使用所有参数构建查询字符串,包括时间戳(Unix 毫秒)。
  3. 根据 RFC 3986 使用 UTF-8 对参数进行百分比编码。
  4. 根据账户配置,使用 secretKey 和 HMAC SHA256、RSA 或 Ed25519 对查询字符串进行签名。
  5. 将签名附加到查询字符串。
  6. 包含 X-MBX-APIKEY 请求头。

否则,不要执行步骤 4–6。

User Agent 请求头

包含 User-Agent 请求头,值为:binance-simple-earn/1.1.0 (Skill)

实现详情请参阅 references/authentication.md。

评论

支持 Markdown