morpho-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemorpho-cli
morpho-cli
Experimental (pre-v1.0) — Command syntax, response schemas, and available operations may change. Always verify critical outputs independently.
Query Morpho protocol data and build unsigned transactions. All commands output JSON to stdout. No private keys needed.
bash
morpho <command> [options]Supported chains: , . Every command requires .
baseethereum--chain实验版本(v1.0之前) — 命令语法、响应结构和可用操作可能会发生变化。重要输出请务必独立验证。
查询Morpho协议数据,构建未签名交易。所有命令的输出都是JSON格式打印到标准输出,无需私钥。
bash
morpho <command> [options]支持的链:、。所有命令都需要指定参数。
baseethereum--chainResponse Schemas
响应结构
- Read commands — exact JSON shapes for query-vaults, get-vault, query-markets, get-market, get-positions, get-position
- Write commands — exact JSON shapes for prepare-*, simulate-transactions
- 读操作命令 — query-vaults、get-vault、query-markets、get-market、get-positions、get-position的准确JSON结构定义
- 写操作命令 — prepare-*、simulate-transactions的准确JSON结构定义
Quick Reference
快速参考
bash
undefinedbash
undefinedRead — query protocol state
读操作 — 查询协议状态
morpho query-vaults --chain base [--asset-symbol USDC] [--asset-address 0x...] [--sort apy_desc|apy_asc|tvl_desc|tvl_asc] [--limit 5] [--skip 0] [--fields address,name,symbol,apyPct,tvl,tvlUsd,feePct]
morpho get-vault --chain base --address 0x...
morpho query-markets --chain base --loan-asset 0x... --collateral-asset 0x... [--sort-by supplyApy|borrowApy|netSupplyApy|netBorrowApy|supplyAssetsUsd|borrowAssetsUsd|totalLiquidityUsd] [--sort-direction asc|desc] [--limit 10] [--skip 0] [--fields supplyApy,borrowApy,totalSupply,totalBorrow,totalCollateral,totalLiquidity,supplyAssetsUsd,borrowAssetsUsd,collateralAssetsUsd,liquidityAssetsUsd]
morpho get-market --chain base --id 0x...
morpho get-positions --chain base --user-address 0x... [--vault-address 0x...] [--market-id 0x...]
morpho get-position --chain base --user-address 0x... [--vault-address 0x...]
morpho query-vaults --chain base [--asset-symbol USDC] [--asset-address 0x...] [--sort apy_desc|apy_asc|tvl_desc|tvl_asc] [--limit 5] [--skip 0] [--fields address,name,symbol,apyPct,tvl,tvlUsd,feePct]
morpho get-vault --chain base --address 0x...
morpho query-markets --chain base --loan-asset 0x... --collateral-asset 0x... [--sort-by supplyApy|borrowApy|netSupplyApy|netBorrowApy|supplyAssetsUsd|borrowAssetsUsd|totalLiquidityUsd] [--sort-direction asc|desc] [--limit 10] [--skip 0] [--fields supplyApy,borrowApy,totalSupply,totalBorrow,totalCollateral,totalLiquidity,supplyAssetsUsd,borrowAssetsUsd,collateralAssetsUsd,liquidityAssetsUsd]
morpho get-market --chain base --id 0x...
morpho get-positions --chain base --user-address 0x... [--vault-address 0x...] [--market-id 0x...]
morpho get-position --chain base --user-address 0x... [--vault-address 0x...]
Write — prepare unsigned transactions (simulation runs by default; add --no-simulate to skip)
写操作 — 准备未签名交易(默认会自动运行模拟;添加--no-simulate可跳过)
morpho prepare-deposit --chain base --vault-address 0x... --user-address 0x... --amount 1000
morpho prepare-withdraw --chain base --vault-address 0x... --user-address 0x... --amount max
morpho prepare-supply --chain base --market-id 0x... --user-address 0x... --amount 5000
morpho prepare-borrow --chain base --market-id 0x... --user-address 0x... --borrow-amount 1
morpho prepare-repay --chain base --market-id 0x... --user-address 0x... --amount max
morpho prepare-supply-collateral --chain base --market-id 0x... --user-address 0x... --amount 5000
morpho prepare-withdraw-collateral --chain base --market-id 0x... --user-address 0x... --amount max
morpho prepare-deposit --chain base --vault-address 0x... --user-address 0x... --amount 1000
morpho prepare-withdraw --chain base --vault-address 0x... --user-address 0x... --amount max
morpho prepare-supply --chain base --market-id 0x... --user-address 0x... --amount 5000
morpho prepare-borrow --chain base --market-id 0x... --user-address 0x... --borrow-amount 1
morpho prepare-repay --chain base --market-id 0x... --user-address 0x... --amount max
morpho prepare-supply-collateral --chain base --market-id 0x... --user-address 0x... --amount 5000
morpho prepare-withdraw-collateral --chain base --market-id 0x... --user-address 0x... --amount max
Simulate — standalone re-simulation or arbitrary transaction simulation
模拟 — 独立重新模拟或任意交易模拟
morpho simulate-transactions --chain base --from 0x... --transactions '<JSON>' --analysis-context '<JSON>'
morpho simulate-transactions --chain base --from 0x... --transactions '<JSON>' --analysis-context '<JSON>'
Utility
工具类命令
morpho health-check
morpho get-supported-chains
undefinedmorpho health-check
morpho get-supported-chains
undefinedWrite Workflow: Prepare → Present
写操作工作流:准备 → 展示
Every write operation follows two steps. Simulation runs automatically inside .
prepare-*- Prepare — run a command. The CLI handles token decimals, allowances, approvals, and simulation automatically. Returns
prepare-*where{operation, simulation}has transactions/summary/warnings/preview andoperationhas execution results, gas, and post-state analysis. Usesimulationto skip simulation.--no-simulate - Present — show the summary, list of unsigned transactions, simulation results, and any warnings (low health factor, partial liquidity) in tabular format. If is false — diagnose before presenting.
simulation.allSucceeded
Use separately only for re-simulating with different parameters or simulating arbitrary transactions.
simulate-transactions所有写操作都遵循两个步骤。命令内部会自动运行模拟。
prepare-*- 准备 — 执行命令。CLI会自动处理代币精度、授权限额、批准和模拟。返回
prepare-*结构,其中{operation, simulation}包含交易/摘要/警告/预览信息,operation包含执行结果、gas消耗和交易后状态分析。可添加simulation参数跳过模拟。--no-simulate - 展示 — 以表格形式展示摘要、未签名交易列表、模拟结果和所有警告(健康因子过低、流动性不足等)。如果为false — 请先诊断问题再展示结果。
simulation.allSucceeded
仅当需要使用不同参数重新模拟或模拟任意交易时,才单独使用命令。
simulate-transactionsSimulation Failures
模拟失败说明
| Revert | Cause | What to do |
|---|---|---|
| Missing approval | Re-prepare — CLI should include approvals automatically |
| Vault liquidity insufficient | Reduce amount (see below) |
| User lacks tokens | Tell the user |
| Custom error hex | Protocol-specific | Query state with |
| 报错信息 | 原因 | 解决方法 |
|---|---|---|
| 缺少授权 | 重新执行准备命令 — CLI会自动包含授权操作 |
| 金库流动性不足 | 减少取款金额(见下文) |
| 用户代币余额不足 | 告知用户 |
| 自定义错误十六进制码 | 协议特定报错 | 使用 |
Partial Withdrawal
部分取款说明
If returns a liquidity warning:
prepare-withdraw --amount max- Parse the safe amount from , apply ~1% buffer (
summary)parsedAmount * 0.99 - Re-call with the buffered amount, then simulate
prepare-withdraw - Tell the user: remaining locked assets free up as borrowers repay
如果返回流动性警告:
prepare-withdraw --amount max- 从中解析安全取款金额,添加约1%的缓冲(
summary)解析后金额 * 0.99 - 使用带缓冲的金额重新调用,然后执行模拟
prepare-withdraw - 告知用户:剩余锁定资产会随着借款人还款而逐步解锁
Safety Rules
安全规则
- Check simulation before presenting — simulation runs by default; check before presenting
simulation.allSucceeded - Never sign or broadcast — unsigned payloads only
- Watch health factor for borrows — warn if below 1.1
- Communicate liquidity constraints clearly for partial withdrawals
- 展示前先检查模拟结果 — 默认会自动运行模拟;展示前请先检查字段
simulation.allSucceeded - 绝不签名或广播交易 — 仅生成未签名负载
- 借款时关注健康因子 — 如果低于1.1请发出警告
- 部分取款时要清晰告知流动性限制
CLI Errors
CLI错误处理
When a morpho CLI command fails, stop and report the error to the user. Do not:
- Retry with different parameters you invented
- Fall back to alternative tools or APIs
- Attempt to work around missing required options
- Pipe output through or other filters — use the CLI's built-in flags (
jq,--fields,--sort-by, etc.) to shape the response--limit
当morpho CLI命令执行失败时,停止操作并向用户上报错误。请勿:
- 自行修改参数重试
- 切换到其他工具或API作为兜底
- 尝试绕过必填参数的限制
- 通过或其他过滤器处理输出 — 使用CLI内置的参数(
jq、--fields、--sort-by等)来调整返回结果格式--limit
Common Mistakes
常见错误
- Forgetting — every command requires it, there is no default
--chain - Using chain IDs (,
1) instead of names (8453,ethereum)base - Displaying raw amounts without dividing by —
10^decimalsUSDC is"2000000000", not 2 billion2000 - Assuming 18 decimals — USDC/USDT have 6
- Passing raw units as — CLI expects human-readable (
--amountnot1000)1000000000 - Using without reason — simulation is on by default; only skip when debugging or for speed
--no-simulate - Ignoring — diagnose before presenting
simulation.allSucceeded === false
- 忘记加参数 — 所有命令都需要该参数,没有默认值
--chain - 使用链ID(、
1)而不是链名称(8453、ethereum)base - 展示原始金额时没有除以—
10^精度USDC对应的是"2000000000",而不是20亿2000 - 默认为18位精度 — USDC/USDT的精度是6位
- 向传入原始单位值 — CLI需要的是人类可读的数值(
--amount而不是1000)1000000000 - 无理由使用— 默认开启模拟;仅在调试或需要提升速度时跳过
--no-simulate - 忽略的情况 — 先诊断问题再展示结果
simulation.allSucceeded === false