Hummingbot Gateway is a REST API that provides a unified interface for interacting with blockchain networks (wallet, node & chain operations) and decentralized exchanges (DEX) (trading, liquidity provision, and market data).
Gateway abstracts the complexity of interacting with different blockchain protocols by providing standardized endpoints that work consistently across different chains and DEXs. Built with TypeScript to leverage native blockchain SDKs, it offers a language-agnostic API that can be integrated into any trading system.
- Multi-Chain Support: Ethereum (and EVM-compatible chains) and Solana
- DEX Integration: Jupiter, Uniswap, Raydium, and Meteora
- Trading Types: Simple swaps, AMM (V2-style), and CLMM (V3-style concentrated liquidity)
- Wallet Management: Secure wallet storage and transaction signing
- Swagger Documentation: Auto-generated interactive API docs at
/docs
- TypeBox Validation: Type-safe request/response schemas
- Ethereum Mainnet
- Arbitrum
- Avalanche
- Base
- BSC (Binance Smart Chain)
- Celo
- Optimism
- Polygon
- World Chain
- Sepolia (testnet)
- Solana Mainnet
- Solana Devnet
Protocol | Chain | Swap | AMM | CLMM |
---|---|---|---|---|
Jupiter | Solana | ✅ | ❌ | ❌ |
Meteora | Solana | ✅ | ❌ | ✅ |
Raydium | Solana | ✅ | ✅ | ✅ |
Uniswap | Ethereum/EVM | ✅ | ✅ | ✅ |
Gateway uses Swagger for API documentation. When running in development mode, access the interactive API documentation at: http://localhost:15888/docs
We recommend downloading the graphical installer from the NodeJS official site.
For terminal-based users, follow the steps below to install from a Linux-based machine (Ubunbu 20+)
# Ensure your package list is up to date and install curl
sudo apt update && sudo apt install -y curl
# Add Node 20.x repository
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# Install the default versions from Ubuntu’s repository:
sudo apt install -y nodejs
# Check Node.js version:
nodejs --version
pnpm
is a faster and more space-efficient package manager than npm
.
# Install PNPM globally
sudo npm install -g pnpm
# Check pnpm version
pnpm --version
# Clone Github repo
git clone https://github.com/hummingbot/gateway.git
# Go to newly created folder
cd gateway
# Switch to main branch (or a specific version branch like core-2.6)
git checkout main
# Install JS libraries
pnpm install
# Complile Typescript into JS
pnpm build
# Run Gateway setup script, which helps you set configs and CERTS_PATH
pnpm run setup
You can run Gateway in the Gateway server in unencrypted HTTP mode using the --dev
flag. Note that a passphrase is still needed to encrypt and decrypt wallets used in executing transactions.
pnpm start --passphrase=<PASSPHRASE> --dev
To start the Gateway server in HTTPS mode, run the command without the --dev
flag. Make sure to use the same passphrase that you used to generate certs in the Hummingbot client.
pnpm start --passphrase=<PASSPHRASE>
Build the Gateway Docker image locally by executing the below command. You may replace development
with a tag of your choice.
docker build \
--build-arg BRANCH=$(git rev-parse --abbrev-ref HEAD) \
--build-arg COMMIT=$(git rev-parse HEAD) \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%d") \
-t hummingbot/gateway:development -f Dockerfile .
Start a container in HTTPS mode using this development
Docker image. Make sure to replace <PASSPHRASE>
with the passphrase you used to generate the certs in the Hummingbot client.
docker run --name gateway \
-p 15888:15888 \
-v "$(pwd)/conf:/home/gateway/conf" \
-v "$(pwd)/logs:/home/gateway/logs" \
-v "$(pwd)/db:/home/gateway/db" \
-v "$(pwd)/certs:/home/gateway/certs" \
-e GATEWAY_PASSPHRASE=<PASSPHRASE> \
hummingbot/gateway:development
Afterwards, clients with valid certificates can connect to Gateway at: https://localhost:15888
You may also start the container in HTTP mode by setting the DEV
environment variable to true
. Note that this will disable HTTPS and allow unauthenticated access to Gateway and its endpoints.
docker run --name gateway \
-p 15888:15888 \
-v "$(pwd)/conf:/home/gateway/conf" \
-v "$(pwd)/logs:/home/gateway/logs" \
-v "$(pwd)/db:/home/gateway/db" \
-v "$(pwd)/certs:/home/gateway/certs" \
-e DEV=true \
hummingbot/gateway:development
Afterwards, client may connect to Gateway at: http://localhost:15888 and you can access the Swagger documentation UI at: http://localhost:15888/docs
GET /
- Health checkGET /chains
- List supported blockchainsGET /connectors
- List supported DEX connectors
GET /config
- Get configurationPOST /config/update
- Update configuration
GET /wallet
- List all walletsPOST /wallet/add
- Add new walletDELETE /wallet/remove
- Remove walletPOST /wallet/sign
- Sign message
GET /status
- Chain connection statusGET /tokens
- Get token informationGET /balances
- Get wallet balancesGET /allowances
- Check token allowancesPOST /approve
- Approve token spendingGET /poll
- Poll transaction status
GET /status
- Chain connection statusGET /tokens
- Get token informationGET /balances
- Get wallet balancesGET /poll
- Poll transaction status
GET /connectors/{dex}/quote-swap
- Get swap quotePOST /connectors/{dex}/execute-swap
- Execute swap
GET /connectors/{dex}/amm/pool-info
- Pool informationGET /connectors/{dex}/amm/position-info
- LP position detailsPOST /connectors/{dex}/amm/add-liquidity
- Add liquidityPOST /connectors/{dex}/amm/remove-liquidity
- Remove liquidity
GET /connectors/{dex}/clmm/pool-info
- Pool informationGET /connectors/{dex}/clmm/positions-owned
- List positionsPOST /connectors/{dex}/clmm/open-position
- Open positionPOST /connectors/{dex}/clmm/add-liquidity
- Add to positionPOST /connectors/{dex}/clmm/remove-liquidity
- Remove from positionPOST /connectors/{dex}/clmm/collect-fees
- Collect fees
Gateway is part of the open source Hummingbot project, which is powered by community contributions. Please see the Contributing guide in the Hummingbot docs for more information.
Here are some ways that you can contribute to Gateway:
- File an issue at hummingbot issues
- Make a pull request
- Edit the docs
- Vote in quarterly polls to decide which DEXs Gateway should support
-
To run in HTTP mode (for development), use
pnpm start --dev
. By default, Gateway runs in secure HTTPS mode. -
If you want Gateway to log to standard out, set
logToStdOut
totrue
in conf/server.yml. -
The format of configuration files are dictated by src/services/config-manager-v2.ts and the corresponding schema files in src/templates/json.
-
For each supported chain, token lists that translate address to symbols for each chain are stored in
/conf/lists
. You can add tokens here to make them available to Gateway.
Gateway follows a modular architecture with clear separation between chains, connectors, and core services:
src/
├── chains/ # Blockchain implementations
│ ├── ethereum/ # Ethereum and EVM chains
│ │ ├── ethereum.ts # Core chain class
│ │ ├── routes/ # Individual route handlers
│ │ └── ethereum.routes.ts
│ └── solana/ # Solana chain
│ ├── solana.ts
│ ├── routes/
│ └── solana.routes.ts
├── connectors/ # DEX implementations
│ ├── jupiter/ # Jupiter aggregator (Solana)
│ ├── meteora/ # Meteora CLMM (Solana)
│ ├── raydium/ # Raydium AMM/CLMM (Solana)
│ └── uniswap/ # Uniswap V2/V3 (Ethereum)
├── schemas/ # TypeBox schemas
│ ├── trading-types/ # AMM, CLMM, Swap schemas
│ └── json/ # JSON schemas
├── services/ # Core services
├── wallet/ # Wallet management
└── config/ # Configuration management
- Singleton Pattern: Chains and connectors use singleton instances per network
- Route Organization: Each module has a dedicated routes folder with operation-specific files
- Schema Validation: All API requests/responses validated with TypeBox schemas
- Error Handling: Consistent error responses using Fastify's httpErrors
Handle blockchain interactions including:
- Wallet balance queries
- Token information and lists
- Transaction submission and monitoring
- Gas estimation
- Token approvals (EVM only)
Implement DEX-specific logic for:
- Price quotes and routing
- Swap execution
- Liquidity pool operations
- Position management (CLMM)
- Fee collection
Provide shared functionality:
- Configuration management with YAML/JSON schemas
- Structured logging with Winston
- Database operations with LevelDB
- API server setup with Fastify
For a pull request merged into the codebase, it has to pass unit test coverage requirements. Take a look at Workflow for more details.
Run all unit tests.
pnpm test
Run an individual test folder or file
GATEWAY_TEST_MODE=dev jest --runInBand test/<folder>/<file>.test.ts
The test directory is organized as follows:
/test
/chains/ # Chain endpoint tests
chain.test.js # Chain routes test
ethereum.test.js # Ethereum chain tests
solana.test.js # Solana chain tests
/connectors/ # Connector endpoint tests by protocol
/jupiter/ # Jupiter connector tests
/uniswap/ # Uniswap connector tests
/raydium/ # Raydium connector tests
/meteora/ # Meteora connector tests
/mocks/ # Mock response data
/chains/ # Chain mock responses
chains.json # Chain routes mock response
/ethereum/ # Ethereum mock responses
/solana/ # Solana mock responses
/connectors/ # Connector mock responses
/services/ # Service tests
/data/ # Test data files
/wallet/ # Wallet tests
/config/ # Configuration tests
/jest-setup.js # Test environment configuration
For more details on the test setup and structure, see Test README.
-
Create chain implementation:
// src/chains/mychain/mychain.ts export class MyChain extends ChainBase { private static instances: Record<string, MyChain> = {}; public static getInstance(network: string): MyChain { if (!MyChain.instances[network]) { MyChain.instances[network] = new MyChain(network); } return MyChain.instances[network]; } }
-
Implement required methods:
getWallet(address: string)
getBalance(address: string)
getTokens(tokenSymbols: string[])
getStatus()
-
Create route handlers in
src/chains/mychain/routes/
-
Add configuration:
- Create
src/templates/mychain.yml
- Add JSON schema in
src/templates/json/mychain-schema.json
- Create
-
Register the chain in
src/chains/chain.routes.ts
-
Choose the appropriate base class:
- For AMM: Extend from AMM base functionality
- For CLMM: Implement CLMM interface
- For simple swaps: Implement basic swap methods
-
Create connector class:
// src/connectors/mydex/mydex.ts export class MyDex { private static instances: Record<string, MyDex> = {}; public static getInstance(chain: string, network: string): MyDex { const key = `${chain}:${network}`; if (!MyDex.instances[key]) { MyDex.instances[key] = new MyDex(chain, network); } return MyDex.instances[key]; } }
-
Implement trading methods based on supported operations
-
Create route files following the pattern:
- Swap routes in
routes/
- AMM routes in
amm-routes/
- CLMM routes in
clmm-routes/
- Swap routes in
-
Add configuration and register in
src/connectors/connector.routes.ts
- Minimum 75% code coverage for new features
- Create mock responses in
test/mocks/
- Write unit tests for all route handlers
- Test error cases and edge conditions
This repo uses eslint
and prettier
for code quality and consistent formatting.
Run linting manually with:
pnpm lint
Format code with prettier:
pnpm format
If you see warnings like bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
when running Gateway, you can safely ignore them. The warnings are related to the bigint-buffer package, which falls back to pure JavaScript implementation when native bindings are not available. This doesn't affect Gateway's functionality.
If you want to attempt to fix these warnings, you can run:
pnpm rebuild-bigint
Note that this requires having the necessary C++ build tools installed on your system.