crypto-treasury-ops
Use this skill when an OpenClaw agent needs to inspect or operate a treasury wallet on Ethereum, Polygon, Arbitrum, or Base with explicit safety controls, or use Solana as a read path and bridge source chain.
What this skill does
- - Checks native and configured stablecoin balances
- Checks Solana native SOL and configured SPL token balances
- Transfers native assets or ERC-20 tokens on one chain
- Bridges tokens across chains through a pluggable provider layer, including Solana -> EVM routes
- Deposits USDC to Hyperliquid with guarded Arbitrum direct flow plus Polygon/Base routing
- Reads Hyperliquid perpetual market state and account state
- Places, protects, and cancels guarded Hyperliquid perpetual orders
- Evaluates treasury safety policy before execution
- Returns structured JSON for reliable downstream agent use
Runtime contract
Execution tools require environment configuration before build or runtime.
Required variables:
CODEBLOCK0
Recommended workflow:
CODEBLOCK1
Important:
- -
TREASURY_PRIVATE_KEY is required for EVM execution tools and as the default destination wallet for Solana -> EVM bridges - INLINECODE1 is required for executing Solana bridge transactions
- INLINECODE2 can be used for read-only Solana quote context when no Solana signer is present
- INLINECODE3 is required for
swap_token and swap quotes - INLINECODE5 is optional but recommended for Solana bridge quote / execution rate limits
- INLINECODE6 variables can further constrain market allowlists, order notional, leverage, and confirmation thresholds
- The skill ships with built-in fallback RPC URL lists for Ethereum, Polygon, Arbitrum, Base, and Solana
- RPC env vars such as
ETHEREUM_RPC_URL and SOLANA_RPC_URL are optional overrides; comma-separated lists are supported - INLINECODE9 ,
get_hyperliquid_market_state, get_hyperliquid_account_state, safety_check, and some quote flows can run without a signer - Do not pass private keys in tool input JSON; this skill reads them from the environment only
- Prefer a vault, KMS, HSM, or delegated signer in production instead of a raw hot-wallet private key in INLINECODE13
- For state-changing treasury operations, run
quote_operation or dryRun=true immediately before execution so the route and balances are fresh
Invoke tools through the CLI:
CODEBLOCK2
Tools
get_balances
Inputs:
- - INLINECODE17
- INLINECODE18
- INLINECODE19 optional when INLINECODE20
Returns:
- - Native balance
- Configured stablecoin balances for that chain
- Symbols, decimals, raw amounts, and human-readable amounts
Notes:
- -
chain=solana is supported for read-only balance queries - Solana execution is limited to bridge source flows only
transfer_token
Inputs:
- - INLINECODE23
- INLINECODE24
- INLINECODE25
- INLINECODE26
- INLINECODE27 optional
- INLINECODE28 optional
Behavior:
- - Validates recipient format
- Resolves token by symbol or address
- Checks wallet balance before sending
- Estimates gas
- Runs safety policy
- Rejects unsafe or underfunded transfers
- Returns transfer summary and transaction hash
swap_token
Inputs:
- - INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
- INLINECODE34 optional
- INLINECODE35 optional
- INLINECODE36 optional
- INLINECODE37 optional
Behavior:
- - Uses the configured swap provider abstraction
- First implementation uses the 0x Swap API
- Supports EVM ERC-20 swaps only
- Rejects native gas token swaps such as raw
ETH or POL; use wrapped tokens such as INLINECODE40 - Quotes route, minimum received, gas, allowance target, and tx data
- Checks treasury policy and gas reserve before execution
- Executes only when approval and policy conditions pass
bridge_token
Inputs:
- - INLINECODE42
- INLINECODE43
- INLINECODE44
- INLINECODE45
- INLINECODE46 optional
- INLINECODE47 optional
Behavior:
- - Uses the configured bridge provider abstraction
- Supports
solana -> ethereum/arbitrum/base/polygon through Mayan - Quotes route, fees, minimum received, and tx data
- Checks treasury policy, fee threshold, and gas reserve
- Executes only when approval and policy conditions pass
- Returns route summary, tx status, and explorer links when available
- The first Solana bridge implementation supports
SOL -> native destination gas token and same-symbol stablecoin routes such as INLINECODE50 - Solana bridge execution currently returns a submitted / pending status after the signed Solana transaction is broadcast; completion should be re-checked from the destination balance or explorer link
deposit_to_hyperliquid
Inputs:
- - INLINECODE52
- INLINECODE53
- INLINECODE54
- INLINECODE55
- INLINECODE56 optional
- INLINECODE57 optional
Behavior:
- - Supports
USDC only - Supports
arbitrum direct deposits and INLINECODE60 - If Arbitrum gas is insufficient for the final deposit, can reserve source USDC and bridge enough Arbitrum ETH first
- This is a multi-stage flow: optional gas top-up, bridge to Arbitrum, then Arbitrum USDC deposit into Hyperliquid
- The tool now attempts balance-based recovery if a bridge status API is unreliable but funds have already arrived onchain
- Rejects deposits to a different Hyperliquid wallet than the treasury signer
- Does not support Solana-origin deposits or INLINECODE61
- Hyperliquid may support separate Solana deposits through Unit-managed flows, but those are outside this skill
- Rejects if minimum deposit or gas reserve requirements are not met
- Returns the bridge leg, deposit leg, and final execution summary
Recommended agent workflow:
- - Call
quote_operation first - If the quote is acceptable, call
deposit_to_hyperliquid with INLINECODE64 - Only then call
deposit_to_hyperliquid with INLINECODE66 - If execution returns an error after a partial bridge or top-up, do not blindly retry the original amount
- Re-check
base/polygon and arbitrum balances, then re-run quote_operation with the remaining source balance if a retry is needed
get_hyperliquid_market_state
Inputs:
Behavior:
- - Returns live Hyperliquid perpetual metadata and context
- If
market is omitted, returns the full supported perpetual market list - If
market is provided, also returns best bid / ask from the live L2 snapshot - Supports HIP-3 / builder dex markets in
dex:COIN format such as INLINECODE75
get_hyperliquid_account_state
Inputs:
- -
user optional - INLINECODE78 optional
Behavior:
- - Returns Hyperliquid perpetual account summary
- Returns positions and open orders
- If
user is omitted, the skill uses the treasury signer address - If
dex is provided, the tool queries that specific HIP-3 builder dex - Also returns
abstractionState and INLINECODE82
place_hyperliquid_order
Inputs:
- -
accountAddress optional for read-only dry-run / quote context - INLINECODE85
- INLINECODE86
- INLINECODE87
- INLINECODE88
- INLINECODE89 required for limit orders
- INLINECODE90 optional for market orders
- INLINECODE91 optional
- INLINECODE92 optional
- INLINECODE93 optional
- INLINECODE94 optional for limit orders
- INLINECODE95 optional
- INLINECODE96 optional
- INLINECODE97 optional
Behavior:
- - Supports Hyperliquid perpetuals only
- Supports builder dex perps in
dex:COIN format such as INLINECODE99 - Supports
market and limit orders in the first version - Market orders are translated into protected IOC orders with a configurable price cap
- Optionally updates leverage before placing the order
- Enforces market allowlist, max single order notional, max daily order notional, max leverage, and confirmation threshold
- INLINECODE102 supports this tool
- If
accountAddress is provided, dry-run and quote can use it for read-only account context - Real execution only proceeds when the signer matches the target Hyperliquid account
- HIP-3 builder-dex execution requires Hyperliquid INLINECODE104
- The skill does not silently switch abstraction mode
- For HIP-3 orders, pass
enableDexAbstraction=true if you want execution to switch the account into dexAbstraction first
Recommended agent workflow:
- - Call
quote_operation first with INLINECODE108 - Review the returned
safety block and INLINECODE110 - Call
place_hyperliquid_order with INLINECODE112 - Only then call
place_hyperliquid_order with INLINECODE114
protect_hyperliquid_position
Inputs:
- -
accountAddress optional for read-only dry-run / quote context - INLINECODE117
- INLINECODE118 optional, default INLINECODE119
- INLINECODE120 optional, default INLINECODE121
- INLINECODE122 optional
- INLINECODE123 optional, default INLINECODE124
- INLINECODE125 optional
- INLINECODE126 optional
- INLINECODE127 optional
Behavior:
- - Reads the live Hyperliquid position for the requested market
- Derives a full-size reduce-only take-profit trigger and a full-size reduce-only stop-loss trigger
- Uses ROE-style rules relative to entry and leverage:
-
takeProfitRoePercent=100 means position equity doubling
-
stopLossRoePercent=50 means position equity halving
- - If the requested stop-loss would be beyond liquidation, the tool tightens it in front of liquidation using
liquidationBufferBps and returns a warning - Uses native Hyperliquid trigger orders with reduce-only semantics
- INLINECODE131 supports this tool
- Real execution only proceeds when the signer matches the target Hyperliquid account
- For HIP-3 builder-dex positions, pass
enableDexAbstraction=true if the account must first switch into INLINECODE133
Recommended agent workflow:
- - Call
quote_operation first with INLINECODE135 - Review any liquidation-adjustment warning before execution
- Call
protect_hyperliquid_position with INLINECODE137 - Only then call
protect_hyperliquid_position with INLINECODE139
cancel_hyperliquid_order
Inputs:
- - INLINECODE141
- INLINECODE142
- INLINECODE143 optional
Behavior:
- - Looks up the matching open order first
- Rejects if the order is not currently open
- Supports dry-run preview before cancellation
safety_check
Inputs:
- - INLINECODE145
- INLINECODE146
- INLINECODE147
- INLINECODE148
- INLINECODE149 optional
- INLINECODE150 optional
- INLINECODE151 optional
- INLINECODE152 optional
Behavior:
- - Enforces allowlists
- Enforces max single transfer size
- Enforces max daily transfer amount
- Requires approval above the configured threshold
- Rejects bridge and deposit flows with insufficient gas reserve
- Rejects excessive estimated fees or slippage
quote_operation
Inputs:
- - INLINECODE154
- operation-specific fields
Behavior:
- - Estimates balance impact, gas, route fees, and minimum received
- Estimates Hyperliquid order notional, submission price, simulated fill price, and safety outcome for INLINECODE155
- Estimates derived TP/SL trigger prices and safety outcome for INLINECODE156
- Returns a structured quote without execution
Examples
CODEBLOCK3
CODEBLOCK4
CODEBLOCK5
CODEBLOCK6
CODEBLOCK7
CODEBLOCK8
CODEBLOCK9
CODEBLOCK10
CODEBLOCK11
CODEBLOCK12
CODEBLOCK13
CODEBLOCK14
CODEBLOCK15
CODEBLOCK16
CODEBLOCK17
CODEBLOCK18
CODEBLOCK19
CODEBLOCK20
Safety defaults
- - Do not bypass
safety_check reasoning. Execution tools perform the check again internally. - Treat rejected outputs as hard stops.
- Prefer
dryRun=true first for all new destinations or larger transfers. - Prefer
quote_operation plus dryRun=true before any new Hyperliquid order. - Prefer
protect_hyperliquid_position over ad hoc manual TP/SL math when protecting an existing Hyperliquid position. - Require explicit
approval=true for amounts above the configured threshold. - Never assume a non-allowlisted destination is safe.
- For multi-stage flows such as Hyperliquid deposits, never reuse a stale quoted amount after a partial execution. Re-quote from current balances first.
crypto-treasury-ops
当OpenClaw代理需要在以太坊、Polygon、Arbitrum或Base上检查或操作具有明确安全控制的国库钱包,或使用Solana作为读取路径和桥接源链时,使用此技能。
此技能的功能
- - 检查原生和配置的稳定币余额
- 检查Solana原生SOL和配置的SPL代币余额
- 在一条链上转移原生资产或ERC-20代币
- 通过可插拔的提供商层跨链桥接代币,包括Solana -> EVM路径
- 通过受保护的Arbitrum直接流以及Polygon/Base路由将USDC存入Hyperliquid
- 读取Hyperliquid永续市场状态和账户状态
- 下达、保护和取消受保护的Hyperliquid永续订单
- 在执行前评估国库安全策略
- 返回结构化JSON以供下游代理可靠使用
运行时约定
执行工具需要在构建或运行前配置环境变量。
必需变量:
bash
TREASURYPRIVATEKEY=0x...
SOLANATREASURYPRIVATE_KEY=
ZEROXAPIKEY=...
推荐工作流程:
bash
cp .env.example .env
填写国库私钥和可选的RPC覆盖
npm install
npm run build
重要提示:
- - TREASURYPRIVATEKEY 是EVM执行工具以及作为Solana -> EVM桥接的默认目标钱包所必需的
- SOLANATREASURYPRIVATEKEY 是执行Solana桥接交易所必需的
- SOLANATREASURYADDRESS 可在没有Solana签名者时用于只读Solana报价上下文
- ZEROXAPIKEY 是 swaptoken 和交换报价所必需的
- MAYANAPIKEY 是可选的,但建议用于Solana桥接报价/执行速率限制
- HYPERLIQUIDTRADING* 变量可进一步约束市场白名单、订单名义价值、杠杆和确认阈值
- 该技能内置了以太坊、Polygon、Arbitrum、Base和Solana的备用RPC URL列表
- 诸如 ETHEREUMRPCURL 和 SOLANARPCURL 等RPC环境变量是可选的覆盖;支持逗号分隔的列表
- getbalances、gethyperliquidmarketstate、gethyperliquidaccountstate、safetycheck 和一些报价流程可以在没有签名者的情况下运行
- 不要在工具输入JSON中传递私钥;此技能仅从环境中读取私钥
- 在生产环境中,优先使用保险库、KMS、HSM或委托签名者,而不是在 .env 中使用原始热钱包私钥
- 对于改变状态的国库操作,在执行前立即运行 quote_operation 或 dryRun=true,以确保路由和余额是最新的
通过CLI调用工具:
bash
node dist/index.js --action --input
工具
get_balances
输入:
- - walletAddress
- chain
- solanaAddress 当 chain=solana 时可选
返回:
- - 原生余额
- 该链上配置的稳定币余额
- 符号、小数位数、原始金额和可读金额
注意:
- - 支持 chain=solana 进行只读余额查询
- Solana执行仅限于桥接源流程
transfer_token
输入:
- - chain
- token
- recipient
- amount
- approval 可选
- dryRun 可选
行为:
- - 验证接收者格式
- 通过符号或地址解析代币
- 发送前检查钱包余额
- 估算Gas
- 运行安全策略
- 拒绝不安全或资金不足的转账
- 返回转账摘要和交易哈希
swap_token
输入:
- - chain
- sellToken
- buyToken
- amount
- recipient 可选
- slippageBps 可选
- approval 可选
- dryRun 可选
行为:
- - 使用配置的交换提供商抽象
- 首次实现使用0x Swap API
- 仅支持EVM ERC-20交换
- 拒绝原生Gas代币交换,如原始 ETH 或 POL;使用包装代币如 WETH
- 报价路由、最低接收量、Gas、授权目标和交易数据
- 执行前检查国库策略和Gas储备
- 仅在授权和策略条件通过时执行
bridge_token
输入:
- - sourceChain
- destinationChain
- token
- amount
- approval 可选
- dryRun 可选
行为:
- - 使用配置的桥接提供商抽象
- 通过Mayan支持 solana -> ethereum/arbitrum/base/polygon
- 报价路由、费用、最低接收量和交易数据
- 检查国库策略、费用阈值和Gas储备
- 仅在授权和策略条件通过时执行
- 返回路由摘要、交易状态和浏览器链接(如可用)
- 首次Solana桥接实现支持 SOL -> 原生目标Gas代币 和相同符号的稳定币路由,如 USDC -> USDC
- Solana桥接执行在广播已签名的Solana交易后返回已提交/待处理状态;应从目标余额或浏览器链接重新检查完成情况
deposittohyperliquid
输入:
- - sourceChain
- token
- amount
- destination
- approval 可选
- dryRun 可选
行为:
- - 仅支持 USDC
- 支持 arbitrum 直接存入和 polygon/base -> arbitrum -> hyperliquid
- 如果Arbitrum Gas不足以进行最终存入,可以预留源USDC并先桥接足够的Arbitrum ETH
- 这是一个多阶段流程:可选的Gas补充、桥接到Arbitrum、然后将Arbitrum USDC存入Hyperliquid
- 如果桥接状态API不可靠但资金已到达链上,该工具现在尝试基于余额的恢复
- 拒绝存入与国库签名者不同的Hyperliquid钱包
- 不支持Solana来源的存入或 SOL
- Hyperliquid可能通过Unit管理的流程支持单独的Solana存入,但这些不在本技能范围内
- 如果不满足最低存入或Gas储备要求则拒绝
- 返回桥接阶段、存入阶段和最终执行摘要
推荐的代理工作流程:
- - 首先调用 quoteoperation
- 如果报价可接受,调用 deposittohyperliquid 并设置 dryRun=true
- 然后才调用 deposittohyperliquid 并设置 dryRun=false
- 如果在部分桥接或补充后执行返回错误,不要盲目重试原始金额
- 重新检查 base/polygon 和 arbitrum 余额,如果需要重试,使用剩余源余额重新运行 quoteoperation
gethyperliquidmarket_state
输入:
行为:
- - 返回实时的Hyperliquid永续元数据和上下文
- 如果省略 market,返回完整的支持永续市场列表
- 如果提供了 market,还从实时L2快照返回最佳买/卖价
- 支持 dex:COIN 格式的HIP-3 / builder dex市场,如 xyz:GOLD
gethyperliquidaccount_state
输入:
行为:
- - 返回Hyperliquid永续账户摘要
- 返回持仓和未成交订单
- 如果省略 user,技能使用国库签名者地址
- 如果提供了 dex,工具查询该特定HIP-3 builder dex
- 还返回 abstractionState 和 dexAbstractionEnabled
placehyperliquidorder
输入:
- - accountAddress 可选,用于只读的dry-run/报价上下文
- market
- side
- size
- orderType
- price 限价单必需
- slippageBps 市价单可选
- reduceOnly 可选
- leverage 可选
- marginMode 可选
- timeInForce 限价单可选
- enableDexAbstraction 可选
- approval 可选
- dryRun 可选
行为:
- - 仅支持Hyperliquid永续合约
- 支持 dex:COIN 格式的builder dex永续合约,如 xyz:GOLD
- 第一版支持 market 和 limit 订单
- 市价单转换为受保护的IOC订单,带有可配置的价格上限
- 在下单前可选地更新杠杆
- 强制执行市场白名单、单笔最大名义价值、每日最大名义价值、最大杠杆和确认阈值
- quote_operation 支持