配置
Gateway 使用模块化配置系统,允许您自定义其运行的各个方面。本指南介绍配置结构以及如何根据需要修改配置。
配置概述¶
Gateway 的配置系统由位于 /conf 目录中的 YAML 文件组成,以及按链和连接器组织的代币和交易对的 JSON 文件。
在安装过程中运行设置脚本时,初始配置文件会自动使用 /src/templates 中的默认模板创建。
配置结构¶
/conf/ 文件夹包含以下类型的配置文件:
- 根配置(root.yml):定义所有配置文件及其模式的列表
- 服务器配置(server.yml):控制 Gateway 服务器行为
- 链配置(例如:solana.yml):定义区块链网络设置
- 连接器配置(例如:raydium.yml):配置特定去中心化交易所(DEX)的设置
- 代币列表(/conf/tokens/{chain}/{network}.json):每个网络的代币定义
- 资金池列表(/conf/pools/{connector}.json):为每个 DEX 连接器定义的流动性池
根配置¶
root.yml 文件是网关配置系统的入口点。它定义了要加载哪些配置文件以及对应的模式文件。
version: 3
configurations:
  $namespace server:
    configurationPath: server.yml
    schemaPath: server-schema.json
  $namespace solana:
    configurationPath: solana.yml
    schemaPath: solana-schema.json
  $namespace jupiter:
    configurationPath: jupiter.yml
    schemaPath: jupiter-schema.json
