Hummingbot Gateway is a REST API that exposes connections to various blockchains (wallet, node & chain interaction) and decentralized exchanges (pricing, trading & liquidity provision). It is written in Typescript and takes advantage of existing blockchain and DEX SDKs. The advantage of using gateway is it provideds a programming language agnostic approach to interacting with blockchains and DEXs.
Gateway may be used alongside the main Hummingbot client to enable trading on DEXs, or as a standalone module by external developers.
To run Gateway in https
(default):
- certs_path: path to folder where Hummingbot generated and saved self-signed SSL certificates
- passphrase: passphrase used to generate the certificates above
Dependencies:
- NodeJS (16.0.0 or higher)
- Yarn: run
npm install -g yarn
after installing NodeJS
# Install dependencies
yarn
# Complile Typescript into JS
$ yarn build
# Generate the config files and edit as needed, especially server.yml
$ setup/generate_conf.sh
# Replace certificatePath with certs_path from step 1
(base) ➜ vi conf/server.yml
# Start the server using the passphrase you used to generate the certs in Hummingbot
$ yarn start --passphrase=<passphrase>
Dependencies:
See the /docker
folder for Docker installation scripts and instructions on how to use them.
See the official Gateway docs.
The API is documented using Swagger. When Gateway is started, it also generates Swagger API docs at: https://localhost:8080
There are a number of ways to contribute to gateway.
-
File an issue at hummingbot issues
-
Make a pull request
-
Edit the docs
-
Vote on a Snapshot proposal
-
Edit
certs_path
in conf/server.yml and enter the absolute path to the folder where Hummingbot stored the certificates it created withgateway generate-certs
. You can also edit this config inside the Hummingbot client by running the command:gateway config server.certs_path
. -
If you want to turn off
https
, setunsafeDevModeWithHTTP
totrue
in conf/server.yml. -
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/services/schema.
Here are some files we recommend you look at in order to get familiar with the Gateway codebase:
-
src/services/ethereum-base.ts: base class for EVM chains.
-
src/connectors/uniswap/uniswap.ts: functionality for interacting with Uniswap.
-
src/services/validator.ts: defines functions for validating request payloads.
For a pull request merged into the codebase, it has to pass unit test coverage requirements. Take a look at Workflow for more details.
Read this document for more details about how to write unit test in gateway: How we write unit tests for gateway.
Run all unit tests.
yarn test:unit
Run an individual test folder or file
yarn jest test/<folder>/<file>
We have found it is useful to test individual endpoints with curl
commands. We have a collection of prepared curl calls. POST bodies are stored in JSON files. Take a look at the curl calls for gateway. Note that some environment variables are expected.
This repo uses eslint
and prettier
. When you run git commit
it will trigger the pre-commit
hook. This will run eslint
on the src
and test
directories.
You can lint before committing with:
yarn run lint
You can run the prettifier before committing with:
yarn run prettier