crypto-treasury-ops
Safely manage EVM treasury operations and native Hyperliquid trading for OpenClaw agents, including wallet balance checks, guarded token transfers, cross-cha...
Description
name: crypto-treasury-ops description: Safely manage EVM treasury operations and native Hyperliquid trading for OpenClaw agents, including wallet balance checks, guarded token transfers, cross-chain USDC bridging, Hyperliquid deposits, destination gas top-ups, trading safety, and structured quoting.
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 read Solana balances.
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
- 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:
TREASURY_PRIVATE_KEY=0x...
ZEROX_API_KEY=...
Recommended workflow:
cp .env.example .env
# fill in the treasury private key and optional RPC overrides
npm install
npm run build
Important:
TREASURY_PRIVATE_KEYis required fortransfer_token,bridge_token,deposit_to_hyperliquid,place_hyperliquid_order,protect_hyperliquid_position, andcancel_hyperliquid_orderZEROX_API_KEYis required forswap_tokenand swap quotesHYPERLIQUID_TRADING_*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_URLandSOLANA_RPC_URLare optional overrides; comma-separated lists are supported get_balances,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
.env - For state-changing treasury operations, run
quote_operationordryRun=trueimmediately before execution so the route and balances are fresh
Invoke tools through the CLI:
node dist/index.js --action <tool_name> --input '<json>'
Tools
get_balances
Inputs:
walletAddresschainsolanaAddressoptional whenchain=solana
Returns:
- Native balance
- Configured stablecoin balances for that chain
- Symbols, decimals, raw amounts, and human-readable amounts
Notes:
chain=solanais supported for read-only balance queries- Solana execution flows are not implemented in this skill
transfer_token
Inputs:
chaintokenrecipientamountapprovaloptionaldryRunoptional
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:
chainsellTokenbuyTokenamountrecipientoptionalslippageBpsoptionalapprovaloptionaldryRunoptional
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
ETHorPOL; use wrapped tokens such asWETH - 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:
sourceChaindestinationChaintokenamountapprovaloptionaldryRunoptional
Behavior:
- Uses the configured bridge provider abstraction
- 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
deposit_to_hyperliquid
Inputs:
sourceChaintokenamountdestinationapprovaloptionaldryRunoptional
Behavior:
- Supports
USDConly - Supports
arbitrumdirect deposits andpolygon/base -> arbitrum -> hyperliquid - 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
SOL - 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_operationfirst - If the quote is acceptable, call
deposit_to_hyperliquidwithdryRun=true - Only then call
deposit_to_hyperliquidwithdryRun=false - If execution returns an error after a partial bridge or top-up, do not blindly retry the original amount
- Re-check
base/polygonandarbitrumbalances, then re-runquote_operationwith the remaining source balance if a retry is needed
get_hyperliquid_market_state
Inputs:
marketoptional
Behavior:
- Returns live Hyperliquid perpetual metadata and context
- If
marketis omitted, returns the full supported perpetual market list - If
marketis provided, also returns best bid / ask from the live L2 snapshot - Supports HIP-3 / builder dex markets in
dex:COINformat such asxyz:GOLD
get_hyperliquid_account_state
Inputs:
useroptionaldexoptional
Behavior:
- Returns Hyperliquid perpetual account summary
- Returns positions and open orders
- If
useris omitted, the skill uses the treasury signer address - If
dexis provided, the tool queries that specific HIP-3 builder dex - Also returns
abstractionStateanddexAbstractionEnabled
place_hyperliquid_order
Inputs:
accountAddressoptional for read-only dry-run / quote contextmarketsidesizeorderTypepricerequired for limit ordersslippageBpsoptional for market ordersreduceOnlyoptionalleverageoptionalmarginModeoptionaltimeInForceoptional for limit ordersenableDexAbstractionoptionalapprovaloptionaldryRunoptional
Behavior:
- Supports Hyperliquid perpetuals only
- Supports builder dex perps in
dex:COINformat such asxyz:GOLD - Supports
marketandlimitorders 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
quote_operationsupports this tool- If
accountAddressis 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
dexAbstraction - The skill does not silently switch abstraction mode
- For HIP-3 orders, pass
enableDexAbstraction=trueif you want execution to switch the account intodexAbstractionfirst
Recommended agent workflow:
- Call
quote_operationfirst withoperationType=place_hyperliquid_order - Review the returned
safetyblock andnotionalUsd - Call
place_hyperliquid_orderwithdryRun=true - Only then call
place_hyperliquid_orderwithdryRun=false
protect_hyperliquid_position
Inputs:
accountAddressoptional for read-only dry-run / quote contextmarkettakeProfitRoePercentoptional, default100stopLossRoePercentoptional, default50replaceExistingoptionalliquidationBufferBpsoptional, default25enableDexAbstractionoptionalapprovaloptionaldryRunoptional
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=100means position equity doublingstopLossRoePercent=50means position equity halving
- If the requested stop-loss would be beyond liquidation, the tool tightens it in front of liquidation using
liquidationBufferBpsand returns a warning - Uses native Hyperliquid trigger orders with reduce-only semantics
quote_operationsupports this tool- Real execution only proceeds when the signer matches the target Hyperliquid account
- For HIP-3 builder-dex positions, pass
enableDexAbstraction=trueif the account must first switch intodexAbstraction
Recommended agent workflow:
- Call
quote_operationfirst withoperationType=protect_hyperliquid_position - Review any liquidation-adjustment warning before execution
- Call
protect_hyperliquid_positionwithdryRun=true - Only then call
protect_hyperliquid_positionwithdryRun=false
cancel_hyperliquid_order
Inputs:
marketorderIddryRunoptional
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:
operationTypechaintokenamountdestinationoptionalapprovaloptionalfeeBpsoptionalslippageBpsoptional
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:
operationType- 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
place_hyperliquid_order - Estimates derived TP/SL trigger prices and safety outcome for
protect_hyperliquid_position - Returns a structured quote without execution
Examples
node dist/index.js --action get_balances --input '{"walletAddress":"0x1111111111111111111111111111111111111111","chain":"arbitrum"}'
node dist/index.js --action get_balances --input '{"chain":"solana","solanaAddress":"HK6y2RbhgDJLQ1gAmJatjEyZTjfK6MSHBtpoSN1Vx85A"}'
node dist/index.js --action transfer_token --input '{"chain":"base","token":"USDC","recipient":"0x2222222222222222222222222222222222222222","amount":"100","approval":true,"dryRun":true}'
node dist/index.js --action swap_token --input '{"chain":"arbitrum","sellToken":"USDC","buyToken":"WETH","amount":"250","approval":true,"dryRun":true,"slippageBps":50}'
node dist/index.js --action bridge_token --input '{"sourceChain":"polygon","destinationChain":"arbitrum","token":"USDC","amount":"2500","approval":true,"dryRun":true}'
node dist/index.js --action deposit_to_hyperliquid --input '{"sourceChain":"base","token":"USDC","amount":"500","destination":"0xYourTreasuryWallet","approval":true,"dryRun":true}'
node dist/index.js --action get_hyperliquid_market_state --input '{"market":"ETH"}'
node dist/index.js --action get_hyperliquid_market_state --input '{"market":"xyz:GOLD"}'
node dist/index.js --action get_hyperliquid_account_state --input '{"user":"0xYourHyperliquidWallet"}'
node dist/index.js --action get_hyperliquid_account_state --input '{"user":"0xYourHyperliquidWallet","dex":"xyz"}'
node dist/index.js --action quote_operation --input '{"operationType":"place_hyperliquid_order","walletAddress":"0xYourHyperliquidWallet","market":"ETH","side":"buy","size":"0.01","orderType":"market","approval":true}'
node dist/index.js --action quote_operation --input '{"operationType":"place_hyperliquid_order","walletAddress":"0xYourHyperliquidWallet","market":"xyz:GOLD","side":"sell","size":"0.01","orderType":"market","approval":true,"enableDexAbstraction":true}'
node dist/index.js --action place_hyperliquid_order --input '{"accountAddress":"0xYourHyperliquidWallet","market":"ETH","side":"buy","size":"0.01","orderType":"limit","price":"2000","leverage":2,"approval":true,"dryRun":true}'
node dist/index.js --action place_hyperliquid_order --input '{"accountAddress":"0xYourHyperliquidWallet","market":"xyz:GOLD","side":"sell","size":"0.01","orderType":"market","approval":true,"enableDexAbstraction":true,"dryRun":true}'
node dist/index.js --action quote_operation --input '{"operationType":"protect_hyperliquid_position","walletAddress":"0xYourHyperliquidWallet","market":"BTC","takeProfitRoePercent":100,"stopLossRoePercent":50,"approval":true}'
node dist/index.js --action protect_hyperliquid_position --input '{"accountAddress":"0xYourHyperliquidWallet","market":"BTC","takeProfitRoePercent":100,"stopLossRoePercent":50,"approval":true,"dryRun":true}'
node dist/index.js --action cancel_hyperliquid_order --input '{"market":"ETH","orderId":123456,"dryRun":true}'
Safety defaults
- Do not bypass
safety_checkreasoning. Execution tools perform the check again internally. - Treat rejected outputs as hard stops.
- Prefer
dryRun=truefirst for all new destinations or larger transfers. - Prefer
quote_operationplusdryRun=truebefore any new Hyperliquid order. - Prefer
protect_hyperliquid_positionover ad hoc manual TP/SL math when protecting an existing Hyperliquid position. - Require explicit
approval=truefor 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.
Reviews (0)
No reviews yet. Be the first to review!
Comments (0)
No comments yet. Be the first to share your thoughts!