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.
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.
Ensure you have setup the Ethereum wallet and nodes, for more details:
- see Setup Ethereum Wallet
- see Setup Infura Node. Take note of the Ethereum RPC URL to be use later for Gateway Docker settings.
- Create a free account on defipulse.
- After you verify your account, take note of the API Key to be use later for Gateway settings in Hummingbot.
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:
The following sections describes the installation and configuration process for Gateway.
generate_certsto create the SSL cert. The following prompt is displayed.
>>> generate_certs ----------------------------------------------------------- Enter passphrase to generate Gateway SSL certification >>>
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
certsdirectory where Hummingbot is installed.
- 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
- 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.
3. The Gateway configuration summary is displayed. Review the information and enter yes to complete the Gateway configuration.
Note: By default, Gateway will install on port
5000which 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.
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.
- Access Hummingbot.
config gateway_api_portto 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 >>>
- Enter the port number.
(Optional Settings 2) Using Defipulse
If you want to use and configure defipulse as the gas estimator
- Access Hummingbot.
config ethgasstation_gas_enabled, and enter
config ethgasstation_api_key, and enter the Defipulse API key.
config ethgasstation_gas_level, and the following prompt is displayed.
Note: For caculation details on the various gas level, see defipulse docs
- Enter the value for the gas level.
- (Optional) Enter
config ethgasstation_refresh_time, enter a value to overwrite the default Gas Station refresh time (120secs).
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.
- In Hummingbot, enter
- Enter the first trading pair, for example
Note: Ensure the trading pair tokens are in your wallet in order to trade.
- Enter an exchange connector, for example
- Enter the second trading pair, for example
- Follow on-screen prompts and info for AMM arb parameters.
startto run the strategy.
- 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_levelto 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.
Enter the first exchange/AMM you would like to trade on.
Enter the first token trading pair for the secondary exchange.
Enter the secondary exchange/AMM you would like to trade on.
Enter the second token trading pair for the secondary exchange.
The order amount for the bid order of the base asset for the first trading pair.
Minimum profitability target required to execute trades.
Percent buffer added to the market 1 exchange price to account for price movement before trade execution.
Percent buffer added to the market 2 exchange price to account for price movement before trade execution.
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.
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
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.
Two ways to switch network(Kovan/Mainnet)
- Delete the Gateway docker container and re-run the
update-gateway.shscript to update the docker image and follow the prompt instructions.