使用yieldsllama CLI(由DeFi Llama API驱动)跨链查询DeFi收益机会。在用户询问DeFi收益率、APY、最佳 staking 等时使用。
Query and compare DeFi yield pool data from DeFi Llama.
If Rust is not installed, run:
bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
bash
# Clone the repo
git clone https://github.com/0x9bb1/yieldsllama.git /tmp/yieldsllama
# Build release binary
cd /tmp/yieldsllama && cargo build --release
# Install to PATH
cp /tmp/yieldsllama/target/release/yieldsllama /usr/local/bin/yieldsllama
# Verify
yieldsllama --help
The tool needs a .env file in the current working directory with the DeFi Llama API endpoint. Before each run, ensure it exists:
bash
if [ ! -f .env ]; then echo 'LLAMA_DOMAIN="https://yields.llama.fi"' > .env; fi
bash
yieldsllama [OPTIONS]
FlagDescriptionDefault-l, --limit <N>Number of results to return10-e, --exposure <TYPE>Pool type: single or multisingle-s, --sort <FIELD>Sort by: apy or tvlapy-t, --tvl <MIN>Minimum TVL in USDnone-c, --chain <CHAIN>Filter by chain name (case-insensitive)none-a, --asset <TOKEN>Filter by token symbol (case-insensitive)none
bash
# Top 10 highest APY single-asset pools
yieldsllama
# Top 20 pools sorted by TVL
yieldsllama -l 20 -s tvl
# Best USDC yields with TVL > $10M
yieldsllama -a USDC -t 10000000
# Best USDT yields on Ethereum
yieldsllama -a USDT -c Ethereum
# Best multi-asset pool yields
yieldsllama -e multi -l 10
# Compare stablecoins with TVL > $10M
yieldsllama -a USDC -t 10000000 -l 5
yieldsllama -a USDT -t 10000000 -l 5
yieldsllama -a USDE -t 10000000 -l 5
yieldsllama -a DAI -t 10000000 -l 5
# Best ETH yields with TVL > $1M
yieldsllama -a WETH -t 1000000 -l 10
# Best yields on specific chains
yieldsllama -c Ethereum -t 1000000 -l 10
yieldsllama -c Base -t 1000000 -l 10
yieldsllama -c Arbitrum -t 1000000 -l 10
ColumnDescriptionapyTotal APY (apyBase + apyReward)symbolToken symbolchainBlockchain networkprojectProtocol nametvlUsdTotal Value Locked in USDapyBaseBase lending/staking APY (organic, sustainable)apyRewardReward token APY (may be unsustainable, subject to token price)exposuresingle (one asset) or multi (LP pair etc.)
When presenting yield data to the user, always consider and mention:
-t for serious allocation decisions.When the user asks "which token/pool has the best yield", run queries for each token in parallel and present a unified comparison table. Example:
text
User: "Compare USDC, USDT, USDE yields with TVL > $10M"
Run in parallel:
yieldsllama -a USDC -t 10000000 -l 5
yieldsllama -a USDT -t 10000000 -l 5
yieldsllama -a USDE -t 10000000 -l 5
Then summarize the top option for each token and give a recommendation.
The tool caches API responses in data.json for 12 hours. To force refresh:
bash
rm -f data.json && yieldsllama
ProblemSolutionyieldsllama: command not foundBinary not in PATH. Run cp /path/to/yieldsllama /usr/local/bin/``读取本地data.json文件异常Normal on first run — it fetches from API and creates data.json``本地文件过期Cache expired (>12h). Tool auto-fetches fresh dataEmpty resultsToken symbol or chain name may not match exactly. Try without -c/ -a filters firstNetwork errorCheck internet connection; DeFi Llama API ( yields.llama.fi) may be temporarily down.env errorEnsure .env exists in current directory with LLAMA_DOMAIN="https://yields.llama.fi"