/
Launch Hummingbot Miner

AMM Arbitrage

Learn how to use AMM arbitrage strategy


Updated as of v0.33

Before you can use the AMM arbitrage strategy in Hummingbot, you need to install and configure the Gateway API server. The following flowchart shows the typical installaton and configuration process for Balancer.

Balancer flowchart

Prerequisites

You need to setup an Ethererum wallet and nodes(Infura), Defipulse API keys for gas estimation, and install Hummingbot via Docker.

Note: You can manually set the gas limit but we recommend to use Defipulse API keys for providing the efficent rate of gas estimation.

Setup Ethereum wallet and nodes

Ensure you have setup the Ethereum wallet and nodes, for more details:

(Optional) Create Defipulse API key

  1. Create a free account on defipulse.
  2. After you verify your account, take note of the API Key to be use later for Gateway settings in Hummingbot.

defipulse

Install Hummingbot via Docker

Refer to the following individual OS for details:

Before you start using Hummingbot, see the following links to have an understanding on how Hummingbot works:

Installation and Configuration

The following sections describes the installation and configuration process for Gateway.

Create SSL Cert in Hummingbot

  1. Start Hummingbot.

  2. Enter generate_certs to create the SSL cert. The following prompt is displayed.

     >>>  generate_certs
     -----------------------------------------------------------
     Enter passphrase to generate Gateway SSL certification >>>
  3. Enter a passphrase.

Note: It is recommended not to use the same password as the Hummingbot instance. Take note of the passphrase and cert path to be use later for Gateway Docker settings.

Tip: To get the cert path, run pwd from the certs directory where Hummingbot is installed.

Install Gateway Docker

  1. Run the following command:
# 1) Download Hummingbot Gateway install

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

# 2) Enable script permissions

chmod a+x create-gateway.sh

# 3) Create a gateway instance

./create-gateway.sh
  1. After Gateway has been installed, the CREATE A NEW GATEWAY INSTANCE prompt is displayed. Follow the onscreen instructions to enter the required values.

    Note: Ensure you have cert passphrase, cert path, and Ethereum RPC URL before proceeding. Else, see Prerequisites for more details The following screenshot displays an example of the completed information.

Gateway 3. The Gateway configuration summary is displayed. Review the information and enter yes to complete the Gateway configuration. Gateway

Note: By default, Gateway will install on port 5000 which Hummingbot will connect to. If the port `5000 is not available, Gateway will find the next port number. Take note of the Gateway port number to be use later in the Gateway settings in Hummingbot.

If your Gateway instance is installed on 5000, Hummingbot should be able to connect to it. Otherwise, you need to set the correct port through the configuration.

(Optional) Configure Gateway settings in Hummingbot

There are two optional settings that you can set for the Gateway:

(Optional Settings 1) Port Number

If your port number is not 5000, you can set the correct port in Hummingbot.

  1. Access Hummingbot.
  2. Enter config gateway_api_port to create the SSL cert. The following prompt is displayed.
>>>  config gateway_api_port
Please follow the prompt to complete configurations:
-----------------------------------------------------------
Please enter your Gateway API port >>>
  1. Enter the port number.

(Optional Settings 2) Using Defipulse

If you want to use and configure defipulse as the gas estimator

  1. Access Hummingbot.
  2. Enter config ethgasstation_gas_enabled, and enter True
  3. Enter config ethgasstation_api_key, and enter the Defipulse API key.
  4. Enter config ethgasstation_gas_level, and the following prompt is displayed.

Note: For caculation details on the various gas level, see defipulse docs

Enter gas level you want to use for Ethererum transcations (fast, fastest, safeLow, average) >>>

  1. Enter the value for the gas level.
  2. (Optional) Enter config ethgasstation_refresh_time, enter a value to overwrite the default Gas Station refresh time (120secs).

AMM Arbitrage Strategy

After the installation and configuration is completed, we can create the configuration for AMM arbitrage strategy. The following example shows a step-by-step on configuring the AMM arb strategy.

Important: Paper trading is not available.

  1. In Hummingbot, enter create.
  2. Enter amm-arb.
  3. Enter balancer.
  4. Enter the first trading pair, for example BAT-DAI.

    Note: Ensure the trading pair tokens are in your wallet in order to trade.

  5. Enter an exchange connector, for example binance.
  6. Enter the second trading pair, for example BAT-USDT.
  7. Follow on-screen prompts and info for AMM arb parameters.
  8. Enter start to run the strategy.
  9. To check transactions, you can use etherscan.io to check if any pending transaction gets stuck for too long (> 5 min). If any Tx is got stuck, change the config ethgasstation_gas_level to fast, the transaction setting should complete < 1-2 min

For details on each AMM parameters, see the following sections for details. These parameters are fields in Hummingbot configuration files (located in the /conf folder, e.g. conf/amm_arb_[#].yml).

connector 1

Enter the first exchange/AMM you would like to trade on.

Prompt:

Enter your first connector (exchange/AMM)

market_1

Enter the first token trading pair for the secondary exchange.

Prompt:

Enter the token trading pair you would like to trade on balancer (e.g. WETH-DAI)

connector 2

Enter the secondary exchange/AMM you would like to trade on.

Prompt:

Enter your second connector (exchange/AMM)

market_2

Enter the second token trading pair for the secondary exchange.

Prompt:

Enter the token trading pair you would like to trade on balancer (e.g. ZRX-ETH)

order_amount

The order amount for the bid order of the base asset for the first trading pair.

Prompt:

What is the amount of [first trading pair base asset] per order?

min_profitability

Minimum profitability target required to execute trades.

Prompt:

What is the minimum profitability for you to make a trade? (Enter 1 to indicate 1%) >>>

market_1_slippage_buffer

Percent buffer added to the market 1 exchange price to account for price movement before trade execution.

Prompt:

How much buffer do you want to add to the price to account for slippage for orders on the first market (Enter 1 to indicate 1%) >>>

market_2_slippage_buffer

Percent buffer added to the market 2 exchange price to account for price movement before trade execution.

Prompt:

How much buffer do you want to add to the price to account for slippage for orders on the second market (Enter 1 to indicate 1%) >>>

concurrent_orders_submission

If true the bot submits both arbitrage taker orders (buy and sell) simultaneously. If false, the bot will wait for first exchange order filled before submitting the other order.

Prompt:

Do you want to submit both arb orders concurrently (Yes/No)? If no, the bot will wait for first connector order filled before submitting the other order >>>

manual_gas_price

If you prefer to manually set your gas other than using Defipulse.

Note: If Defipulse is set for gas estimation, manual_gas_price is ignored. To use manual gas price, you need to disable ethgasstation_gas_enabled

Prompt:

Enter fixed gas price (in Gwei) you want to use for Ethereum transactions >>>

Update Gateway 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.

Switch Balancer Network

Two ways to switch network(Kovan/Mainnet)

  • Delete the Gateway docker container and re-run the create-gateway.sh script.
  • Use update-gateway.sh script to update the docker image and follow the prompt instructions.
Edit on GitHub