Using Osmosis with Hummingbot¶
Introduction¶
These instructions help users navigate the installation, configuration, and operation of (OSS) Hummingbot high-frequency trading bot running Automated Market Making Arbitrage or Range Automated Market Making strategies on Osmosis DEX over the Hummingbot Gateway.
Prerequisites¶
Create an Osmosis (Cosmos) Wallet¶
The Cosmos ecosystem is powered by the Inter-Blockchain Communication protocol (IBC) which functions like an internet of blockchains. Most Cosmos wallets support all IBC chains natively, including Osmosis - though specific networks may need to be manually added.
Stay up to date with Osmosis-specific wallet information on the Osmosis website and/or Docs:
Leap Wallet (recommended)¶
To ensure the ability to easily export the wallet private key, use Leap. Remember that the private key exported from Leap will include a ‘0x’ prefix which must be removed.
Fund the Wallet¶
There are multiple bridges to Cosmos available, but the easiest way is to directly deposit to Osmosis using the Osmosis DEX front end.
Note
Please ensure your wallet has sufficient balance, including OSMO for gas fees
Install Hummingbot¶
There are two main methods to install Hummingbot:
Docker¶
The recommended method for installing Hummingbot is using Docker.
Source¶
For advanced users who are comfortable using command line interface, installing from source allows for customization and private changes.
Guides for various environments:
Add Osmosis Wallet to Hummingbot¶
You will need to export the private key for your designated trading wallet. It is highly advised to have a dedicated account for this purpose.
Warning
Be aware an exported private key may have an 0x at the start, which may need to be removed to fit the private key format check.
→ Before: 0x1234567890...
→ After: 1234567890...
Export Private Key from Keplr¶
Keplr is the most popular Cosmos-based wallet. However, when creating a Keplr wallet, only users who link a Google Account are able to export their private key directly from Keplr.
Note
For a linked Keplr-Google wallet, find instructions to export the private key here.
To get around this, export the seed instead and then restore with a different Osmosis wallet which allows exporting private key.
To get a Keplr private key without a linked Google Account:
-
Export Keplr seed phrase.
-
Restore the wallet using the seed phrase, in a different Cosmos-based wallet (such as Leap wallet) which allows exporting the private key.
-
Export the private key from the newly restored wallet.
Warning
Your wallet seed phrase is extremely sensitive. Keep it confidential and never share it online or with anyone you don't trust. Always ensure you're in a secure and private environment when handling your seed phrase.
Export Private Key from Leap¶
To export a private key from Leap wallet:
-
Open Leap wallet and then open the wallet menu.
-
Scroll down to the ‘Security’ section and select ‘Export Private Key’.
-
Enter the wallet password and proceed to view the private key by hovering the cursor over the blurred area.
-
Copy down the private key and be sure to discard the ‘0x’ at the beginning of the displayed key.
Note
Images made with Leap version 0.10.7 and Keplr version 0.12.70; in Chrome.
Add Private Key to Hummingbot¶
Run gateway connect osmosis
and follow the prompts to add a trading wallet to the Osmosis DEX connector.
Note
Hummingbot stores both API keys and private keys on the local machine in encrypted form, with the Hummingbot client password as the key.
Gateway Connect¶
- To connect to Osmosis mainnet run the command below
-
To connect to the Osmosis testnet, select 'testnet' instead of 'mainnet' when prompted.
-
You will be prompted to enter your Osmosis private key. If valid, you should get a message saying The connector osmosis_osmosis_mainnet is now using wallet osmo
-
To confirm the connection, you can run the balance command below to see if Hummingbot is able to pull the available balance from the exchange
Run a Strategy¶
To begin trading, a strategy must be configured. The two strategies supported natively by the Osmosis connector are amm_arb and amm_v3_lp.
Prepare¶
-
If you haven’t already, connect a wallet to Osmosis Mainnet with
gateway connect osmosis
. Afterwards, you should be able to see yourosmosis_osmosis_mainnet
wallet when you rungateway balance
. -
To display the balance of specific tokens in the trading wallet balance, run
gateway approve-tokens osmosis_osmosis_mainnet <TOKEN_SYMBOL_HERE>
. The token balance will be displayed the next timegateway balance
is run. -
Ensure the added trading wallet has at least 1 OSMO to cover trading gas costs.
Create New Strategy¶
Use the create
command to set up an amm_arb or amm_v3_lp strategy. Answer the question prompts presented so that you to generate your own version of the following example configurations.
Example AMM_ARB Config¶
strategy: amm_arb
connector_1: osmosis_osmosis_mainnet
market_1: OSMO-USDC
connector_2: uniswap_polygon_mainnet
market_2: USDC-WOSMO
min_profitability: 1.0
market_1_slippage_buffer: 1.0
market_2_slippage_buffer: 1.0
concurrent_orders_submission: false
debug_price_shim: false
gateway_transaction_cancel_interval: 600
Example AMM_V3_LP Config¶
strategy: range_amm
connector: osmosis_osmosis_mainnet
market: OSMO-USDC
fee_tier: MEDIUM
price_spread: 1.0
amount: 1.0
min_profitability: 1.0
Import a Strategy¶
Run import
to get a list of locally stored files, use the arrow keys or tab to scroll and select one. Or, you can also skip the prompt by running import <file_name.yml>
directly.
If successful, you will see:
Start a Strategy¶
To run a trading strategy:
-
Ensure a strategy is loaded and Preliminary checks are confirmed.
-
Run
start
.
Note
The amm_arb
strategy will first request confirmation of selected wallets.
Use a Script¶
Scripts can be created similar to strategies, by using the create --script
command.
Modify Strategy or Script Config¶
Modifications can be made to strategies and scripts by manually editing the file:
-
Locate the
hummingbot/scripts
folder and open the relevant file using any text editor or an IDE like Visual Studio Code. -
Make the desired changes and save.
-
Restart Hummingbot and run the command below to start the bot again:
Or, if using scripts:
Useful Commands¶
You can run the status
command shown below or press CTRL + S to check the bot status:
Note
The status
command currently has a issue with amm_v3_lp strategy.
Known Issues¶
- V1 Strategy compatibility for amm_arb and amm_v3_lp are in development.
- The fee tier ‘LOWEST’ is not supported and will result in an error.
- In some cases, the token pair must be in alphabetical order.
- PoolPrice RPC may time out intermittently which results in an error 500.
Potential Improvements¶
If you are interested in contributing or funding a bounty for development of additional features or improvements for this connector or related strategies, please feel free to contact Pecunia.Finance.
- V1 strategy bugs
- V2 strategy development
- Data Feed
- Custom CLMM range input (strategy development - amm_lp_v3 or new)
- Future Osmosis Development - https://forum.osmosis.zone/c/site-feedback/2
[Placeholder for additional Osmosis info]