Hummingbot Gateway

What is Hummingbot Gateway?

Hummingbot Gateway is a API server that allows Hummingbot to connect to protocols that are used in the amm-arb strategy and other future strategies. This is a light web server that enables Hummingbot client to send and receive data from different blockchain protocols and provides an easier entry point for external devs to build connectors to other protocols.

Note

To use Gateway, you need to install Hummingbot using Docker or from source.

Create SSL certificates

  1. Run the command gateway generate_certs in the Hummingbot client
  2. Enter a passphrase to be used later during installation

Note

As this passphrase will be stored in unencrypted form in the Gateway environment, we recommend that you use a different password as the Hummingbot password, which is used to encrypt your API and private keys.

Install Gateway via Docker

  1. Take note of the absolute path where your Hummingbot files are stored. You can run the command pwd from the terminal while inside the folder.
  2. Copy and paste the following commands to your terminal:

Mac

1
2
3
4
curl https://raw.githubusercontent.com/CoinAlpha/hummingbot/development/installation/docker-commands/create-gateway.sh -o create-gateway.sh
curl https://raw.githubusercontent.com/CoinAlpha/hummingbot/development/installation/docker-commands/update-gateway.sh -o update-gateway.sh
chmod a+x *.sh
./create-gateway.sh

Linux

1
2
3
4
wget https://raw.githubusercontent.com/CoinAlpha/hummingbot/development/installation/docker-commands/create-gateway.sh
wget https://raw.githubusercontent.com/CoinAlpha/hummingbot/development/installation/docker-commands/update-gateway.sh
chmod a+x *.sh
./create-gateway.sh

It downloads the scripts from GitHub, sets their correct permission and runs the create-gateway script.

  1. Answer each prompt, review the summary and enter Y to proceed with the installation.

Note

When creating a Gateway instance for Ethereum protocol connectors such as Balancer, Uniswap, and Perpetual Finance the script picks up the settings from your global config file (conf_global.yml). Make sure to connect them first from the Hummingbot client before installing Gateway.

By default, Gateway will install on port 5000 which Hummingbot will connect to. If the default port is not available, Gateway will find the next port number.

  1. The file global_conf.yml is created where your Gateway settings are saved.

Configure port number (optional)

In case the port number used by Gateway is not set to the default value of 5000, make sure to set the gateway_api_port in the Hummingbot client to match the same port number.

  1. Run command config gateway_api_port in the Hummingbot client
  2. Enter the port number indicated when Gateway was created

ETH Gas Station

Note

As of version 0.38.0, ethgasstation_gas_enabled has been removed from the hummingbot client and added to the parameters when setting up gateway.

Users have the option to use and configure DeFI Pulse gas price as the gas estimator.

  1. Sign up for a free account on DeFi Pulse Data
  2. Get your API key - once you log into DeFi Pulse Data, your API key can be found on the right side of the Dashboard. Click the copy button to copy your API Key.

When setting up your Hummingbot gateway, you will be ask if you want to enable ETH Gas price. If yes,

  1. You would need to enter the DeFI pulse API key
  2. Enter gas level you want to use for ETH transactions
  3. Refresh time for ETH gas price look up

If you choose not to enable ETH gas price, you would only need to set up the fixed gas price to use for ETH transactions.

Update Gateway via Docker

To update the docker container, run the update-gateway.sh script and and follow the prompt instructions. The update script allows you to stop and delete the running instance, and update the docker image if it is not the latest. Upon completion, it will automatically execute the create-gateway.sh script to create a new Gateway container instance.

Install Gateway from source

Prerequisites

Installation applies to Windows, Linux or macOS

  1. NodeJS - visit this page to download and install.

  2. Tested versions v12.13.0, v12.13.1.

1
2
# to check your current version
node -v

Tip

You can install nvm to manage and use different node versions on the same system.

  1. Yarn (required for node package installations)
1
2
# to install yarn globally
npm -g install yarn
  • Tested versions v1.22.5 and v1.22.10

Setup

Steps for setting up gateway-api

1
2
# clone the repo
git clone https://github.com/CoinAlpha/gateway-api
1
2
# open directory
cd gateway-api
1
2
3
4
# install npm packages
# build packages
yarn
yarn build

1
2
# copy sample environment
cp global_conf.yml.example global_conf.yml

  • Edit global_conf.yml file with your favorite text editor then save changes.
  • There are 2 ways to start the gateway
1
2
# run debug mode with additional route debug logging
yarn debug
1
2
# run prod mode
yarn start

Setting up Kovan testnet

This guide will help you setup gateway-api instance for Kovan testnet. This will help you run some test to AMM_Arbitrage strategy without risking your funds.

You must have set your ETH wallet to Kovan test network, for metamask you can click the Ethereum Mainnet and select Kovan Test Network. To get test assets, you can go to https://gitter.im/kovan-testnet/faucet and login your github account. Provide your ETH wallet address.

Tip

Assets sent to your ETH wallet from kovan-testnet are not real (mainnet) ETH, has no market value, and is only useful for testing.

When connecting your Hummingbot to ethereum, you need to change to kovan instead of mainnet for your ethreum chain, websocket and node. See example below,

For more information about ERC20 Kovan token lists click here.

File location gateway-api/src/assets/ecr20_tokens_kovan.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  {
  "name": "kovan",
  "tokens": [
    {
      "symbol": "COIN1",
      "address": "0x809F5A762e7b0CC75C42cd76098b85CB7BD2BA64",
      "decimals": 18,
      "chainId": 42
    },
    {
      "symbol": "COIN2",
      "address": "0x9866c4043bc6cf47eaf845c56f6ab221c204e0df",
      "decimals": 8,
      "chainId": 42
    },
    {
      "symbol": "COIN3",
      "address": "0x3D2097889B97A9eF23B3eA8FC10c626fbda29099",
      "decimals": 18,
      "chainId": 42
    }
  ]
}

Relaunch your Hummingbot client and setup an AMM_Arbitrage strategy.