该文件告诉网关:
- 要加载哪些配置文件
- 在哪里找到用于验证每个配置的模式文件,这些文件位于 /src/services/schemas目录中
- 如何为每个配置部分设置命名空间
服务器配置¶
server.yml 文件控制网关核心服务器行为,包括端口、日志和安全设置。
# GMT Offset in hours (e.g. -8 for Pacific US Time, -5 for Eastern US Time)
GMTOffset: -8
# Port on which to run the Gateway server
port: 15888
# Port on which to run the Swagger documentation UI. 
# Set to 0 to serve docs at http://0.0.0.0:{port}/docs (same port as Gateway server)
# Set to a specific port (e.g. 8080) to serve docs separately at http://0.0.0.0:{docPort}
docsPort: 0
# Path to folder where Hummingbot generates self-signed certificates
certificatePath: ./certs/
# Path to folder where logs will be stored.
logPath: './logs'
# IPs allowed to access gateway. localhost is allowed by default.
ipWhitelist: []
# If true, logs will be stored in logPath and printed to stdout. If false, they
# will only be stored in logPath and not printed to stdout.
logToStdOut: true
# If true, the server will print detailed Fastify logs for each request and response to stdout. If false, only standard logs will be emitted.
fastifyLogs: false
# Nonce database
nonceDbPath: 'nonce.level'
# Transaction database
transactionDbPath: 'transaction.level'
链配置¶
链配置文件(例如 /conf/chains/solana.yml)现在仅包含每条区块链的默认网络和钱包设置。
当你使用 gateway connect 连接钱包时,它会自动成为该链的 defaultWallet。defaultNetwork 决定了网关默认使用哪个网络配置来连接该链。
注意
特定网络的配置现在存储在 /conf/chains/{chain}/{network}.yml 下的独立文件中
连接器配置¶
连接器配置文件(例如 /conf/connectors/jupiter.yml)定义了每个 DEX 连接器的特定设置,包括滑点容忍度、路由偏好和 API 配置。
示例:Jupiter 配置¶
# Default slippage percentage for swaps (as a decimal, e.g., 1 = 1%)
slippagePct: 1
# Priority level for swap transaction processing
# Options: medium, high, veryHigh
priorityLevel: 'veryHigh'
# Maximum priority fee in lamports (for dynamic priority fees)
# Used when priorityLevel is set and no explicit priorityFeeLamports is provided
maxLamports: 1000000
# Restrict routing to only go through 1 market
# Default: false (allows multi-hop routes for better prices)
onlyDirectRoutes: false
# Restrict routing through highly liquid intermediate tokens only
# Default: true (for better price and stability)
restrictIntermediateTokens: true
# Jupiter API key (optional)
# For free tier, leave empty (uses https://lite-api.jup.ag)
# For paid plans, generate key at https://portal.jup.ag (uses https://api.jup.ag)
apiKey: ''
配置选项说明:
- 
slippagePct:交易可接受的最大价格滑点。如果执行价格偏离报价超过此百分比,交易将失败。
- 
priorityLevel:控制 Solana 上的交易优先级。更高的优先级可加快确认速度,但费用更高。对于时间敏感的交易,请设置为veryHigh。
- 
maxLamports:限制最高优先费,防止在网络拥堵期间产生过高成本。1,000,000 lamports = 0.001 SOL。
- 
onlyDirectRoutes:当设为true时,仅允许直接资金池交易(不经过中间代币)。这可以减少价格影响,但对于流动性较低的交易对可能导致报价更差或路径失败。
- 
restrictIntermediateTokens:当设为true时,仅允许通过主要代币(SOL、USDC、USDT)作为中间代币进行交易。这提高了可靠性并降低了价格波动风险。
- 
apiKey:Jupiter 付费层级的可选 API 密钥。免费层级(lite-api)适用于大多数用户,而付费层级提供更高的速率限制和额外功能。
网络配置¶
网络配置文件(例如 /conf/chains/solana/mainnet-beta.yml)包含每条区块链网络的详细设置,包括 RPC 端点和交易参数。
示例:Solana mainnet-beta 配置¶
nodeURL: https://api.mainnet-beta.solana.com
nativeCurrencySymbol: SOL
# Default compute units for a transaction
# This sets the compute unit limit for transactions when not specified by the user
defaultComputeUnits: 200000
# Confirmation polling interval in seconds
# How often to check if a submitted transaction has been confirmed (inner retry loop)
confirmRetryInterval: 0.5
# Number of confirmation polling attempts
# How many times to poll for confirmation before considering the transaction unconfirmed
confirmRetryCount: 10
# Floor percentile of recent priority fee samples used to estimate gasPrice for a transaction
# Use the Nth percentile of recent priority fees as the base fee (90 = 90th percentile)
basePriorityFeePct: 90
# Minimum priority fee per compute unit in lamports
# This sets the floor for priority fees to ensure transactions are processed (default: 0.1 lamports/CU)
minPriorityFeePerCU: 0.1
你可以使用网关命令查看任何网络的当前配置:
>>> 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 [namespace] update:
>>> gateway config solana-mainnet-beta update
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
Enter new value (or 'exit' to cancel): https://your-preferred-node-provider.com/your-api-key
通用配置任务¶
更换节点提供商¶
要更改区块链网络的 RPC 节点提供商,您可以使用 Gateway 命令,或直接编辑配置文件。
使用 Gateway 命令¶
>>> 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
Enter new value (or 'exit' to cancel): https://your-preferred-node-provider.com/your-api-key
Successfully updated nodeURL
Gateway will restart automatically for changes to take effect
编辑配置文件¶
- 进入网络配置文件夹(例如:/conf/chains/solana/)
- 打开特定网络文件(例如:mainnet-beta.yml)
- 找到 nodeURL字段,并将其替换为您首选节点提供商的 URL
- 保存文件并重启 Gateway
Solana 主网示例(/conf/chains/solana/mainnet-beta.yml):
nodeURL: https://your-preferred-node-provider.com/your-api-key
nativeCurrencySymbol: SOL
# Default compute units for a transaction
# This sets the compute unit limit for transactions when not specified by the user
defaultComputeUnits: 200000
# Confirmation polling interval in seconds
# How often to check if a submitted transaction has been confirmed (inner retry loop)
confirmRetryInterval: 0.5
# Number of confirmation polling attempts
# How many times to poll for confirmation before considering the transaction unconfirmed
confirmRetryCount: 10
# Floor percentile of recent priority fee samples used to estimate gasPrice for a transaction
# Use the Nth percentile of recent priority fees as the base fee (90 = 90th percentile)
basePriorityFeePct: 90
# Minimum priority fee per compute unit in lamports
# This sets the floor for priority fees to ensure transactions are processed (default: 0.1 lamports/CU)
minPriorityFeePerCU: 0.1
以太坊主网示例(/conf/chains/ethereum/mainnet.yml):
chainID: 1
nodeURL: https://your-preferred-node-provider.com/your-api-key
nativeCurrencySymbol: ETH
minGasPrice: 0.1
添加代币¶
提示
新的 Gateway 端点除了支持符号外,还接受baseToken和quoteToken的地址,因此您可以在将代币符号添加到网络代币列表之前直接使用地址。
Gateway 使用按链和网络组织的标准代币列表。每个网络都有自己的代币列表文件,其中包含该网络上所有支持代币的元数据。
使用 Gateway 命令¶
>>  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.
编辑代币文件¶
- 进入 /conf/tokens/{chain}/文件夹(例如:/conf/tokens/solana/)
- 打开相应的网络文件(例如,Solana 主网的mainnet-beta.json)
- 按照下方现有格式在数组中添加新的代币条目
- 确保最终文件仍然是有效的 JSON!
- 保存文件并重启 Gateway
{
  "chainId": 101,
  "name": "ai16z",
  "symbol": "AI16Z",
  "address": "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC",
  "decimals": 9
}
代币列表结构遵循代币列表标准,有助于用户避免诈骗并在不同网络间查找合法代币。
添加交易池¶
每个 AMM 和 CLMM 去中心化交易所(DEX)可能对同一交易对提供具有不同参数(如手续费等级和区间步长)的多个交易池。Gateway 现在将每个 DEX 连接器的交易池定义存储在独立的 JSON 文件中。
使用 Gateway 命令¶
>>>  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
编辑交易池文件¶
- 进入 /conf/pools/文件夹
- 打开连接器的交易池文件(例如:raydium.json)
- 按照现有格式在数组中添加新的交易池条目
- 确保最终文件仍然是有效的 JSON!
- 保存文件并重启 Gateway
交易池条目示例:
{
  "type": "amm",
  "network": "mainnet-beta",
  "baseSymbol": "WIF",
  "quoteSymbol": "SOL",
  "address": "EP2ib6dYdEeqD8MfE2ezHCxX3kP3K2eLKkirfPm5eyMx"
}
对于 CLMM 交易池,请改用"type": "clmm"。该交易池文件结构允许您在同一连接器内为不同网络和交易类型(AMM 与 CLMM)指定不同的交易池。
更新配置¶
有两种方式可以更新您的 Gateway 配置:
- 手动更新:
- 直接编辑配置文件
- 
重启网关以应用更改 
- 
API 更新: 
- 使用 /config/updateAPI 端点来更新配置
- 这允许动态更新,而无需重启网关
提示
在将配置更改应用到生产环境之前,请务必验证其正确性。你可以使用 root.yml 中引用的模式文件来确保配置的有效性。
