命令
本指南介绍如何在 Hummingbot 客户端中使用 Gateway 命令。通过 Gateway 命令,您可以直接从 Hummingbot 管理钱包、执行交易、管理流动性仓位以及配置 Gateway 设置。
安装与设置¶
在使用 Gateway 命令之前,您需要先安装并运行 Gateway。请按照 Gateway 安装指南 中的说明,使用 Docker 或源码方式完成 Gateway 的安装与配置。
Gateway 启动后,您可以在 Hummingbot 中验证连接状态:
- 检查状态指示器:查看 Hummingbot 客户端右上角是否显示
GATEWAY: 🟢 ONLINE - 测试连接:运行
gateway ping命令,验证 Gateway 是否可访问且链节点已连接 - 生成证书(如需要):运行
gateway generate-certs命令,为安全通信创建 SSL 证书
如果在右上角看到 GATEWAY: 🔴 OFFLINE:
- 确保 Gateway 正在运行(检查 Docker 容器或进程)
- 确认 Gateway 在正确的端口上运行(默认:15888)
- 检查 Hummingbot 和 Gateway 的证书是否匹配(如果您以生产模式运行)
- 查看 Gateway 日志中是否有错误信息
gateway --help¶
查看所有可用的 Gateway 命令及其说明:
>>> gateway --help
usage: gateway [-h] {allowance,approve,balance,config,connect,generate-certs,list,lp,ping,pool,swap,token} ...
positional arguments:
{allowance,approve,balance,config,connect,generate-certs,list,lp,ping,pool,swap,token}
allowance Check token allowances for ethereum connectors
approve Approve token for use with ethereum connectors
balance Check token balances
config Show or update configuration
connect Add a wallet for a chain
generate-certs Create SSL certificate
list List available connectors
lp Manage liquidity positions
ping Test node and chain/network status
pool View or update pool information
swap Swap tokens
token View or update token information
gateway ping¶
测试与 Gateway 的连接,并检查节点/链的状态。
>>> gateway ping
Gateway service is online.
Testing network status for 2 chains...
ethereum (base):
- RPC URL: https://small-dimensional-pine.base-mainnet.quiknode.pro/d01204cade4fab5
2085cd0033c01bb2606a40c33
- Current Block: 34463843
- Native Currency: ETH
- Status: ✓ Connected
solana (mainnet-beta):
- RPC URL: https://dry-dawn-hill.solana-mainnet.quiknode.pro/41bbd7ad405c552f91cc92
8e044e5e04c66341d2
- Current Block: 361378534
- Native Currency: SOL
- Status: ✓ Connected
gateway list¶
列出所有可用的链、网络和连接器。
>>> gateway list
+-------------+--------------+------------------------------------------------------------------+-------------------+
| connector | chain_type | networks | trading_types |
|-------------+--------------+------------------------------------------------------------------+-------------------|
| jupiter | solana | devnet, mainnet-beta | router |
| meteora | solana | devnet, mainnet-beta | clmm |
| raydium | solana | devnet, mainnet-beta | amm, clmm |
| uniswap | ethereum | arbitrum, avalanche, base, bsc, celo, mainnet, optimism, polygon | amm, clmm, router |
| 0x | ethereum | arbitrum, avalanche, base, bsc, mainnet, optimism, polygon | router |
+-------------+--------------+------------------------------------------------------------------+-------------------+
gateway connect¶
为特定链添加钱包。这是将钱包连接到 Gateway 的主要方式。成功添加钱包后,它会自动成为 Gateway 配置中该链(ethereum 或 solana)的 defaultWallet。
usage: gateway connect [-h] [chain]
positional arguments:
chain Blockchain chain (e.g., ethereum, solana)
添加普通钱包¶
>>> gateway connect ethereum
Select Option (1) Add Regular Wallet, (2) Add Hardware Wallet, (3) Exit [default: 3]: 1
Enter your ethereum wallet private key: *********
添加硬件钱包¶
>>> gateway connect ethereum
Select Option (1) Add Regular Wallet, (2) Add Hardware Wallet, (3) Exit [default: 3]: 2
Enter your hardware wallet address >>> 0x123...abc
注意
您添加的钱包将成为该链上所有操作的默认钱包。您可以通过运行 gateway config ethereum 或 gateway config solana 查看当前设置的默认钱包。
gateway balance¶
查询已连接钱包的代币余额。
usage: gateway balance [-h] [chain] [tokens]
positional arguments:
chain Chain name (e.g., ethereum, solana)
tokens Comma-separated list of tokens to check (optional)
>>> gateway balance
Updating gateway balances, please wait...
Fetching balances for ethereum:base for tokens: all
Chain: ethereum
Network: base
Address: <ethereum-address>
Token Balance
ETH 0.0154
USDC 57.2579
WETH 0.0188
Fetching balances for solana:mainnet-beta for tokens: all
Chain: solana
Network: mainnet-beta
Address: <solana-address>
Token Balance
BONK 20508.7066
SOL 0.1413
USDC 27.9640
gateway config¶
查看和更新 Gateway 配置设置。
usage: gateway config [-h] [namespace] [action] [args ...]
positional arguments:
namespace Namespace (e.g., ethereum-mainnet, uniswap)
action Action to perform (update)
args Additional arguments: <path> <value> for direct update
查看配置¶
您可以查看任何 命名空间 的配置:
- chain: ethereum, solana 等
- network: ethereum-mainnet, solana-mainnet-beta 等
- connector: jupiter, uniswap 等
>>> gateway config solana-mainnet-beta
Gateway Configuration - namespace: solana-mainnet-beta:
nodeURL: https://dry-dawn-hill.solana-mainnet.quiknode.pro/41bbd7ad405c552f91cc928e044e5e04c66341d2
nativeCurrencySymbol: SOL
defaultComputeUnits: 200000
confirmRetryInterval: 0.5
confirmRetryCount: 10
basePriorityFeePct: 90
minPriorityFeePerCU: 0.1
更新配置¶
>>> gateway config solana-mainnet-beta update
Current configuration for solana-mainnet-beta:
nodeURL: https://api.mainnet-beta.solana.com
nativeCurrencySymbol: SOL
defaultComputeUnits: 200000
confirmRetryInterval: 0.5
confirmRetryCount: 10
basePriorityFeePct: 90
minPriorityFeePerCU: 0.1
Available configuration paths: nodeURL, nativeCurrencySymbol, defaultComputeUnits, confirmRetryInterval, confirmRetryCount, basePriorityFeePct, minPriorityFeePerCU
Enter configuration path (or 'exit' to cancel): nodeURL
Current value for 'nodeURL': https://api.mainnet-beta.solana.com v
Enter new value (or 'exit' to cancel):
网关将在任何配置更改后自动重启。
网关代币¶
在代币列表中查看或管理代币。
usage: gateway token [-h] [symbol_or_address] [action]
positional arguments:
symbol_or_address Token symbol or address
action Action to perform (update)
获取代币信息¶
>>> gateway token WETH
Searching for token 'WETH' across all chains' default networks...
Found tokens:
chain network symbol name address decimals
ethereum base WETH Wrapped Ether 0x4200000000000000000000000000000000000006 18
添加代币¶
>> gateway token HERMES update
Enter chain (e.g., ethereum, solana): solana
Token 'HERMES' not found. Let's add it to solana (mainnet-beta).
Enter token information:
Symbol [HERMES]:
Name: HermesWizard
Contract address: 24R8j15RDq3VoeRaSDFXMvSw4W7RLLZLdpTwK8ynx777
Decimals [18]: 9
Token to add/update:
{
"symbol": "HERMES",
"name": "HermesWizard",
"address": "24R8j15RDq3VoeRaSDFXMvSw4W7RLLZLdpTwK8ynx777",
"decimals": 9
}
Add/update this token? (Yes/No) >>> Yes
Adding/updating token...
✓ Token successfully added/updated!
Restarting Gateway for changes to take effect...
✓ Gateway restarted successfully
You can now use 'gateway token HERMES' to view the token information.
网关资金池¶
查看和管理流动性池信息。
usage: gateway pool [-h] [connector] [trading_pair] [action] [args ...]
positional arguments:
connector Connector name/type (e.g., uniswap/amm)
trading_pair Trading pair (e.g., ETH-USDC)
action Action to perform (update)
args Additional arguments: <address> for direct pool update
获取资金池信息¶
>>> gateway pool raydium/amm SOL-USDC
Fetching pool information for SOL-USDC on raydium/amm...
=== Pool Information ===
Connector: raydium/amm
Trading Pair: SOL-USDC
Pool Type: amm
Network: mainnet-beta
Base Token: SOL
Quote Token: USDC
Pool Address: 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
添加资金池¶
>>> gateway pool raydium/amm LIGHT-SOL update
=== Add Pool for LIGHT-SOL on raydium/amm ===
Chain: solana
Network: mainnet-beta
Pool 'LIGHT-SOL' not found. Let's add it to solana (mainnet-beta).
Enter pool information:
Pool contract address: 7YZEyZ3DuHQTmgmKwzuXMYG6SHD3sCWZ3mLkU7HuLrfC
Pool to add:
{
"address": "7YZEyZ3DuHQTmgmKwzuXMYG6SHD3sCWZ3mLkU7HuLrfC",
"baseSymbol": "LIGHT",
"quoteSymbol": "SOL",
"type": "amm"
}
Add this pool? (Yes/No) >>> Yes
Adding pool...
✓ Pool successfully added!
Restarting Gateway for changes to take effect...
✓ Gateway restarted successfully
Pool has been added. You can view it with: gateway pool raydium/amm LIGHT-SOL
网关兑换¶
通过 DEX 连接器执行代币兑换。
usage: gateway swap [-h] [connector] [args ...]
positional arguments:
connector Connector name/type (e.g., jupiter/router)
args Arguments: [base-quote] [side] [amount]. Interactive mode if not all provided. Example: gateway swap uniswap ETH-USDC BUY 0.1
options:
-h, --help show this help message and exit
>>> gateway swap jupiter/router
Enter base token (symbol or address): SOL
Enter quote token (symbol or address): USDC
Enter amount to trade: 0.01
Enter side (BUY/SELL): BUY
Fetching swap quote for SOL-USDC from jupiter/router...
=== Swap Transaction ===
Token In: SOL (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)
Token Out: USDC (So11111111111111111111111111111111111111112)
Price: 186.61700000000002 USDC/SOL
Slippage: 1%
Price Impact: 0.00%
You will spend:
Amount: 1.86617 USDC
Max Amount (w/ slippage): 1.8848317 USDC
You will receive:
Amount: 0.01 SOL
Estimating transaction fees for solana mainnet-beta...
=== Balance Impact After Swap ===
Wallet: 82SggY...yHx5
Token Current Balance → After Transaction
--------------------------------------------------
SOL 0.141273 → 0.151248
USDC 27.963970 → 26.097800
Transaction Fee Details:
Current Gas Price: 0.1000 lamports
Estimated Gas Cost: ~0.000025 SOL
Do you want to execute this swap? (y/n) >>>
Executing swap...
Order created: buy-SOL-USDC-1755721261102151
Monitoring transaction status...
✓ Transaction completed successfully!
Transaction hash: 5ToGDFBSALxAnY2nWjx1m1hNer9xp3bxg4dban1t5pefXHoaK41RiJJGxC7ZqLpy1nLx93DgZdtax8jqY3WzPwFa
网关流动性提供¶
在 AMM 和 CLMM 资金池上管理流动性头寸。
usage: gateway lp [-h] [connector] [{add-liquidity,remove-liquidity,position-info,collect-fees}]
positional arguments:
connector Connector name/type (e.g., raydium/amm)
{add-liquidity,remove-liquidity,position-info,collect-fees}
LP action to perform
列出头寸¶
>>> gateway lp raydium/amm position-info
=== Liquidity Positions on raydium/amm ===
Chain: solana
Network: mainnet-beta
Wallet: 82SggY...yHx5
Enter trading pair (e.g., SOL-USDC): SOL-USDC
Fetching positions for SOL-USDC...
=== AMM Position ===
Pool: 58oQCh...YQo2
Pair: SOL-USDC
Price: 186.849646 USDC/SOL
Holdings:
SOL: 0.009999
USDC: 1.868401
LP Tokens: 0.015601
添加流动性¶
>>> gateway lp raydium/amm add-liquidity
=== Add Liquidity to raydium/amm ===
Chain: solana
Network: mainnet-beta
Wallet: 82SggY...yHx5
Type: Standard AMM
Enter trading pair (e.g., SOL-USDC): SOL-USDC
Fetching pool information for SOL-USDC...
=== Pool Information ===
Pool Address: 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
Current Price: 186.803554
Fee: 0.0025%
Pool Reserves:
SOL: 46972.751032
USDC: 8774676.823955
TVL (in USDC): ~17549353.65
Enter token amounts to add (press Enter to skip):
Amount of SOL (optional): 0.01
Amount of USDC (optional): 2
Calculating optimal token amounts...
Note: Liquidity will be limited by base token amount
Token amounts to add:
SOL: 0.010000
USDC: 1.868497
Estimating transaction fees...
=== Balance Impact After Adding Liquidity ===
Wallet: 82SggY...yHx5
Token Current Balance → After Transaction
--------------------------------------------------
SOL 0.151259 → 0.141234
USDC 26.098180 → 24.229683
Transaction Fee Details:
Current Gas Price: 0.1000 lamports
Estimated Gas Cost: ~0.000025 SOL
Adding liquidity to pool at current price: 186.803554
Slippage tolerance: 1%
Do you want to add liquidity? (Yes/No) >>> Yes
Adding liquidity...
Transaction submitted. Order ID: range-SOL-USDC-1755722086328873
Monitoring transaction status...
✓ Transaction completed successfully!
Transaction hash: 5g3hDfWdSVpsXTdrqF1HqPKh9bH8bqpQ3XBoZXqHrCJKsCXQkGRhCc1YaBWYB3MNwcgEHRwyN5qyuP9dvNiexCUL
✓ Liquidity added successfully!
Use 'gateway lp raydium/amm position-info' to view your position
移除流动性¶
>>> gateway lp raydium/amm remove-liquidity
=== Remove Liquidity from raydium/amm ===
Chain: solana
Network: mainnet-beta
Wallet: 82SggY...yHx5
Enter trading pair (e.g., SOL-USDC): SOL-USDC
Fetching positions for SOL-USDC...
=== AMM Position ===
Pool: 58oQCh...YQo2
Pair: SOL-USDC
Price: 186.802435 USDC/SOL
Holdings:
SOL: 0.010001
USDC: 1.868167
LP Tokens: 0.015601
Selected position: 58oQCh...YQo2
Percentage to remove (0-100, default 100): 100
Removing 100.0% liquidity
You will receive:
SOL: 0.010001
USDC: 1.868167
Estimating transaction fees...
=== Balance Impact After Removing Liquidity ===
Wallet: 82SggY...yHx5
Token Current Balance → After Transaction
--------------------------------------------------
SOL 0.141214 → 0.151189
USDC 24.229877 → 26.098044
Transaction Fee Details:
Current Gas Price: 0.1000 lamports
Estimated Gas Cost: ~0.000025 SOL
Do you want to remove 100.0% liquidity? (Yes/No) >>> Yes
Removing liquidity...
Transaction submitted. Order ID: range-SOL-USDC-1755722234730374
Monitoring transaction status...
✓ Transaction completed successfully!
✓ 100.0% liquidity removed successfully!
收取费用¶
>>> gateway lp raydium/clmm collect-fees
=== Collect Fees from raydium/clmm ===
Chain: solana
Network: mainnet-beta
Wallet: 82SggY...yHx5
Enter trading pair (e.g., SOL-USDC): SOL-USDC
Fetching positions for SOL-USDC...
网关授权¶
批准 ERC-20 代币用于 DEX 连接器(仅限以太坊)。
usage: gateway approve [-h] [connector] [token]
positional arguments:
connector Connector name/type (e.g., jupiter/router)
token Token symbol to approve (e.g., WETH)
>>> gateway approve uniswap/amm CBBTC
Fetching uniswap/amm allowance for CBBTC...
=== Approve Transaction ===
Connector: uniswap/amm
Network: ethereum base
Wallet: 0xDA50...6684
Token to approve:
Symbol: CBBTC
Address: Unknown
Current Allowance: 0
Estimating transaction fees for ethereum base...
=== Balance Impact After Approval ===
Wallet: 0xDA50...6684
Token Current Balance → After Transaction
--------------------------------------------------
CBBTC 0.000000
ETH 0.015378 → 0.015348
Transaction Fee Details:
Current Gas Price: 0.1000 gwei
Estimated Gas Cost: ~0.000030 ETH
Do you want to proceed with the approval? (Yes/No) >>> Yes
Approving CBBTC for uniswap/amm...
Submitting approval for CBBTC...
Approval submitted for CBBTC. Order ID: approve-cbbtc-1755722519391857
Monitoring transaction status...
⚠ Transaction completed with state: OrderState.PENDING_APPROVAL
网关额度¶
检查 DEX 连接器的代币授权额度(仅限以太坊)。
usage: gateway allowance [-h] [connector]
positional arguments:
connector Ethereum connector name/type (e.g., uniswap/amm)
>>> gateway allowance uniswap/amm
Checking token allowances, please wait...
Connector: uniswap/amm
Chain: ethereum
Network: base
Wallet: 0xDA50C69342216b538Daf06FfECDa7363E0B96684
Symbol Address Allowance
AAVE 0x6370...814b Unlimited
CBBTC 0xcbB7...33Bf 0
DAI 0x50c5...B0Cb Unlimited
LINK 0x88fb...e196 Unlimited
USDC 0x8335...2913 Unlimited
USDT 0xfde4...9bb2 0
VIRTUAL 0x0b3e...7e1b Unlimited
WETH 0x4200...0006 Unlimited
网关生成证书¶
为安全的网关通信生成 SSL 证书。
>>> gateway generate-certs
Enter pass phrase to generate Gateway SSL certifications >>> *****
Gateway SSL certification files are created in /Users/feng/hummingbot/certs.
之后,从网关根目录运行 pnpm run setup 以将这些证书复制到网关。