Wayfinder
DeFi trading, yield strategies, and portfolio management powered by poetry run wayfinder Paths.
Pre-Flight Check
Before running any commands, verify that poetry run wayfinder Paths is installed and reachable:
# SDK location (override by setting WAYFINDER_SDK_PATH)
export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
# Check if wayfinder-paths-sdk directory exists
if [ ! -d "$WAYFINDER_SDK_PATH" ]; then
echo "ERROR: wayfinder-paths-sdk is not installed at: $WAYFINDER_SDK_PATH"
echo "Set WAYFINDER_SDK_PATH or run the First-Time Setup below."
exit 1
fi
# Config path (override by setting WAYFINDER_CONFIG_PATH)
export WAYFINDER_CONFIG_PATH="${WAYFINDER_CONFIG_PATH:-$WAYFINDER_SDK_PATH/config.json}"
# Check if the config exists
if [ ! -f "$WAYFINDER_CONFIG_PATH" ]; then
echo "ERROR: config not found at $WAYFINDER_CONFIG_PATH. Run the First-Time Setup below."
exit 1
fi
# Check if the CLI is functional
cd "$WAYFINDER_SDK_PATH"
if ! poetry run wayfinder --help > /dev/null 2>&1; then
echo "ERROR: poetry run wayfinder CLI is not working. Run 'cd $WAYFINDER_SDK_PATH && poetry install' to fix."
exit 1
fi
echo "poetry run wayfinder Paths is installed and ready."
If either check fails, follow the First-Time Setup instructions below before proceeding.
Quick Start
First-Time Setup
Important: The SDK must be installed from GitHub via git clone. Do NOT install from PyPI (pip install wayfinder-paths will not work).
Before starting: You need a Wayfinder API key (format: wk_...). Get one at https://strategies.wayfinder.ai. The guided setup will prompt you for this key.
# Clone wayfinder-paths-sdk from GitHub (required — do NOT pip install)
export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
if [ ! -d "$WAYFINDER_SDK_PATH" ]; then
git clone https://github.com/WayfinderFoundation/wayfinder-paths-sdk.git "$WAYFINDER_SDK_PATH"
fi
cd "$WAYFINDER_SDK_PATH"
poetry install
# Run guided setup (creates/updates config.json + local dev wallets + MCP config)
# You will need your API key from https://strategies.wayfinder.ai (format: wk_...)
python3 scripts/setup.py
Wallet security:
- NEVER output private keys or seed phrases into the conversation. These are secrets — they must stay on the machine, never in chat.
- For a long-running bot, prefer a seed phrase stored in your backend/secret manager rather than generating random wallets on the server.
- On first-time setup, the user should retrieve the seed phrase directly from their machine or secret manager. Only offer to display the seed phrase if the user explicitly confirms they cannot access the machine to retrieve it themselves.
- See
references/setup.md for detailed wallet setup instructions.
Verify Setup
export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
export WAYFINDER_CONFIG_PATH="${WAYFINDER_CONFIG_PATH:-$WAYFINDER_SDK_PATH/config.json}"
cd "$WAYFINDER_SDK_PATH"
poetry run wayfinder resource wayfinder://strategies
poetry run wayfinder resource wayfinder://wallets
poetry run wayfinder resource wayfinder://balances/main
Command Reference
All commands should be run from $WAYFINDER_SDK_PATH and require WAYFINDER_CONFIG_PATH (default: $WAYFINDER_SDK_PATH/config.json). All responses return {"ok": true, "result": {...}} on success or {"ok": false, "error": {"code": "...", "message": "..."}} on failure.
resource — Read MCP resources by URI
Read-only access to adapters, strategies, wallets, balances, tokens, and Hyperliquid market data via URI-based resources. Use --list to see all available resources and templates.
Asset/data sourcing rule: When the user asks you to look up token/pool/market/protocol data, first use Wayfinder’s adapter/strategy discovery resources (poetry run wayfinder resource wayfinder://adapters, wayfinder://adapters/{name}, wayfinder://strategies, wayfinder://tokens/*). Only fall back to other methods if Wayfinder doesn’t expose the required data or the user explicitly asks.
# List all available resources and templates
poetry run wayfinder resource --list
Static Resources
| URI |
Description |
wayfinder://adapters |
List all adapters with capabilities |
wayfinder://strategies |
List all strategies with adapter dependencies |
wayfinder://wallets |
List all configured wallets |
wayfinder://hyperliquid/prices |
All Hyperliquid mid prices |
wayfinder://hyperliquid/markets |
Perp market metadata, funding rates, and asset contexts |
wayfinder://hyperliquid/spot-assets |
Spot asset metadata |
poetry run wayfinder resource wayfinder://adapters
poetry run wayfinder resource wayfinder://strategies
poetry run wayfinder resource wayfinder://wallets
poetry run wayfinder resource wayfinder://hyperliquid/prices
poetry run wayfinder resource wayfinder://hyperliquid/markets
poetry run wayfinder resource wayfinder://hyperliquid/spot-assets
Resource Templates
| URI Template |
Description |
wayfinder://adapters/{name} |
Describe a single adapter (e.g. moonwell_adapter) |
wayfinder://strategies/{name} |
Describe a single strategy (e.g. stablecoin_yield_strategy) |
wayfinder://wallets/{label} |
Get a single wallet by label |
wayfinder://balances/{label} |
Enriched multi-chain balances for a wallet |
wayfinder://activity/{label} |
Recent transaction activity for a wallet |
wayfinder://tokens/search/{chain_code}/{query} |
Fuzzy token search (hits /tokens/fuzzy/) — ALWAYS use this first |
wayfinder://tokens/resolve/{query} |
Resolve a token by known ID (hits /tokens/detail/) — only use with IDs from search |
wayfinder://tokens/gas/{chain_code} |
Native gas token for a chain (ETH, HYPE) — use for native tokens |
wayfinder://hyperliquid/{label}/state |
Perp positions + PnL for a wallet |
wayfinder://hyperliquid/{label}/spot |
Spot balances on Hyperliquid for a wallet |
wayfinder://hyperliquid/prices/{coin} |
Mid price for a single coin |
wayfinder://hyperliquid/book/{coin} |
Order book for a coin |
Token lookup order — always search or use gas endpoint first:
# 1. For native gas tokens (ETH, HYPE): use the gas endpoint
poetry run wayfinder resource wayfinder://tokens/gas/ethereum # ETH on Ethereum
poetry run wayfinder resource wayfinder://tokens/gas/base # ETH on Base
poetry run wayfinder resource wayfinder://tokens/gas/hyperevm # HYPE on HyperEVM
# 2. For ERC20 tokens: ALWAYS fuzzy search first
poetry run wayfinder resource wayfinder://tokens/search/base/usdc
poetry run wayfinder resource wayfinder://tokens/search/arbitrum/eth
poetry run wayfinder resource wayfinder://tokens/search/ethereum/weth
# 3. Then resolve with the exact ID from search results
poetry run wayfinder resource wayfinder://tokens/resolve/usd-coin-base
poetry run wayfinder resource wayfinder://adapters/moonwell_adapter
poetry run wayfinder resource wayfinder://strategies/stablecoin_yield_strategy
poetry run wayfinder resource wayfinder://wallets/main
poetry run wayfinder resource wayfinder://balances/main
poetry run wayfinder resource wayfinder://activity/main
poetry run wayfinder resource wayfinder://hyperliquid/main/state
poetry run wayfinder resource wayfinder://hyperliquid/main/spot
poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
poetry run wayfinder resource wayfinder://hyperliquid/book/ETH
wallets — Manage wallets and discover positions
Create, annotate, and discover cross-protocol positions. Use resource wayfinder://wallets to list wallets and resource wayfinder://wallets/{label} to get a single wallet.
| Parameter |
Type |
Required |
Default |
Notes |
action |
"create" | "annotate" | "discover_portfolio" |
Yes |
— |
— |
label |
string |
create |
— |
Must be non-empty; duplicate labels are idempotent |
wallet_label |
string |
annotate, discover_portfolio |
— |
Or use wallet_address |
wallet_address |
string |
No |
— |
Alternative to wallet_label |
protocol |
string |
annotate |
— |
Protocol name for annotation |
annotate_action |
string |
annotate |
— |
Action being annotated |
tool |
string |
annotate |
— |
Tool name for annotation |
status |
string |
annotate |
— |
Status for annotation |
chain_id |
string |
No |
— |
— |
details |
string (JSON) |
No |
— |
Extra metadata for annotation |
protocols |
string (JSON) |
No |
— |
Filter discover_portfolio to specific protocols |
parallel |
bool |
No |
false |
Required if querying >= 3 protocols without a protocols filter |
include_zero_positions |
bool |
No |
false |
Include empty positions in portfolio |
Supported protocols for discover_portfolio: hyperliquid, hyperlend, moonwell, boros, pendle.
poetry run wayfinder wallets --action create --label my_new_strategy
poetry run wayfinder wallets --action discover_portfolio --wallet_label main --parallel
poetry run wayfinder wallets --action discover_portfolio --wallet_label main --protocols '["hyperliquid","moonwell"]'
Validations:
create: label must be non-empty. Duplicate labels return the existing wallet (idempotent).
annotate/discover_portfolio: must resolve a wallet address from wallet_label or wallet_address.
annotate: all of protocol, annotate_action, tool, status are required.
discover_portfolio with >= 3 protocols requires parallel=true or an explicit protocols filter (returns requires_confirmation otherwise).
quote_swap — Get a swap/bridge quote (read-only)
Returns a quote for swapping or bridging tokens. No on-chain effects.
| Parameter |
Type |
Required |
Default |
Notes |
wallet_label |
string |
Yes |
— |
Must resolve to a wallet with an address |
from_token |
string |
Yes |
— |
Token ID from search results (e.g. usd-coin-base). Always search first — do not guess. |
to_token |
string |
Yes |
— |
Token ID from search results. Always search first. |
amount |
string |
Yes |
— |
Human-readable amount (e.g. "500"). Must be positive, Decimal-parseable, and > 0 after scaling to token decimals |
slippage_bps |
int |
No |
50 |
Slippage tolerance in basis points (50 = 0.5%) |
recipient |
string |
No |
— |
Defaults to sender address |
include_calldata |
bool |
No |
false |
Include raw calldata in response |
Always resolve token IDs before calling quote_swap. Run poetry run wayfinder resource wayfinder://tokens/search/<chain>/<symbol> for each token first, then use the exact ID from the result. Do not pass raw symbols or guessed symbol-chain strings — they may resolve incorrectly or fail.
Note: Native gas tokens (e.g., unwrapped ETH) may fail in swaps with from_token_address: null. Use the wrapped ERC20 version instead (e.g., WETH). Search for it: resource wayfinder://tokens/search/<chain>/weth.
Bridging to a new chain for the first time: the wallet needs native gas on the destination chain before it can do anything. Bridge the native gas token (e.g. ETH) to the destination chain first, then bridge or swap for the target token. Use the native token IDs from the supported-chains table below (e.g. ethereum-base for ETH on Base).
- Use the native token IDs from the supported-chains table below when bridging gas (e.g.
ethereum-base for ETH on Base, plasma-plasma for PLASMA on Plasma).
poetry run wayfinder quote_swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 500
poetry run wayfinder quote_swap --wallet_label main --from_token "USDC-base" --to_token "ETH-base" --amount 1000 --slippage_bps 100
Errors: not_found (wallet), invalid_wallet, token_error, invalid_token (missing chain_id/address), invalid_amount, quote_error.
execute — Execute on-chain transactions
Execute swaps, token sends, or Hyperliquid deposits. This broadcasts transactions and can move real funds.
| Parameter |
Type |
Required |
Default |
Notes |
kind |
swap | send | hyperliquid_deposit |
Yes |
— |
Operation type |
wallet_label |
string |
Yes |
— |
Must resolve to a wallet with private key |
amount |
string |
Yes |
— |
Human-readable amount (e.g. "500") |
from_token |
string |
swap |
— |
Source token ID. Always search first. |
to_token |
string |
swap |
— |
Destination token ID. Always search first. |
slippage_bps |
int |
No |
50 |
Swap only; basis points |
deadline_seconds |
int |
No |
300 |
Swap only |
recipient |
string |
send |
— |
Recipient address |
token |
string |
send |
— |
Token ID (or "native" with chain_id). Always search first. |
chain_id |
string |
No |
— |
Required for send when token="native" |
force |
flag |
No |
false |
Do not rely on this as a “dry-run vs live” gate. Treat execute as live and require explicit user confirmation before calling it. |
Hyperliquid deposit validations (critical):
- Amount must be >= 5 USDC (deposits below 5 are lost on the bridge).
- Hard-codes: token = Arbitrum USDC, recipient =
HYPERLIQUID_BRIDGE_ADDRESS, chain = Arbitrum (42161).
Additional runtime validations:
- Wallet must have both
address and private_key_hex.
- Token resolution must succeed (chain_id + token address required).
- Swap quotes must return a
best_quote with calldata.
- For USDT-style tokens, a zero-allowance reset transaction is sent before approval.
# Swap
poetry run wayfinder execute --kind swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 500
# Send tokens
poetry run wayfinder execute --kind send --wallet_label main --token usd-coin-base --recipient 0x... --amount 100
# Hyperliquid deposit (min 5 USDC)
poetry run wayfinder execute --kind hyperliquid_deposit --wallet_label main --amount 100
hyperliquid — Wait for Hyperliquid deposits/withdrawals
Wait for deposits or withdrawals to settle on Hyperliquid. For read-only queries (user state, prices, order books), use the resource command with Hyperliquid URIs.
| Parameter |
Type |
Required |
Default |
Notes |
action |
"wait_for_deposit" | "wait_for_withdrawal" |
Yes |
— |
— |
wallet_label |
string |
No |
— |
Or use wallet_address |
wallet_address |
string |
No |
— |
Alternative to wallet_label |
expected_increase |
string |
No |
— |
Expected USDC increase for deposit |
timeout_s |
int |
No |
120 |
Timeout for wait_for_deposit |
poll_interval_s |
int |
No |
5 |
Poll interval for wait actions |
lookback_s |
int |
No |
5 |
For wait_for_withdrawal |
max_poll_time_s |
int |
No |
900 |
Max wait for wait_for_withdrawal (15 min) |
poetry run wayfinder hyperliquid --action wait_for_deposit --wallet_label main --expected_increase 100
poetry run wayfinder hyperliquid --action wait_for_withdrawal --wallet_label main
Read-only queries via resources:
# Perp positions + PnL
poetry run wayfinder resource wayfinder://hyperliquid/main/state
# Spot balances
poetry run wayfinder resource wayfinder://hyperliquid/main/spot
# All mid prices
poetry run wayfinder resource wayfinder://hyperliquid/prices
# Single coin price
poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
# Market metadata + funding rates
poetry run wayfinder resource wayfinder://hyperliquid/markets
# Spot asset metadata
poetry run wayfinder resource wayfinder://hyperliquid/spot-assets
# Order book
poetry run wayfinder resource wayfinder://hyperliquid/book/ETH
hyperliquid_execute — Hyperliquid trading operations
Place/cancel orders, update leverage, and withdraw USDC. These operations are live and can place real orders / move real funds.
| Parameter |
Type |
Required |
Default |
Notes |
action |
place_order | cancel_order | update_leverage | withdraw | spot_to_perp_transfer | perp_to_spot_transfer |
Yes |
— |
— |
wallet_label |
string |
Yes |
— |
Must resolve to wallet with private key |
coin |
string |
place_order, cancel_order, update_leverage |
— |
Or use asset_id. Strips -perp/_perp suffixes automatically |
asset_id |
string |
No |
— |
Direct asset ID (alternative to coin) |
is_spot |
string |
No |
— |
true for spot orders, false for perp. Must be explicit for place_order. |
order_type |
market | limit |
No |
market |
— |
is_buy |
string |
place_order |
— |
true or false |
size |
string |
No |
— |
Mutually exclusive with usd_amount; coin units |
usd_amount |
string |
No |
— |
Mutually exclusive with size; USD amount |
usd_amount_kind |
string |
when usd_amount is used |
— |
notional or margin |
leverage |
string |
when usd_amount_kind=margin; update_leverage |
— |
Must be positive |
price |
string |
limit orders |
— |
Must be positive |
slippage |
float |
No |
0.01 |
Market orders only; 0–0.25 (25% cap) |
reduce_only |
flag |
No |
false |
--reduce_only / --no-reduce_only |
cloid |
string |
No |
— |
Client order ID |
order_id |
string |
cancel_order |
— |
Or use cancel_cloid |
cancel_cloid |
string |
No |
— |
Alternative to order_id for cancel |
is_cross |
flag |
No |
true |
--is_cross / --no-is_cross |
amount_usdc |
string |
withdraw, transfers |
— |
USDC amount for withdraw or transfers |
builder_fee_tenths_bp |
string |
No |
— |
Falls back to config default |
force |
flag |
No |
false |
Do not rely on this as a “dry-run vs live” gate. Treat hyperliquid_execute as live and require explicit user confirmation before calling it. |
Key validations for place_order:
- Exactly one of
size or usd_amount (not both, not neither).
- If
usd_amount is used, usd_amount_kind is required.
- If
usd_amount_kind=margin, then leverage is required.
- Limit orders require
price > 0.
- After lot-size rounding, size must still be > 0.
- Builder fee is mandatory (auto-configured; approval is auto-submitted if needed).
# Market buy
poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy true --usd_amount 200 --usd_amount_kind margin --leverage 5
# Spot buy
poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin HYPE --is_spot true --is_buy true --usd_amount 20
# Limit sell
poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy false --size 0.1 --price 4000 --order_type limit
# Close position (reduce-only)
poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy false --size 0.5 --reduce_only
# Update leverage
poetry run wayfinder hyperliquid_execute --action update_leverage --wallet_label main --coin ETH --leverage 5
# Cancel order
poetry run wayfinder hyperliquid_execute --action cancel_order --wallet_label main --coin ETH --order_id 12345
# Withdraw USDC
poetry run wayfinder hyperliquid_execute --action withdraw --wallet_label main --amount_usdc 100
# Transfer USDC between spot and perp wallets
poetry run wayfinder hyperliquid_execute --action spot_to_perp_transfer --wallet_label main --amount_usdc 50
poetry run wayfinder hyperliquid_execute --action perp_to_spot_transfer --wallet_label main --amount_usdc 50
polymarket — Polymarket market + account reads
Read-only access to Polymarket markets, prices, order books, and user status.
Tradability filter: a market can be “found” but not tradable. Filter for enableOrderBook, acceptingOrders, active, closed != true, and non-empty clobTokenIds.
| Parameter |
Type |
Required |
Default |
Notes |
action |
status | search | trending | get_market | get_event | price | order_book | price_history | bridge_status | open_orders |
Yes |
— |
— |
wallet_label |
string |
No |
— |
Resolves account from config; required for open_orders |
wallet_address |
string |
No |
— |
Alternative to wallet_label for account-based reads |
account |
string |
No |
— |
Direct account address (alternative to wallet inputs) |
include_orders |
bool |
No |
true |
status only |
include_activity |
bool |
No |
false |
status only |
activity_limit |
int |
No |
50 |
status only |
include_trades |
bool |
No |
false |
status only |
trades_limit |
int |
No |
50 |
status only |
positions_limit |
int |
No |
500 |
status only |
max_positions_pages |
int |
No |
10 |
status only |
query |
string |
search |
— |
Query string for fuzzy market search |
limit |
int |
No |
10 |
search, trending |
page |
int |
No |
1 |
search |
keep_closed_markets |
bool |
No |
false |
search |
rerank |
bool |
No |
true |
search |
offset |
int |
No |
0 |
trending |
market_slug |
string |
get_market |
— |
Market slug |
event_slug |
string |
get_event |
— |
Event slug |
token_id |
string |
price, order_book, price_history |
— |
Polymarket CLOB token id (optional for open_orders filter) |
side |
BUY | SELL |
No |
BUY |
price only |
interval |
string |
No |
"1d" |
price_history only |
start_ts |
int |
No |
— |
price_history only (unix seconds) |
end_ts |
int |
No |
— |
price_history only (unix seconds) |
fidelity |
int |
No |
— |
price_history only |
Action-specific requirements:
status, bridge_status: require an account (via --account, --wallet_address, or --wallet_label).
open_orders: requires --wallet_label and a wallet with private_key_hex in config.json (Level-2 auth). Optional: --token_id to filter.
# Search markets
poetry run wayfinder polymarket --action search --query "bitcoin above 100k" --limit 5
# User status (positions + balances)
poetry run wayfinder polymarket --action status --wallet_label main
# CLOB order book
poetry run wayfinder polymarket --action order_book --token_id 123456
polymarket_execute — Polymarket execution (bridge + orders)
Execute Polymarket actions (bridging and trading). This command is live (no dry-run flag).
| Parameter |
Type |
Required |
Default |
Notes |
action |
bridge_deposit | bridge_withdraw | buy | sell | close_position | place_limit_order | cancel_order | redeem_positions |
Yes |
— |
— |
wallet_label |
string |
Yes |
— |
Wallet must include address and private_key_hex in config |
from_chain_id |
int |
No |
137 |
bridge_deposit only |
from_token_address |
string |
No |
Polygon USDC |
bridge_deposit only |
amount |
float |
bridge_deposit |
— |
Amount of USDC to deposit |
recipient_address |
string |
No |
sender |
bridge_deposit only |
amount_usdce |
float |
bridge_withdraw |
— |
Amount of USDC.e to withdraw |
to_chain_id |
int |
No |
137 |
bridge_withdraw only |
to_token_address |
string |
No |
Polygon USDC |
bridge_withdraw only |
recipient_addr |
string |
No |
sender |
bridge_withdraw only |
token_decimals |
int |
No |
6 |
Bridge token decimals |
market_slug |
string |
No |
— |
Used by buy, sell, close_position |
outcome |
string | int |
No |
"YES" |
Used with market_slug (e.g. YES/NO) |
token_id |
string |
No |
— |
Alternative to market_slug for buy, sell, place_limit_order |
amount_usdc |
float |
buy |
— |
Buy amount in USDC |
shares |
float |
sell |
— |
Shares to sell |
side |
BUY | SELL |
No |
BUY |
place_limit_order only |
price |
float |
place_limit_order |
— |
Limit price (0–1) |
size |
float |
place_limit_order |
— |
Order size (shares) |
post_only |
bool |
No |
false |
place_limit_order only |
order_id |
string |
cancel_order |
— |
— |
condition_id |
string |
redeem_positions |
— |
Required for redeem_positions; also accepted by close_position as a fallback |
Approvals + API creds: handled automatically before order placement (idempotent).
Collateral: Polymarket CLOB trading collateral is USDC.e on Polygon, not native Polygon USDC. Use bridge_deposit / bridge_withdraw to convert. These methods prefer a fast on-chain BRAP swap on Polygon when possible (sender == recipient); otherwise they fall back to the Polymarket Bridge service (method: "polymarket_bridge" in the result) and you can monitor via polymarket --action bridge_status.
Trade semantics:
buy uses amount_usdc as collateral ($) to spend
sell uses shares as shares to sell
Always require explicit user confirmation before running polymarket_execute.
# Bridge USDC -> USDC.e collateral (Polymarket)
poetry run wayfinder polymarket_execute --action bridge_deposit --wallet_label main --amount 10
# Buy shares by market slug + outcome
poetry run wayfinder polymarket_execute --action buy --wallet_label main --market_slug "some-market-slug" --outcome YES --amount_usdc 2
# Close a position (sells full size; resolves token_id from market slug)
poetry run wayfinder polymarket_execute --action close_position --wallet_label main --market_slug "some-market-slug" --outcome YES
run_strategy — Strategy lifecycle management
Run strategy actions: check status, analyze, quote, deposit, update, withdraw, or exit.
| Parameter |
Type |
Required |
Default |
Notes |
strategy |
string |
Yes |
— |
Strategy directory name; must have manifest.yaml |
action |
status | analyze | snapshot | policy | quote | deposit | update | withdraw | exit |
Yes |
— |
— |
amount_usdc |
float |
No |
1000.0 |
Read-only analysis: hypothetical deposit for analyze, snapshot, quote |
amount |
string |
No |
— |
Generic amount parameter (strategy-specific) |
main_token_amount |
string |
deposit |
— |
Actual deposit: amount of strategy's deposit token |
gas_token_amount |
float |
No |
0.0 |
Actual deposit: optional gas token amount |
Amount parameter rules:
- For read-only analysis (
analyze, snapshot, quote): use --amount_usdc
- For actual deposits (
deposit): use --main_token_amount (required) + optionally --gas_token_amount
- The deposit token varies by strategy (USDC on Base for stablecoin_yield, USDC on Arbitrum for boros_hype, etc.)
poetry run wayfinder resource wayfinder://strategies
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action status
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action analyze --amount_usdc 100
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action quote --amount_usdc 100
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action deposit --main_token_amount 100 --gas_token_amount 0.01
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action update
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action withdraw
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action exit
Errors: invalid_request (empty strategy), not_found (missing manifest), not_supported (strategy lacks the method), strategy_error (runtime exception).
Note: withdraw liquidates positions but funds stay in the strategy wallet. exit transfers funds from the strategy wallet back to the main wallet. These are separate steps.
run_script — Execute sandboxed Python scripts
Run a local Python script in a subprocess. Scripts must live inside the runs directory ($WAYFINDER_RUNS_DIR or .wayfinder_runs/).
| Parameter |
Type |
Required |
Default |
Notes |
script_path |
string |
Yes |
— |
Must be .py, must exist, must be inside the runs directory |
args |
string |
No |
— |
Arguments passed to the script (JSON list) |
timeout_s |
int |
No |
600 |
Clamped to min 1 second |
env |
string |
No |
— |
Additional env vars for subprocess (JSON object) |
wallet_label |
string |
No |
— |
For profile annotation |
force |
flag |
No |
false |
Do not rely on this as a “dry-run vs live” gate. Prefer implementing --dry-run / --force inside your script and passing it via --args. |
Validations:
- Script path must resolve to inside the runs directory (sandboxed — no arbitrary file execution).
- Must be a
.py file.
- Must exist on disk.
- Output is truncated to 20,000 chars.
# Recommended: implement --dry-run / --force in your script and pass it via --args
poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --args '["--dry-run"]' --wallet_label main
poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --args '["--force"]' --wallet_label main
# With timeout
poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --wallet_label main --timeout_s 120
Config Structure
Config is loaded from $WAYFINDER_CONFIG_PATH (default: $WAYFINDER_SDK_PATH/config.json).
{
"system": {
"api_base_url": "https://strategies.wayfinder.ai/api/v1",
"api_key": "wk_..."
},
"strategy": {
"rpc_urls": {
"1": ["https://eth.llamarpc.com"],
"42161": ["https://arb1.arbitrum.io/rpc"],
"8453": ["https://mainnet.base.org"],
"999": ["https://rpc.hyperliquid.xyz/evm"]
}
},
"wallets": [
{
"label": "main",
"address": "0x...",
"private_key_hex": "0x..."
}
],
"ccxt": {
"aster": { "apiKey": "", "secret": "" },
"binance": { "apiKey": "", "secret": "" }
}
}
system.api_key falls back to $WAYFINDER_API_KEY env var.
- Most write operations require a wallet entry with
address + private_key_hex.
Available Strategies
| Strategy |
Status |
Chain |
Token |
Risk |
Description |
basis_trading_strategy |
stable |
Hyperliquid |
USDC |
Medium |
Delta-neutral funding rate capture with matched spot/perp positions |
boros_hype_strategy |
stable |
Arbitrum + HyperEVM + Hyperliquid |
HYPE/USDC |
Medium |
Multi-leg HYPE yield with fixed-rate funding lock via Boros |
hyperlend_stable_yield_strategy |
stable |
HyperEVM |
USDT0 |
Low |
Stablecoin yield optimization on HyperLend with rotation policy |
moonwell_wsteth_loop_strategy |
stable |
Base |
USDC/WETH/wstETH |
Medium-High |
Leveraged wstETH carry trade via Moonwell looping |
stablecoin_yield_strategy |
wip |
Base |
USDC |
Low |
Auto-rotates across best stablecoin pools on Base |
projectx_thbill_usdc_strategy |
wip |
HyperEVM |
THBILL/USDC |
Medium |
Concentrated liquidity market making on ProjectX (V3 fork) |
Reference: references/strategies.md
Available Adapters
| Adapter |
Protocol |
Capabilities |
balance_adapter |
EVM wallets |
balance.read, transfer.main_to_strategy, transfer.strategy_to_main, transfer.send |
boros_adapter |
Boros (Arbitrum) |
market.read, market.quote, position.open, position.close, collateral.deposit, collateral.withdraw |
brap_adapter |
Cross-chain swaps |
swap.quote, swap.execute, swap.compare_routes, bridge.quote, gas.estimate |
ccxt_adapter |
Centralized exchanges (CCXT) |
exchange.factory |
hyperlend_adapter |
HyperLend (HyperEVM) |
market.stable_markets, market.assets_view, market.rate_history, lending.lend, lending.unlend |
hyperliquid_adapter |
Hyperliquid DEX |
market.read, market.meta, market.funding, market.candles, market.orderbook, order.execute, order.cancel, position.manage, transfer, withdraw |
ledger_adapter |
Local bookkeeping |
ledger.read, ledger.record, ledger.snapshot |
moonwell_adapter |
Moonwell (Base) |
lending.lend, lending.unlend, lending.borrow, lending.repay, collateral.set, collateral.remove, rewards.claim, position.read, market.apy, market.collateral_factor |
multicall_adapter |
EVM batch calls |
multicall.aggregate |
pendle_adapter |
Pendle |
pendle.markets.read, pendle.market.snapshot, pendle.swap.quote, pendle.swap.execute, pendle.convert.quote, pendle.positions.database, and more |
polymarket_adapter |
Polymarket |
market.read, market.search, market.orderbook, market.candles, position.read, order.execute, order.cancel, bridge.deposit, bridge.withdraw |
pool_adapter |
DeFi Llama |
pool.read, pool.discover |
projectx_adapter |
ProjectX (V3 fork) |
projectx.pool.overview, projectx.positions.list, projectx.liquidity.mint, projectx.liquidity.increase, projectx.liquidity.decrease, projectx.fees.collect, projectx.swap.exact_in |
token_adapter |
Token metadata |
token.read, token.price, token.gas |
uniswap_adapter |
Uniswap V3 |
uniswap.liquidity.add, uniswap.liquidity.increase, uniswap.liquidity.remove, uniswap.fees.collect, uniswap.position.get, uniswap.positions.list, uniswap.fees.uncollected, uniswap.pool.get |
Reference: references/adapters.md
Token ID Format — ALWAYS SEARCH FIRST
CRITICAL: NEVER guess or construct token IDs. Always look up the correct token using the appropriate endpoint before using it in any command.
Three token endpoints — know which to use:
tokens/search → fuzzy search (hits /blockchain/tokens/fuzzy/) — always use this first for ERC20 tokens
tokens/resolve → exact lookup (hits /blockchain/tokens/detail/) — only use with an ID you got from search
tokens/gas → native gas tokens (hits /blockchain/tokens/gas/) — use for ETH, HYPE, and other native tokens
Token IDs use <coingecko_id>-<chain_code> format (NOT symbol-chain):
usd-coin-base (USDC on Base) — NOT usdc-base
ethereum-arbitrum (ETH on Arbitrum) — NOT ETH-arbitrum
usdt0-arbitrum (USDT on Arbitrum) — NOT USDT-arbitrum
hyperliquid-hyperevm (HYPE on HyperEVM) — NOT HYPE-hyperevm
You cannot reliably guess coingecko IDs from token symbols. For example, ETH's coingecko ID is ethereum, USDC's is usd-coin, HYPE's is hyperliquid. These are not derivable from the symbol alone.
Native gas tokens are best discovered via tokens/gas/<chain_code>. Use the table below as a convenient reference, but prefer tokens/gas when in doubt.
Valid chain codes (common): ethereum, base, arbitrum, polygon, bsc, avalanche, plasma, hyperevm. Note: mainnet is NOT a valid chain code — use ethereum instead.
Supported chains
| Chain |
ID |
Code |
Symbol |
Native token ID |
| Ethereum |
1 |
ethereum |
ETH |
ethereum-ethereum |
| Base |
8453 |
base |
ETH |
ethereum-base |
| Arbitrum |
42161 |
arbitrum |
ETH |
ethereum-arbitrum |
| Polygon |
137 |
polygon |
POL |
polygon-ecosystem-token-polygon |
| BSC |
56 |
bsc |
BNB |
binancecoin-bsc |
| Avalanche |
43114 |
avalanche |
AVAX |
avalanche-avalanche |
| Plasma |
9745 |
plasma |
PLASMA |
plasma-plasma |
| HyperEVM |
999 |
hyperevm |
HYPE |
hyperliquid-hyperevm |
Before every swap, send, or token operation:
# For native gas tokens (ETH, HYPE):
poetry run wayfinder resource wayfinder://tokens/gas/<chain_code>
# For ERC20 tokens — REQUIRED: fuzzy search first
poetry run wayfinder resource wayfinder://tokens/search/<chain_code>/<symbol>
# Then use the exact token ID from the search result
Sizing for Perp Orders
When a user says "$X at Yx leverage", clarify:
--usd_amount_kind margin = $X is collateral (notional = X * leverage)
--usd_amount_kind notional = $X is position size
--usd_amount and --size are mutually exclusive. When using --usd_amount with --usd_amount_kind margin, --leverage is required.
Safety
- NEVER output private keys or seed phrases into the conversation. These are secrets that must stay on the machine. Only offer to display a seed phrase if the user explicitly confirms they cannot access the machine to retrieve it themselves.
- Execution commands are live. Require explicit user confirmation before running
execute, hyperliquid_execute, polymarket_execute, or any script that broadcasts transactions.
- NEVER guess or fabricate token IDs. Before any token operation (swap, send, quote, balance check):
- For native gas tokens (ETH, HYPE): use
poetry run wayfinder resource wayfinder://tokens/gas/<chain_code>
- For ERC20 tokens: use
poetry run wayfinder resource wayfinder://tokens/search/<chain_code>/<query> (fuzzy search) and use the exact token ID from the result
- Do not construct IDs by combining symbols with chain names — the coingecko ID is unpredictable. Do not call
tokens/resolve with a guessed ID — it hits a different API than search.
- Bridging to a new chain (first time): bridge native gas to the destination chain first (use the supported-chains table or
tokens/gas/<chain_code>), then bridge/swap for the target asset.
- Start with small test amounts.
- Withdraw and exit are separate steps:
withdraw liquidates positions, exit transfers funds home.
- Hyperliquid deposits must be >= 5 USDC — amounts below 5 are lost on the bridge.
- Market order slippage is capped at 25% (
--slippage 0.25).
- Scripts are sandboxed to the runs directory — no arbitrary file execution.
Common Workflows
Check Before Trading
poetry run wayfinder resource wayfinder://balances/main
# ALWAYS look up tokens first — never guess IDs
poetry run wayfinder resource wayfinder://tokens/search/base/usdc # Search for USDC → get token ID from result
poetry run wayfinder resource wayfinder://tokens/gas/base # Get native ETH on Base
# Use the exact token IDs from the lookup results
poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
poetry run wayfinder quote_swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 1000
Deploy a Strategy
poetry run wayfinder resource wayfinder://strategies
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action status
poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --ac
…(truncated)
1---
2name: wayfinder
3description: DeFi trading, yield strategies, and portfolio management via the Wayfinder Paths CLI (`poetry run wayfinder`). Use when the user wants to check balances, swap tokens, bridge assets, trade perps, trade prediction markets (Polymarket), run automated yield strategies (stablecoin yield, basis trading, Moonwell loops, HyperLend, Boros HYPE), manage wallets, discover DeFi pools, look up token metadata, manage LP positions (Uniswap V3 / ProjectX), or execute one-off DeFi scripts. Supports Ethereum, Base, Arbitrum, Polygon, BSC, Avalanche, Plasma, and HyperEVM via protocol adapters.
4metadata:
5 source: https://skillmd.com/skills/modbender/wayfinder
6 openclaw:
7 emoji: 🧭
8 homepage: https://github.com/WayfinderFoundation/wayfinder-paths-sdk
9 requires:
10 bins:
11 - poetry
12 install:
13 - id: brew
14 kind: brew
15 formula: poetry
16 bins:
17 - poetry
18 label: Install poetry
19---
20
21# Wayfinder
22
23DeFi trading, yield strategies, and portfolio management powered by [poetry run wayfinder Paths](https://github.com/WayfinderFoundation/wayfinder-paths-sdk).
24
25## Pre-Flight Check
26
27Before running any commands, verify that poetry run wayfinder Paths is installed and reachable:
28
29```bash
30# SDK location (override by setting WAYFINDER_SDK_PATH)
31export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
32
33# Check if wayfinder-paths-sdk directory exists
34if [ ! -d "$WAYFINDER_SDK_PATH" ]; then
35 echo "ERROR: wayfinder-paths-sdk is not installed at: $WAYFINDER_SDK_PATH"
36 echo "Set WAYFINDER_SDK_PATH or run the First-Time Setup below."
37 exit 1
38fi
39
40# Config path (override by setting WAYFINDER_CONFIG_PATH)
41export WAYFINDER_CONFIG_PATH="${WAYFINDER_CONFIG_PATH:-$WAYFINDER_SDK_PATH/config.json}"
42
43# Check if the config exists
44if [ ! -f "$WAYFINDER_CONFIG_PATH" ]; then
45 echo "ERROR: config not found at $WAYFINDER_CONFIG_PATH. Run the First-Time Setup below."
46 exit 1
47fi
48
49# Check if the CLI is functional
50cd "$WAYFINDER_SDK_PATH"
51if ! poetry run wayfinder --help > /dev/null 2>&1; then
52 echo "ERROR: poetry run wayfinder CLI is not working. Run 'cd $WAYFINDER_SDK_PATH && poetry install' to fix."
53 exit 1
54fi
55
56echo "poetry run wayfinder Paths is installed and ready."
57```
58
59If either check fails, follow the **First-Time Setup** instructions below before proceeding.
60
61## Quick Start
62
63### First-Time Setup
64
65**Important:** The SDK must be installed from GitHub via `git clone`. Do NOT install from PyPI (`pip install wayfinder-paths` will not work).
66
67**Before starting:** You need a Wayfinder API key (format: `wk_...`). Get one at **https://strategies.wayfinder.ai**. The guided setup will prompt you for this key.
68
69```bash
70# Clone wayfinder-paths-sdk from GitHub (required — do NOT pip install)
71export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
72if [ ! -d "$WAYFINDER_SDK_PATH" ]; then
73 git clone https://github.com/WayfinderFoundation/wayfinder-paths-sdk.git "$WAYFINDER_SDK_PATH"
74fi
75
76cd "$WAYFINDER_SDK_PATH"
77poetry install
78
79# Run guided setup (creates/updates config.json + local dev wallets + MCP config)
80# You will need your API key from https://strategies.wayfinder.ai (format: wk_...)
81python3 scripts/setup.py
82```
83
84**Wallet security:**
85- **NEVER output private keys or seed phrases into the conversation.** These are secrets — they must stay on the machine, never in chat.
86- For a long-running bot, prefer a seed phrase stored in your backend/secret manager rather than generating random wallets on the server.
87- On first-time setup, the user should retrieve the seed phrase directly from their machine or secret manager. Only offer to display the seed phrase if the user explicitly confirms they cannot access the machine to retrieve it themselves.
88- See `references/setup.md` for detailed wallet setup instructions.
89
90### Verify Setup
91
92```bash
93export WAYFINDER_SDK_PATH="${WAYFINDER_SDK_PATH:-$HOME/wayfinder-paths-sdk}"
94export WAYFINDER_CONFIG_PATH="${WAYFINDER_CONFIG_PATH:-$WAYFINDER_SDK_PATH/config.json}"
95cd "$WAYFINDER_SDK_PATH"
96poetry run wayfinder resource wayfinder://strategies
97poetry run wayfinder resource wayfinder://wallets
98poetry run wayfinder resource wayfinder://balances/main
99```
100
101## Command Reference
102
103All commands should be run from `$WAYFINDER_SDK_PATH` and require `WAYFINDER_CONFIG_PATH` (default: `$WAYFINDER_SDK_PATH/config.json`). All responses return `{"ok": true, "result": {...}}` on success or `{"ok": false, "error": {"code": "...", "message": "..."}}` on failure.
104
105---
106
107### `resource` — Read MCP resources by URI
108
109Read-only access to adapters, strategies, wallets, balances, tokens, and Hyperliquid market data via URI-based resources. Use `--list` to see all available resources and templates.
110
111**Asset/data sourcing rule:** When the user asks you to look up token/pool/market/protocol data, first use Wayfinder’s adapter/strategy discovery resources (`poetry run wayfinder resource wayfinder://adapters`, `wayfinder://adapters/{name}`, `wayfinder://strategies`, `wayfinder://tokens/*`). Only fall back to other methods if Wayfinder doesn’t expose the required data or the user explicitly asks.
112
113```bash
114# List all available resources and templates
115poetry run wayfinder resource --list
116```
117
118#### Static Resources
119
120| URI | Description |
121|-----|-------------|
122| `wayfinder://adapters` | List all adapters with capabilities |
123| `wayfinder://strategies` | List all strategies with adapter dependencies |
124| `wayfinder://wallets` | List all configured wallets |
125| `wayfinder://hyperliquid/prices` | All Hyperliquid mid prices |
126| `wayfinder://hyperliquid/markets` | Perp market metadata, funding rates, and asset contexts |
127| `wayfinder://hyperliquid/spot-assets` | Spot asset metadata |
128
129```bash
130poetry run wayfinder resource wayfinder://adapters
131poetry run wayfinder resource wayfinder://strategies
132poetry run wayfinder resource wayfinder://wallets
133poetry run wayfinder resource wayfinder://hyperliquid/prices
134poetry run wayfinder resource wayfinder://hyperliquid/markets
135poetry run wayfinder resource wayfinder://hyperliquid/spot-assets
136```
137
138#### Resource Templates
139
140| URI Template | Description |
141|--------------|-------------|
142| `wayfinder://adapters/{name}` | Describe a single adapter (e.g. `moonwell_adapter`) |
143| `wayfinder://strategies/{name}` | Describe a single strategy (e.g. `stablecoin_yield_strategy`) |
144| `wayfinder://wallets/{label}` | Get a single wallet by label |
145| `wayfinder://balances/{label}` | Enriched multi-chain balances for a wallet |
146| `wayfinder://activity/{label}` | Recent transaction activity for a wallet |
147| `wayfinder://tokens/search/{chain_code}/{query}` | **Fuzzy token search** (hits `/tokens/fuzzy/`) — ALWAYS use this first |
148| `wayfinder://tokens/resolve/{query}` | Resolve a token by known ID (hits `/tokens/detail/`) — only use with IDs from search |
149| `wayfinder://tokens/gas/{chain_code}` | **Native gas token** for a chain (ETH, HYPE) — use for native tokens |
150| `wayfinder://hyperliquid/{label}/state` | Perp positions + PnL for a wallet |
151| `wayfinder://hyperliquid/{label}/spot` | Spot balances on Hyperliquid for a wallet |
152| `wayfinder://hyperliquid/prices/{coin}` | Mid price for a single coin |
153| `wayfinder://hyperliquid/book/{coin}` | Order book for a coin |
154
155**Token lookup order — always search or use gas endpoint first:**
156
157```bash
158# 1. For native gas tokens (ETH, HYPE): use the gas endpoint
159poetry run wayfinder resource wayfinder://tokens/gas/ethereum # ETH on Ethereum
160poetry run wayfinder resource wayfinder://tokens/gas/base # ETH on Base
161poetry run wayfinder resource wayfinder://tokens/gas/hyperevm # HYPE on HyperEVM
162
163# 2. For ERC20 tokens: ALWAYS fuzzy search first
164poetry run wayfinder resource wayfinder://tokens/search/base/usdc
165poetry run wayfinder resource wayfinder://tokens/search/arbitrum/eth
166poetry run wayfinder resource wayfinder://tokens/search/ethereum/weth
167
168# 3. Then resolve with the exact ID from search results
169poetry run wayfinder resource wayfinder://tokens/resolve/usd-coin-base
170```
171
172```bash
173poetry run wayfinder resource wayfinder://adapters/moonwell_adapter
174poetry run wayfinder resource wayfinder://strategies/stablecoin_yield_strategy
175poetry run wayfinder resource wayfinder://wallets/main
176poetry run wayfinder resource wayfinder://balances/main
177poetry run wayfinder resource wayfinder://activity/main
178poetry run wayfinder resource wayfinder://hyperliquid/main/state
179poetry run wayfinder resource wayfinder://hyperliquid/main/spot
180poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
181poetry run wayfinder resource wayfinder://hyperliquid/book/ETH
182```
183
184---
185
186### `wallets` — Manage wallets and discover positions
187
188Create, annotate, and discover cross-protocol positions. Use `resource wayfinder://wallets` to list wallets and `resource wayfinder://wallets/{label}` to get a single wallet.
189
190| Parameter | Type | Required | Default | Notes |
191|-----------|------|----------|---------|-------|
192| `action` | `"create"` \| `"annotate"` \| `"discover_portfolio"` | **Yes** | — | — |
193| `label` | string | **create** | — | Must be non-empty; duplicate labels are idempotent |
194| `wallet_label` | string | **annotate, discover_portfolio** | — | Or use `wallet_address` |
195| `wallet_address` | string | No | — | Alternative to `wallet_label` |
196| `protocol` | string | **annotate** | — | Protocol name for annotation |
197| `annotate_action` | string | **annotate** | — | Action being annotated |
198| `tool` | string | **annotate** | — | Tool name for annotation |
199| `status` | string | **annotate** | — | Status for annotation |
200| `chain_id` | string | No | — | — |
201| `details` | string (JSON) | No | — | Extra metadata for annotation |
202| `protocols` | string (JSON) | No | — | Filter `discover_portfolio` to specific protocols |
203| `parallel` | bool | No | `false` | **Required if querying >= 3 protocols** without a `protocols` filter |
204| `include_zero_positions` | bool | No | `false` | Include empty positions in portfolio |
205
206Supported protocols for `discover_portfolio`: `hyperliquid`, `hyperlend`, `moonwell`, `boros`, `pendle`.
207
208```bash
209poetry run wayfinder wallets --action create --label my_new_strategy
210poetry run wayfinder wallets --action discover_portfolio --wallet_label main --parallel
211poetry run wayfinder wallets --action discover_portfolio --wallet_label main --protocols '["hyperliquid","moonwell"]'
212```
213
214**Validations:**
215- `create`: `label` must be non-empty. Duplicate labels return the existing wallet (idempotent).
216- `annotate`/`discover_portfolio`: must resolve a wallet address from `wallet_label` or `wallet_address`.
217- `annotate`: all of `protocol`, `annotate_action`, `tool`, `status` are required.
218- `discover_portfolio` with >= 3 protocols requires `parallel=true` or an explicit `protocols` filter (returns `requires_confirmation` otherwise).
219
220---
221
222### `quote_swap` — Get a swap/bridge quote (read-only)
223
224Returns a quote for swapping or bridging tokens. No on-chain effects.
225
226| Parameter | Type | Required | Default | Notes |
227|-----------|------|----------|---------|-------|
228| `wallet_label` | string | **Yes** | — | Must resolve to a wallet with an address |
229| `from_token` | string | **Yes** | — | Token ID from search results (e.g. `usd-coin-base`). **Always search first** — do not guess. |
230| `to_token` | string | **Yes** | — | Token ID from search results. **Always search first.** |
231| `amount` | string | **Yes** | — | Human-readable amount (e.g. `"500"`). Must be positive, Decimal-parseable, and > 0 after scaling to token decimals |
232| `slippage_bps` | int | No | `50` | Slippage tolerance in basis points (50 = 0.5%) |
233| `recipient` | string | No | — | Defaults to sender address |
234| `include_calldata` | bool | No | `false` | Include raw calldata in response |
235
236**Always resolve token IDs before calling quote_swap.** Run `poetry run wayfinder resource wayfinder://tokens/search/<chain>/<symbol>` for each token first, then use the exact ID from the result. Do not pass raw symbols or guessed `symbol-chain` strings — they may resolve incorrectly or fail.
237
238**Note:** Native gas tokens (e.g., unwrapped ETH) may fail in swaps with `from_token_address: null`. Use the wrapped ERC20 version instead (e.g., WETH). Search for it: `resource wayfinder://tokens/search/<chain>/weth`.
239
240**Bridging to a new chain for the first time:** the wallet needs **native gas on the destination chain** before it can do anything. Bridge the native gas token (e.g. ETH) to the destination chain first, then bridge or swap for the target token. Use the native token IDs from the supported-chains table below (e.g. `ethereum-base` for ETH on Base).
241- Use the native token IDs from the supported-chains table below when bridging gas (e.g. `ethereum-base` for ETH on Base, `plasma-plasma` for PLASMA on Plasma).
242
243```bash
244poetry run wayfinder quote_swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 500
245poetry run wayfinder quote_swap --wallet_label main --from_token "USDC-base" --to_token "ETH-base" --amount 1000 --slippage_bps 100
246```
247
248**Errors:** `not_found` (wallet), `invalid_wallet`, `token_error`, `invalid_token` (missing chain_id/address), `invalid_amount`, `quote_error`.
249
250---
251
252### `execute` — Execute on-chain transactions
253
254Execute swaps, token sends, or Hyperliquid deposits. **This broadcasts transactions** and can move real funds.
255
256| Parameter | Type | Required | Default | Notes |
257|-----------|------|----------|---------|-------|
258| `kind` | `swap` \| `send` \| `hyperliquid_deposit` | **Yes** | — | Operation type |
259| `wallet_label` | string | **Yes** | — | Must resolve to a wallet with private key |
260| `amount` | string | **Yes** | — | Human-readable amount (e.g. `"500"`) |
261| `from_token` | string | **swap** | — | Source token ID. **Always search first.** |
262| `to_token` | string | **swap** | — | Destination token ID. **Always search first.** |
263| `slippage_bps` | int | No | `50` | Swap only; basis points |
264| `deadline_seconds` | int | No | `300` | Swap only |
265| `recipient` | string | **send** | — | Recipient address |
266| `token` | string | **send** | — | Token ID (or `"native"` with `chain_id`). **Always search first.** |
267| `chain_id` | string | No | — | Required for `send` when `token="native"` |
268| `force` | flag | No | `false` | Do not rely on this as a “dry-run vs live” gate. Treat `execute` as live and require explicit user confirmation before calling it. |
269
270**Hyperliquid deposit validations (critical):**
271- Amount **must be >= 5 USDC** (deposits below 5 are lost on the bridge).
272- Hard-codes: token = Arbitrum USDC, recipient = `HYPERLIQUID_BRIDGE_ADDRESS`, chain = Arbitrum (42161).
273
274**Additional runtime validations:**
275- Wallet must have both `address` and `private_key_hex`.
276- Token resolution must succeed (chain_id + token address required).
277- Swap quotes must return a `best_quote` with `calldata`.
278- For USDT-style tokens, a zero-allowance reset transaction is sent before approval.
279
280```bash
281# Swap
282poetry run wayfinder execute --kind swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 500
283
284# Send tokens
285poetry run wayfinder execute --kind send --wallet_label main --token usd-coin-base --recipient 0x... --amount 100
286
287# Hyperliquid deposit (min 5 USDC)
288poetry run wayfinder execute --kind hyperliquid_deposit --wallet_label main --amount 100
289```
290
291---
292
293### `hyperliquid` — Wait for Hyperliquid deposits/withdrawals
294
295Wait for deposits or withdrawals to settle on Hyperliquid. For read-only queries (user state, prices, order books), use the `resource` command with Hyperliquid URIs.
296
297| Parameter | Type | Required | Default | Notes |
298|-----------|------|----------|---------|-------|
299| `action` | `"wait_for_deposit"` \| `"wait_for_withdrawal"` | **Yes** | — | — |
300| `wallet_label` | string | No | — | Or use `wallet_address` |
301| `wallet_address` | string | No | — | Alternative to `wallet_label` |
302| `expected_increase` | string | No | — | Expected USDC increase for deposit |
303| `timeout_s` | int | No | `120` | Timeout for `wait_for_deposit` |
304| `poll_interval_s` | int | No | `5` | Poll interval for wait actions |
305| `lookback_s` | int | No | `5` | For `wait_for_withdrawal` |
306| `max_poll_time_s` | int | No | `900` | Max wait for `wait_for_withdrawal` (15 min) |
307
308```bash
309poetry run wayfinder hyperliquid --action wait_for_deposit --wallet_label main --expected_increase 100
310poetry run wayfinder hyperliquid --action wait_for_withdrawal --wallet_label main
311```
312
313**Read-only queries via resources:**
314
315```bash
316# Perp positions + PnL
317poetry run wayfinder resource wayfinder://hyperliquid/main/state
318
319# Spot balances
320poetry run wayfinder resource wayfinder://hyperliquid/main/spot
321
322# All mid prices
323poetry run wayfinder resource wayfinder://hyperliquid/prices
324
325# Single coin price
326poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
327
328# Market metadata + funding rates
329poetry run wayfinder resource wayfinder://hyperliquid/markets
330
331# Spot asset metadata
332poetry run wayfinder resource wayfinder://hyperliquid/spot-assets
333
334# Order book
335poetry run wayfinder resource wayfinder://hyperliquid/book/ETH
336```
337
338---
339
340### `hyperliquid_execute` — Hyperliquid trading operations
341
342Place/cancel orders, update leverage, and withdraw USDC. **These operations are live** and can place real orders / move real funds.
343
344| Parameter | Type | Required | Default | Notes |
345|-----------|------|----------|---------|-------|
346| `action` | `place_order` \| `cancel_order` \| `update_leverage` \| `withdraw` \| `spot_to_perp_transfer` \| `perp_to_spot_transfer` | **Yes** | — | — |
347| `wallet_label` | string | **Yes** | — | Must resolve to wallet with private key |
348| `coin` | string | **place_order, cancel_order, update_leverage** | — | Or use `asset_id`. Strips `-perp`/`_perp` suffixes automatically |
349| `asset_id` | string | No | — | Direct asset ID (alternative to `coin`) |
350| `is_spot` | string | No | — | `true` for spot orders, `false` for perp. **Must be explicit for place_order.** |
351| `order_type` | `market` \| `limit` | No | `market` | — |
352| `is_buy` | string | **place_order** | — | `true` or `false` |
353| `size` | string | No | — | **Mutually exclusive with `usd_amount`**; coin units |
354| `usd_amount` | string | No | — | **Mutually exclusive with `size`**; USD amount |
355| `usd_amount_kind` | string | **when `usd_amount` is used** | — | `notional` or `margin` |
356| `leverage` | string | **when `usd_amount_kind=margin`; update_leverage** | — | Must be positive |
357| `price` | string | **limit orders** | — | Must be positive |
358| `slippage` | float | No | `0.01` | Market orders only; 0–0.25 (25% cap) |
359| `reduce_only` | flag | No | `false` | `--reduce_only` / `--no-reduce_only` |
360| `cloid` | string | No | — | Client order ID |
361| `order_id` | string | **cancel_order** | — | Or use `cancel_cloid` |
362| `cancel_cloid` | string | No | — | Alternative to `order_id` for cancel |
363| `is_cross` | flag | No | `true` | `--is_cross` / `--no-is_cross` |
364| `amount_usdc` | string | **withdraw, transfers** | — | USDC amount for withdraw or transfers |
365| `builder_fee_tenths_bp` | string | No | — | Falls back to config default |
366| `force` | flag | No | `false` | Do not rely on this as a “dry-run vs live” gate. Treat `hyperliquid_execute` as live and require explicit user confirmation before calling it. |
367
368**Key validations for `place_order`:**
369- Exactly one of `size` or `usd_amount` (not both, not neither).
370- If `usd_amount` is used, `usd_amount_kind` is required.
371- If `usd_amount_kind=margin`, then `leverage` is required.
372- Limit orders require `price` > 0.
373- After lot-size rounding, size must still be > 0.
374- Builder fee is mandatory (auto-configured; approval is auto-submitted if needed).
375
376```bash
377# Market buy
378poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy true --usd_amount 200 --usd_amount_kind margin --leverage 5
379
380# Spot buy
381poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin HYPE --is_spot true --is_buy true --usd_amount 20
382
383# Limit sell
384poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy false --size 0.1 --price 4000 --order_type limit
385
386# Close position (reduce-only)
387poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy false --size 0.5 --reduce_only
388
389# Update leverage
390poetry run wayfinder hyperliquid_execute --action update_leverage --wallet_label main --coin ETH --leverage 5
391
392# Cancel order
393poetry run wayfinder hyperliquid_execute --action cancel_order --wallet_label main --coin ETH --order_id 12345
394
395# Withdraw USDC
396poetry run wayfinder hyperliquid_execute --action withdraw --wallet_label main --amount_usdc 100
397
398# Transfer USDC between spot and perp wallets
399poetry run wayfinder hyperliquid_execute --action spot_to_perp_transfer --wallet_label main --amount_usdc 50
400poetry run wayfinder hyperliquid_execute --action perp_to_spot_transfer --wallet_label main --amount_usdc 50
401```
402
403---
404
405### `polymarket` — Polymarket market + account reads
406
407Read-only access to Polymarket markets, prices, order books, and user status.
408
409**Tradability filter:** a market can be “found” but not tradable. Filter for `enableOrderBook`, `acceptingOrders`, `active`, `closed != true`, and non-empty `clobTokenIds`.
410
411| Parameter | Type | Required | Default | Notes |
412|-----------|------|----------|---------|-------|
413| `action` | `status` \| `search` \| `trending` \| `get_market` \| `get_event` \| `price` \| `order_book` \| `price_history` \| `bridge_status` \| `open_orders` | **Yes** | — | — |
414| `wallet_label` | string | No | — | Resolves `account` from config; required for `open_orders` |
415| `wallet_address` | string | No | — | Alternative to `wallet_label` for account-based reads |
416| `account` | string | No | — | Direct account address (alternative to wallet inputs) |
417| `include_orders` | bool | No | `true` | `status` only |
418| `include_activity` | bool | No | `false` | `status` only |
419| `activity_limit` | int | No | `50` | `status` only |
420| `include_trades` | bool | No | `false` | `status` only |
421| `trades_limit` | int | No | `50` | `status` only |
422| `positions_limit` | int | No | `500` | `status` only |
423| `max_positions_pages` | int | No | `10` | `status` only |
424| `query` | string | **search** | — | Query string for fuzzy market search |
425| `limit` | int | No | `10` | `search`, `trending` |
426| `page` | int | No | `1` | `search` |
427| `keep_closed_markets` | bool | No | `false` | `search` |
428| `rerank` | bool | No | `true` | `search` |
429| `offset` | int | No | `0` | `trending` |
430| `market_slug` | string | **get_market** | — | Market slug |
431| `event_slug` | string | **get_event** | — | Event slug |
432| `token_id` | string | **price, order_book, price_history** | — | Polymarket CLOB token id (optional for `open_orders` filter) |
433| `side` | `BUY` \| `SELL` | No | `BUY` | `price` only |
434| `interval` | string | No | `"1d"` | `price_history` only |
435| `start_ts` | int | No | — | `price_history` only (unix seconds) |
436| `end_ts` | int | No | — | `price_history` only (unix seconds) |
437| `fidelity` | int | No | — | `price_history` only |
438
439**Action-specific requirements:**
440- `status`, `bridge_status`: require an `account` (via `--account`, `--wallet_address`, or `--wallet_label`).
441- `open_orders`: requires `--wallet_label` and a wallet with `private_key_hex` in `config.json` (Level-2 auth). Optional: `--token_id` to filter.
442
443```bash
444# Search markets
445poetry run wayfinder polymarket --action search --query "bitcoin above 100k" --limit 5
446
447# User status (positions + balances)
448poetry run wayfinder polymarket --action status --wallet_label main
449
450# CLOB order book
451poetry run wayfinder polymarket --action order_book --token_id 123456
452```
453
454---
455
456### `polymarket_execute` — Polymarket execution (bridge + orders)
457
458Execute Polymarket actions (bridging and trading). **This command is live (no dry-run flag).**
459
460| Parameter | Type | Required | Default | Notes |
461|-----------|------|----------|---------|-------|
462| `action` | `bridge_deposit` \| `bridge_withdraw` \| `buy` \| `sell` \| `close_position` \| `place_limit_order` \| `cancel_order` \| `redeem_positions` | **Yes** | — | — |
463| `wallet_label` | string | **Yes** | — | Wallet must include `address` and `private_key_hex` in config |
464| `from_chain_id` | int | No | `137` | `bridge_deposit` only |
465| `from_token_address` | string | No | Polygon USDC | `bridge_deposit` only |
466| `amount` | float | **bridge_deposit** | — | Amount of USDC to deposit |
467| `recipient_address` | string | No | sender | `bridge_deposit` only |
468| `amount_usdce` | float | **bridge_withdraw** | — | Amount of USDC.e to withdraw |
469| `to_chain_id` | int | No | `137` | `bridge_withdraw` only |
470| `to_token_address` | string | No | Polygon USDC | `bridge_withdraw` only |
471| `recipient_addr` | string | No | sender | `bridge_withdraw` only |
472| `token_decimals` | int | No | `6` | Bridge token decimals |
473| `market_slug` | string | No | — | Used by `buy`, `sell`, `close_position` |
474| `outcome` | string \| int | No | `"YES"` | Used with `market_slug` (e.g. `YES`/`NO`) |
475| `token_id` | string | No | — | Alternative to `market_slug` for `buy`, `sell`, `place_limit_order` |
476| `amount_usdc` | float | **buy** | — | Buy amount in USDC |
477| `shares` | float | **sell** | — | Shares to sell |
478| `side` | `BUY` \| `SELL` | No | `BUY` | `place_limit_order` only |
479| `price` | float | **place_limit_order** | — | Limit price (0–1) |
480| `size` | float | **place_limit_order** | — | Order size (shares) |
481| `post_only` | bool | No | `false` | `place_limit_order` only |
482| `order_id` | string | **cancel_order** | — | — |
483| `condition_id` | string | **redeem_positions** | — | Required for `redeem_positions`; also accepted by `close_position` as a fallback |
484
485**Approvals + API creds:** handled automatically before order placement (idempotent).
486
487**Collateral:** Polymarket CLOB trading collateral is **USDC.e on Polygon**, not native Polygon USDC. Use `bridge_deposit` / `bridge_withdraw` to convert. These methods prefer a fast on-chain BRAP swap on Polygon when possible (sender == recipient); otherwise they fall back to the Polymarket Bridge service (`method: "polymarket_bridge"` in the result) and you can monitor via `polymarket --action bridge_status`.
488
489**Trade semantics:**
490- `buy` uses `amount_usdc` as **collateral ($) to spend**
491- `sell` uses `shares` as **shares to sell**
492
493**Always require explicit user confirmation before running `polymarket_execute`.**
494
495```bash
496# Bridge USDC -> USDC.e collateral (Polymarket)
497poetry run wayfinder polymarket_execute --action bridge_deposit --wallet_label main --amount 10
498
499# Buy shares by market slug + outcome
500poetry run wayfinder polymarket_execute --action buy --wallet_label main --market_slug "some-market-slug" --outcome YES --amount_usdc 2
501
502# Close a position (sells full size; resolves token_id from market slug)
503poetry run wayfinder polymarket_execute --action close_position --wallet_label main --market_slug "some-market-slug" --outcome YES
504```
505
506---
507
508### `run_strategy` — Strategy lifecycle management
509
510Run strategy actions: check status, analyze, quote, deposit, update, withdraw, or exit.
511
512| Parameter | Type | Required | Default | Notes |
513|-----------|------|----------|---------|-------|
514| `strategy` | string | **Yes** | — | Strategy directory name; must have `manifest.yaml` |
515| `action` | `status` \| `analyze` \| `snapshot` \| `policy` \| `quote` \| `deposit` \| `update` \| `withdraw` \| `exit` | **Yes** | — | — |
516| `amount_usdc` | float | No | `1000.0` | **Read-only analysis:** hypothetical deposit for `analyze`, `snapshot`, `quote` |
517| `amount` | string | No | — | Generic amount parameter (strategy-specific) |
518| `main_token_amount` | string | **deposit** | — | **Actual deposit:** amount of strategy's deposit token |
519| `gas_token_amount` | float | No | `0.0` | **Actual deposit:** optional gas token amount |
520
521**Amount parameter rules:**
522- **For read-only analysis** (`analyze`, `snapshot`, `quote`): use `--amount_usdc`
523- **For actual deposits** (`deposit`): use `--main_token_amount` (required) + optionally `--gas_token_amount`
524- The deposit token varies by strategy (USDC on Base for stablecoin_yield, USDC on Arbitrum for boros_hype, etc.)
525
526```bash
527poetry run wayfinder resource wayfinder://strategies
528poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action status
529poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action analyze --amount_usdc 100
530poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action quote --amount_usdc 100
531poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action deposit --main_token_amount 100 --gas_token_amount 0.01
532poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action update
533poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action withdraw
534poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action exit
535```
536
537**Errors:** `invalid_request` (empty strategy), `not_found` (missing manifest), `not_supported` (strategy lacks the method), `strategy_error` (runtime exception).
538
539**Note:** `withdraw` liquidates positions but funds stay in the strategy wallet. `exit` transfers funds from the strategy wallet back to the main wallet. These are separate steps.
540
541---
542
543### `run_script` — Execute sandboxed Python scripts
544
545Run a local Python script in a subprocess. Scripts must live inside the runs directory (`$WAYFINDER_RUNS_DIR` or `.wayfinder_runs/`).
546
547| Parameter | Type | Required | Default | Notes |
548|-----------|------|----------|---------|-------|
549| `script_path` | string | **Yes** | — | Must be `.py`, must exist, **must be inside the runs directory** |
550| `args` | string | No | — | Arguments passed to the script (JSON list) |
551| `timeout_s` | int | No | `600` | Clamped to min 1 second |
552| `env` | string | No | — | Additional env vars for subprocess (JSON object) |
553| `wallet_label` | string | No | — | For profile annotation |
554| `force` | flag | No | `false` | Do not rely on this as a “dry-run vs live” gate. Prefer implementing `--dry-run` / `--force` inside your script and passing it via `--args`. |
555
556**Validations:**
557- Script path must resolve to inside the runs directory (sandboxed — no arbitrary file execution).
558- Must be a `.py` file.
559- Must exist on disk.
560- Output is truncated to 20,000 chars.
561
562```bash
563# Recommended: implement --dry-run / --force in your script and pass it via --args
564poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --args '["--dry-run"]' --wallet_label main
565poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --args '["--force"]' --wallet_label main
566
567# With timeout
568poetry run wayfinder run_script --script_path .wayfinder_runs/my_flow.py --wallet_label main --timeout_s 120
569```
570
571---
572
573## Config Structure
574
575Config is loaded from `$WAYFINDER_CONFIG_PATH` (default: `$WAYFINDER_SDK_PATH/config.json`).
576
577```json
578{
579 "system": {
580 "api_base_url": "https://strategies.wayfinder.ai/api/v1",
581 "api_key": "wk_..."
582 },
583 "strategy": {
584 "rpc_urls": {
585 "1": ["https://eth.llamarpc.com"],
586 "42161": ["https://arb1.arbitrum.io/rpc"],
587 "8453": ["https://mainnet.base.org"],
588 "999": ["https://rpc.hyperliquid.xyz/evm"]
589 }
590 },
591 "wallets": [
592 {
593 "label": "main",
594 "address": "0x...",
595 "private_key_hex": "0x..."
596 }
597 ],
598 "ccxt": {
599 "aster": { "apiKey": "", "secret": "" },
600 "binance": { "apiKey": "", "secret": "" }
601 }
602}
603```
604
605- `system.api_key` falls back to `$WAYFINDER_API_KEY` env var.
606- Most write operations require a wallet entry with `address` + `private_key_hex`.
607
608## Available Strategies
609
610| Strategy | Status | Chain | Token | Risk | Description |
611|----------|--------|-------|-------|------|-------------|
612| `basis_trading_strategy` | stable | Hyperliquid | USDC | Medium | Delta-neutral funding rate capture with matched spot/perp positions |
613| `boros_hype_strategy` | stable | Arbitrum + HyperEVM + Hyperliquid | HYPE/USDC | Medium | Multi-leg HYPE yield with fixed-rate funding lock via Boros |
614| `hyperlend_stable_yield_strategy` | stable | HyperEVM | USDT0 | Low | Stablecoin yield optimization on HyperLend with rotation policy |
615| `moonwell_wsteth_loop_strategy` | stable | Base | USDC/WETH/wstETH | Medium-High | Leveraged wstETH carry trade via Moonwell looping |
616| `stablecoin_yield_strategy` | wip | Base | USDC | Low | Auto-rotates across best stablecoin pools on Base |
617| `projectx_thbill_usdc_strategy` | wip | HyperEVM | THBILL/USDC | Medium | Concentrated liquidity market making on ProjectX (V3 fork) |
618
619**Reference**: [references/strategies.md](references/strategies.md)
620
621## Available Adapters
622
623| Adapter | Protocol | Capabilities |
624|---------|----------|-------------|
625| `balance_adapter` | EVM wallets | `balance.read`, `transfer.main_to_strategy`, `transfer.strategy_to_main`, `transfer.send` |
626| `boros_adapter` | Boros (Arbitrum) | `market.read`, `market.quote`, `position.open`, `position.close`, `collateral.deposit`, `collateral.withdraw` |
627| `brap_adapter` | Cross-chain swaps | `swap.quote`, `swap.execute`, `swap.compare_routes`, `bridge.quote`, `gas.estimate` |
628| `ccxt_adapter` | Centralized exchanges (CCXT) | `exchange.factory` |
629| `hyperlend_adapter` | HyperLend (HyperEVM) | `market.stable_markets`, `market.assets_view`, `market.rate_history`, `lending.lend`, `lending.unlend` |
630| `hyperliquid_adapter` | Hyperliquid DEX | `market.read`, `market.meta`, `market.funding`, `market.candles`, `market.orderbook`, `order.execute`, `order.cancel`, `position.manage`, `transfer`, `withdraw` |
631| `ledger_adapter` | Local bookkeeping | `ledger.read`, `ledger.record`, `ledger.snapshot` |
632| `moonwell_adapter` | Moonwell (Base) | `lending.lend`, `lending.unlend`, `lending.borrow`, `lending.repay`, `collateral.set`, `collateral.remove`, `rewards.claim`, `position.read`, `market.apy`, `market.collateral_factor` |
633| `multicall_adapter` | EVM batch calls | `multicall.aggregate` |
634| `pendle_adapter` | Pendle | `pendle.markets.read`, `pendle.market.snapshot`, `pendle.swap.quote`, `pendle.swap.execute`, `pendle.convert.quote`, `pendle.positions.database`, and more |
635| `polymarket_adapter` | Polymarket | `market.read`, `market.search`, `market.orderbook`, `market.candles`, `position.read`, `order.execute`, `order.cancel`, `bridge.deposit`, `bridge.withdraw` |
636| `pool_adapter` | DeFi Llama | `pool.read`, `pool.discover` |
637| `projectx_adapter` | ProjectX (V3 fork) | `projectx.pool.overview`, `projectx.positions.list`, `projectx.liquidity.mint`, `projectx.liquidity.increase`, `projectx.liquidity.decrease`, `projectx.fees.collect`, `projectx.swap.exact_in` |
638| `token_adapter` | Token metadata | `token.read`, `token.price`, `token.gas` |
639| `uniswap_adapter` | Uniswap V3 | `uniswap.liquidity.add`, `uniswap.liquidity.increase`, `uniswap.liquidity.remove`, `uniswap.fees.collect`, `uniswap.position.get`, `uniswap.positions.list`, `uniswap.fees.uncollected`, `uniswap.pool.get` |
640
641**Reference**: [references/adapters.md](references/adapters.md)
642
643## Token ID Format — ALWAYS SEARCH FIRST
644
645**CRITICAL: NEVER guess or construct token IDs.** Always look up the correct token using the appropriate endpoint before using it in any command.
646
647**Three token endpoints — know which to use:**
648- **`tokens/search`** → fuzzy search (hits `/blockchain/tokens/fuzzy/`) — **always use this first for ERC20 tokens**
649- **`tokens/resolve`** → exact lookup (hits `/blockchain/tokens/detail/`) — only use with an ID you got from search
650- **`tokens/gas`** → native gas tokens (hits `/blockchain/tokens/gas/`) — **use for ETH, HYPE, and other native tokens**
651
652Token IDs use `<coingecko_id>-<chain_code>` format (NOT symbol-chain):
653- `usd-coin-base` (USDC on Base) — NOT `usdc-base`
654- `ethereum-arbitrum` (ETH on Arbitrum) — NOT `ETH-arbitrum`
655- `usdt0-arbitrum` (USDT on Arbitrum) — NOT `USDT-arbitrum`
656- `hyperliquid-hyperevm` (HYPE on HyperEVM) — NOT `HYPE-hyperevm`
657
658**You cannot reliably guess coingecko IDs from token symbols.** For example, ETH's coingecko ID is `ethereum`, USDC's is `usd-coin`, HYPE's is `hyperliquid`. These are not derivable from the symbol alone.
659
660**Native gas tokens** are best discovered via `tokens/gas/<chain_code>`. Use the table below as a convenient reference, but prefer `tokens/gas` when in doubt.
661
662Valid chain codes (common): `ethereum`, `base`, `arbitrum`, `polygon`, `bsc`, `avalanche`, `plasma`, `hyperevm`. Note: `mainnet` is NOT a valid chain code — use `ethereum` instead.
663
664### Supported chains
665
666| Chain | ID | Code | Symbol | Native token ID |
667|------|----|------|--------|-----------------|
668| Ethereum | 1 | `ethereum` | ETH | `ethereum-ethereum` |
669| Base | 8453 | `base` | ETH | `ethereum-base` |
670| Arbitrum | 42161 | `arbitrum` | ETH | `ethereum-arbitrum` |
671| Polygon | 137 | `polygon` | POL | `polygon-ecosystem-token-polygon` |
672| BSC | 56 | `bsc` | BNB | `binancecoin-bsc` |
673| Avalanche | 43114 | `avalanche` | AVAX | `avalanche-avalanche` |
674| Plasma | 9745 | `plasma` | PLASMA | `plasma-plasma` |
675| HyperEVM | 999 | `hyperevm` | HYPE | `hyperliquid-hyperevm` |
676
677**Before every swap, send, or token operation:**
678```bash
679# For native gas tokens (ETH, HYPE):
680poetry run wayfinder resource wayfinder://tokens/gas/<chain_code>
681
682# For ERC20 tokens — REQUIRED: fuzzy search first
683poetry run wayfinder resource wayfinder://tokens/search/<chain_code>/<symbol>
684# Then use the exact token ID from the search result
685```
686
687## Sizing for Perp Orders
688
689When a user says "$X at Yx leverage", clarify:
690- `--usd_amount_kind margin` = $X is collateral (notional = X * leverage)
691- `--usd_amount_kind notional` = $X is position size
692
693`--usd_amount` and `--size` are mutually exclusive. When using `--usd_amount` with `--usd_amount_kind margin`, `--leverage` is required.
694
695## Safety
696
697- **NEVER output private keys or seed phrases into the conversation.** These are secrets that must stay on the machine. Only offer to display a seed phrase if the user explicitly confirms they cannot access the machine to retrieve it themselves.
698- **Execution commands are live.** Require explicit user confirmation before running `execute`, `hyperliquid_execute`, `polymarket_execute`, or any script that broadcasts transactions.
699- **NEVER guess or fabricate token IDs.** Before any token operation (swap, send, quote, balance check):
700 - For **native gas tokens** (ETH, HYPE): use `poetry run wayfinder resource wayfinder://tokens/gas/<chain_code>`
701 - For **ERC20 tokens**: use `poetry run wayfinder resource wayfinder://tokens/search/<chain_code>/<query>` (fuzzy search) and use the exact token ID from the result
702 - Do not construct IDs by combining symbols with chain names — the coingecko ID is unpredictable. Do not call `tokens/resolve` with a guessed ID — it hits a different API than search.
703- **Bridging to a new chain (first time):** bridge native gas to the destination chain first (use the supported-chains table or `tokens/gas/<chain_code>`), then bridge/swap for the target asset.
704- Start with small test amounts.
705- Withdraw and exit are separate steps: `withdraw` liquidates positions, `exit` transfers funds home.
706- **Hyperliquid deposits must be >= 5 USDC** — amounts below 5 are lost on the bridge.
707- Market order slippage is capped at 25% (`--slippage 0.25`).
708- Scripts are sandboxed to the runs directory — no arbitrary file execution.
709
710## Common Workflows
711
712### Check Before Trading
713
714```bash
715poetry run wayfinder resource wayfinder://balances/main
716# ALWAYS look up tokens first — never guess IDs
717poetry run wayfinder resource wayfinder://tokens/search/base/usdc # Search for USDC → get token ID from result
718poetry run wayfinder resource wayfinder://tokens/gas/base # Get native ETH on Base
719# Use the exact token IDs from the lookup results
720poetry run wayfinder resource wayfinder://hyperliquid/prices/ETH
721poetry run wayfinder quote_swap --wallet_label main --from_token usd-coin-base --to_token ethereum-base --amount 1000
722```
723
724### Deploy a Strategy
725
726```bash
727poetry run wayfinder resource wayfinder://strategies
728poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action status
729poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action deposit --main_token_amount 100 --gas_token_amount 0.01
730poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action update
731```
732
733### Open a Hyperliquid Position
734
735```bash
736poetry run wayfinder resource wayfinder://hyperliquid/main/state
737poetry run wayfinder hyperliquid_execute --action update_leverage --wallet_label main --coin ETH --leverage 5
738poetry run wayfinder hyperliquid_execute --action place_order --wallet_label main --coin ETH --is_buy true --usd_amount 200 --usd_amount_kind margin --leverage 5
739```
740
741### Wind Down Everything
742
743```bash
744poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action withdraw
745poetry run wayfinder run_strategy --strategy stablecoin_yield_strategy --action exit
746```
747
748## Custom Scripts via the Coding Interface
749
750**For any operation that goes beyond a single CLI command, you SHOULD write a custom Python script.** The `wayfinder-paths-sdk` provides a full coding interface — use it whenever you need multi-step flows, conditional logic, batched operations, or protocol combinations.
751
752### When to Write a Script
753
754- **Multi-step atomic flows** — operations that must succeed together
755- **Custom logic** — conditional execution based on market state
756- **Batched operations** — multiple protocol interactions in sequence
757- **Protocol combinations** — bridging multiple adapters in one flow
758- **Complex calculations** — position sizing, rebalancing, PnL analysis
759- **Anything the user asks that isn't a single CLI call**
760
761### Script Location
762
763All generated scripts **must** be saved to `.wayfinder_runs/` inside the SDK directory:
764
765```
766$WAYFINDER_SDK_PATH/.wayfinder_runs/my_script.py
767```
768
769This directory is sandboxed — `run_script` only executes scripts inside it. Create it if it doesn't exist:
770
771```bash
772mkdir -p "$WAYFINDER_SDK_PATH/.wayfinder_runs"
773```
774
775### Referencing the SDK Source
776
777Before writing any script, **pull the detailed reference docs** for the adapter or strategy you're working with. The SDK ships comprehensive skill docs covering method signatures, gotchas, unit conventions, and execution patterns.
778
779**Use the reference script** (bash or PowerShell):
780
781```bash
782# List available topics
783./wayfinder/scripts/pull-sdk-ref.sh --list
784
785# Pull docs for specific adapters (supports multiple topics)
786./wayfinder/scripts/pull-sdk-ref.sh moonwell
787./wayfinder/scripts/pull-sdk-ref.sh boros hyperliquid
788./wayfinder/scripts/pull-sdk-ref.sh strategies
789
790# Pull everything
791./wayfinder/scripts/pull-sdk-ref.sh --all
792
793# Check the pinned SDK version
794./wayfinder/scripts/pull-sdk-ref.sh --version
795
796# Override with a specific commit
797./wayfinder/scripts/pull-sdk-ref.sh --commit abc123 moonwell
798```
799
800```powershell
801# Windows
802.\wayfinder\scripts\pull-sdk-ref.ps1 moonwell
803.\wayfinder\scripts\pull-sdk-ref.ps1 -All
804.\wayfinder\scripts\pull-sdk-ref.ps1 -Version
805.\wayfinder\scripts\pull-sdk-ref.ps1 -Commit abc123 moonwell
806```
807
808**Available topics:** `strategies`, `setup`, `boros`, `brap`, `hyperlend`, `hyperliquid`, `polymarket`, `moonwell`, `pendle`, `uniswap`, `projectx`, `data`
809
810The SDK ref is tracked in `wayfinder/sdk-version.md` (default: `main`). The pull script checks out that ref when reading docs, then restores the SDK to its previous state.
811
812**Always run this before writing a script** — the docs cover critical details like:
813- Exact method signatures and required parameters
814- Unit conventions (raw base units vs human-readable, wei vs native)
815- Gotchas (e.g., `unlend()` takes mToken amounts not underlying, withdrawal cooldowns, funding sign conventions)
816- Execution patterns and safety rails
817- Token/contract addresses
818
819You can also read the adapter source code directly:
820
821```
822$WAYFINDER_SDK_PATH/wayfinder_paths/adapters/ # All adapter implementations
823$WAYFINDER_SDK_PATH/wayfinder_paths/mcp/scripting.py # get_adapter() helper
824$WAYFINDER_SDK_PATH/wayfinder_paths/strategies/ # Strategy implementations
825```
826
827### Quick Start
828
829```python
830#!/usr/bin/env python3
831import asyncio
832from wayfinder_paths.mcp.scripting import get_adapter
833from wayfinder_paths.adapters.moonwell_adapter import MoonwellAdapter
834
835async def main():
836 adapter = get_adapter(MoonwellAdapter, "main") # Auto-wires config + signing
837 success, result = await adapter.lend(mtoken="0x...", amount=100_000_000)
838 print(f"Result: {result}" if success else f"Error: {result}")
839
840if __name__ == "__main__":
841 asyncio.run(main())
842```
843
844### Testing Workflow
845
846**Always test before live execution.** Follow this workflow:
847
8481. **Write** the script to `.wayfinder_runs/`
8492. **Safe run** — run the script in a non-fund-moving mode first (recommended: implement `--dry-run` / `--force` in your script and pass it via `--args`):
850 ```bash
851 cd "$WAYFINDER_SDK_PATH"
852 poetry run wayfinder run_script --script_path .wayfinder_runs/my_script.py --args '["--dry-run"]' --wallet_label main
853 ```
8543. **Review** the output. Verify the operations, amounts, and addresses are correct.
8554. **Live execution** — only after confirming the safe run looks right, run with `--force`:
856 ```bash
857 poetry run wayfinder run_script --script_path .wayfinder_runs/my_script.py --args '["--force"]' --wallet_label main
858 ```
859
860**Never skip the safe-run step for scripts that move funds.**
861
862**Reference**: [references/coding-interface.md](references/coding-interface.md) — Full adapter API reference, examples, and patterns
863
864## Protocol References
865
866- [references/setup.md](references/setup.md) — First-time setup, configuration, and wallet management
867- [references/strategies.md](references/strategies.md) — Strategy details, parameters, and workflows
868- [references/adapters.md](references/adapters.md) — Adapter capabilities and method signatures
869- [references/coding-interface.md](references/coding-interface.md) — Custom Python scripting with adapters
870- [references/hyperliquid.md](references/hyperliquid.md) — Hyperliquid trading, deposits, funding
871- [references/polymarket.md](references/polymarket.md) — Polymarket markets, bridging, and trading
872- [references/ccxt.md](references/ccxt.md) — Centralized exchanges (Aster/Binance/etc.) via CCXT (use carefully)
873- [references/moonwell.md](references/moonwell.md) — Moonwell lending, mToken addresses, gotchas
874- [references/pendle.md](references/pendle.md) — Pendle PT/YT markets, swap execution
875- [references/boros.md](references/boros.md) — Boros fixed-rate markets, rate locking
876- [references/uniswap.md](references/uniswap.md) — Uniswap V3 LP positions and fee collection
877- [references/projectx.md](references/projectx.md) — ProjectX (V3 fork) LP positions, swaps, and strategy notes
878- [references/tokens-and-pools.md](references/tokens-and-pools.md) — Token IDs, pool discovery, balance reads
879- [references/hyperlend.md](references/hyperlend.md) — HyperLend lending, supply/withdraw flows
880
881## Error Handling
882
883All errors return structured JSON: `{"ok": false, "error": {"code": "...", "message": "...", "details": ...}}`.
884
885### Error Categories
886
887#### Validation Errors — bad input, fixable by the caller
888
889| Error Code | Meaning | Common Causes | User-Facing Guidance |
890|------------|---------|---------------|----------------------|
891| `invalid_request` | Missing or invalid required parameters | Omitted `action`, empty `strategy`, missing `token_id` for balance query | Tell the user which parameter is missing and show the correct command format |
892| `invalid_wallet` | Wallet missing `address` or `private_key_hex` | Wallet label exists but entry is incomplete; read-only wallet used for execution | Ask the user to check their config.json wallet entry has both fields |
893| `invalid_token` | Token resolution failed — missing `chain_id` or contract `address` after lookup | Typo in token ID, token not indexed, ambiguous symbol without chain qualifier | Suggest running `resource wayfinder://tokens/search/<chain>/<query>` and show the closest matches |
894| `invalid_amount` | Amount not parseable, not positive, or zero after decimal scaling | Non-numeric string, negative value, amount like `0.000000001` that rounds to 0 for a low-decimal token | Show the parsed value and the token's decimals so the user understands the rounding |
895
896#### Resource Errors — something doesn't exist
897
898| Error Code | Meaning | Common Causes | User-Facing Guidance |
899|------------|---------|---------------|----------------------|
900| `not_found` | Directory, manifest, wallet, or resource not found | Strategy name typo, adapter not installed, wallet label doesn't match config | List available resources (`resource wayfinder://strategies`) so the user can pick the right name |
901| `not_supported` | Strategy does not implement the requested action | Calling `withdraw` on a strategy that only supports `status`/`deposit` | Show which actions the strategy does support (from its manifest) |
902| `requires_confirmation` | Operation needs explicit user confirmation before proceeding | `discover_portfolio` across >= 3 protocols without `--parallel` flag | Explain the operation scope and ask the user to confirm or pass `--parallel` |
903
904#### API & Integration Errors — upstream service failures
905
906| Error Code | Meaning | Common Causes | User-Facing Guidance |
907|------------|---------|---------------|----------------------|
908| `token_error` | Token adapter API call failed | Wayfinder API down, network timeout, invalid API key | Check API key validity; retry after a moment; show the raw error message from details |
909| `quote_error` | Swap/bridge quote generation failed | No liquidity for pair, amount too small for routing, bridge route unavailable | Suggest trying a different amount, checking if the pair is supported, or using a different route |
910| `balance_error` | Balance query failed | RPC node down, rate-limited, invalid chain_id | Retry; if persistent, check RPC URL configuration |
911| `activity_error` | Activity/transaction history query failed | Indexer lag, unsupported chain for activity | Inform user the history service may be temporarily unavailable |
912| `price_error` | Price lookup failed | Token not priced by CoinGecko, API rate limit | Note that the token may be too new or illiquid for price data; balances are still valid without prices |
913
914#### Execution Errors — on-chain failures
915
916| Error Code | Meaning | Common Causes | User-Facing Guidance |
917|------------|---------|---------------|----------------------|
918| `executor_error` | On-chain transaction failed | Insufficient gas, contract revert, nonce conflict, allowance issue | Show the revert reason if available; check gas balance; for USDT-style tokens, mention the zero-allowance reset |
919| `strategy_error` | Strategy runtime exception | Unhandled edge case in strategy code, external dependency failure mid-execution | Show the exception message; suggest checking `status` before retrying |
920
921### Error Details Object
922
923The `details` field varies by error code and may contain:
924
925| Field | Present On | Description |
926|-------|-----------|-------------|
927| `parameter` | `invalid_request` | The specific parameter that failed validation |
928| `wallet_label` | `invalid_wallet`, `not_found` | The wallet label that was looked up |
929| `query` | `invalid_token` | The token query that failed resolution |
930| `candidates` | `invalid_token` | Fuzzy match candidates when available |
931| `raw_amount` | `invalid_amount` | The original amount string provided |
932| `scaled_amount` | `invalid_amount` | The amount after decimal scaling (shows why it became zero) |
933| `decimals` | `invalid_amount` | Token decimals used for scaling |
934| `tx_hash` | `executor_error` | Transaction hash if the tx was submitted before failing |
935| `revert_reason` | `executor_error` | Decoded revert reason from the contract |
936| `strategy` | `strategy_error`, `not_supported` | Strategy name |
937| `supported_actions` | `not_supported` | List of actions the strategy does implement |
938| `protocols` | `requires_confirmation` | The protocols that would be queried |
939| `upstream_error` | `token_error`, `quote_error`, `balance_error`, `activity_error`, `price_error` | Raw error message from the upstream service |
940
941### Presenting Errors to Users
942
943When an error is returned, follow this pattern:
944
9451. **Translate the code** — don't show raw error codes. Map to plain language (e.g., `invalid_token` -> "I couldn't find that token").
9462. **Include the actionable fix** — every error above has a recovery path. Always tell the user what to do next.
9473. **Show relevant details** — if `details.candidates` exists, list the closest token matches. If `details.revert_reason` exists, explain what the contract rejected.
9484. **Offer to retry** — for transient errors (`token_error`, `balance_error`, `quote_error`, `activity_error`, `price_error`), offer to retry. For validation errors, show the corrected command.
949
950### Common User-Facing Issues
951
952| Symptom | Error Code | Resolution |
953|---------|-----------|------------|
954| "Missing config" | `not_found` | Run setup or create `config.json` manually |
955| "strategy_wallet not configured" | `invalid_wallet` | Add wallet with matching label to config.json |
956| "Minimum deposit" | `invalid_amount` | Check strategy minimum requirements (e.g., Hyperliquid >= 5 USDC) |
957| "Insufficient gas" | `executor_error` | Fund wallet with native gas token for the target chain |
958| "Token not found" | `invalid_token` | Use `resource wayfinder://tokens/search/<chain>/<query>` to find the correct coingecko ID |
959| "No quote available" | `quote_error` | Try a different amount, check pair liquidity, or use an alternative route |
960| "Nonce too low" | `executor_error` | A previous transaction is pending; wait or speed it up |
961| "Allowance reset needed" | `executor_error` | For USDT-style tokens, the CLI auto-resets allowance — retry if it was a transient RPC issue |
962| "Rate limited" | `token_error` / `balance_error` | Wait a few seconds and retry the request |
963
964## Best Practices
965
966### Security
9671. Never share private keys or commit config.json
9682. Start with small test amounts
9693. Use dedicated wallets per strategy for isolation
9704. Verify addresses before large transfers
9715. Use stop losses for leverage trading
972
973### Trading
9741. Always quote before executing swaps
9752. Specify chain for lesser-known tokens
9763. Consider gas costs (use Base for small amounts)
9774. Check balance before trades
9785. Use limit orders for better prices on Hyperliquid