🌊-Liquidity Providers
This guide is written for anyone looking to run a opendex liquidity provider setup entirely via the command line and create a revenue stream via automated arbitrage.
Prerequisites
Two Modes
Default: Light setup using Neutrino and a random open eth provider. This keeps the setup light-weight & cheap, but creates a certain dependency on other people's full nodes.
Three Networks
Simnet.
Status: down
until further noticeTestnet.
Status: up | Required CPUs: 2 for light, 4 for full | RAM: 2GB for light, 16GB for full | Disk: 1GB for light, 200GB for full | Initial Sync Time: 15 mins for light, 24h for full
bitcoin testnet 3, litecoin testnet 4, ethereum rinkeby. Faucets: t-BTC, t-LTC, t-ETH 1 or 2. If you need help or some testnet coins, hit us up on Discord!
Mainnet.
Status: down | Required CPUs: 2 for light, 4 for full | RAM: 2GB for light, 16GB for full | Disk: 1GB for light, 1TB for full | Initial Sync Time: 30 mins for light, 72h for full
Down until all breaking changes are merged and some weeks on testnet didn't reveal major issues.
Hardware
Since liquidity providers should be online 24/7 and we are ushering in a post-cloud era, we recommend setting up a power-efficient linux box connected to your router. No special configurations, like port forwardings, are necessary. Running your opendexd setup in the cloud is obviously possible, just not something we encourage to do.
🧑🏭 Standard Hardware Guide: This guide walks you through setting up an arm64-based Raspberry Pi3/4. Costs: 65€-290€
💪 Pro Hardware Guide: This guide walks you through setting up a powerful amd64-based Mini PC. Costs: 180€-465€
🎚️ Custom: If you are using a different device or a cloud VPS:
Check the hardware requirements for the different networks and modes above
The full setup requires a SSD for geth being able to sync. For the light setup, a regular HDD/SD card is fine.
If you are using a VPS for testnet or mainnet, you can switch to 2 cores & 4 GB RAM after initial sync, given you use default settings.
We currently support
amd64
(also calledx86
/x64
) andarm64
(also calledaarch64
/armv8
), which should cover most devices and services.
Software
Docker & Docker Compose.
Version >= 18.09 on Linux or Windows 10 using WSL 2. If you do not have docker & docker-compose installed yet and you are using Ubuntu 20.04 LTS, install these via sudo apt install docker.io
. If you are using any version besides Ubuntu 20.04, follow the official docker install instructions. Also make sure that the current user can run docker commands. Test with docker run hello-world
. If this fails, follow these instructions. This guide was written using Ubuntu 20.04 LTS.
The Setup
From here we assume that your device is running with docker set up. Check the guides in the hardware section above if your device is not ready yet.
Let's Roll (!WIP - NOT FULLY WORKING YET!)
Start the environment with
The setup will ask you to choose the network:
Sync light clients (default):
And then guide you through some basics:
When creating a new opendexd SEED, the setup asks you to set a password to encrypt your environment's private keys and to write down your mnemonic phrase. This serves as backup for your opendexd node key and wallets (your on-chain assets). This is your last resort in case something happens to your device. Keep it somewhere safe!
Then you'll be asked to enter the path to your backup drive, e.g. a previously mounted USB drive:
The entered backup drive location is persisted as backup-dir = "/media/USB/"
in mainnet.conf
and can be changed any time. Alternatively, you can consider running your environment on two hard drives in RAID 1 to protect against data loss.
Then the setup might restart clients and ask you to enter your password once more before the CTL
Use the status
command to check on the your setup's health and sync progress. The default light setup should show Ready
after some seconds:
If you configured the full setup via config file or cli parameters, the sync will start fast and get slower towards the end. You might see 0.00% progress for several minutes at first.
After a while you should see all three full-nodes syncing nicely.
Bitcoind/Litecoind should finish syncing within 12h, geth in about 72h on powerful hardware. A Pi4 needs about twice that long.
The CLI takes opendex-cli
commands without the need to prepend opendex-cli
, e.g. simply type getinfo
to get basic information about your opendex node. Run help
to get an always up-to-date list of commands. Append -j
to any command to get JSON instead of the formatted output, e.g. using listpeers
to see other opendexd nodes on the network:
Your First Trade
Start by depositing some funds into your opendex node:
The deposit command for BTC & LTC is powered by Boltz. Boltz will automatically open a balanced lightning channel to you, if you don't have a channel yet. This can take several minutes to complete and we'd kindly ask you to wait patiently for your funds to appear in the getbalance
overview. If you want to follow what is happening under the hood, you can do so by typing logs boltz
. For ETH, currently one still needs to trigger a manual channel creation in a second step after funds were deposited:
Check existing orders for all activated pairs with the command orderbook
. It might take several seconds to see orders after opendexd was started due to the decentralized nature of the order exchange. Use orderbook btc/usdt
to show the order book for BTC/USDT only:
Use getbalance
to check your balance before the swap.
Issue a regular limit order with e.g. sell 0.1 btc/usdt 7171
to sell 0.1 btc for a price of 7171 USDT per BTC. If your order was matched, settlement shouldn't take longer than a couple of seconds.
Use getbalance
to check your balance after the swap. You are now owning 0.1 BTC less and 717 USDT more.
Connect Arby
In this final step we are connecting your opendex setup to your CEX (Centralized EXchage) account via a liquidity provider bot called "arby". Arby enables "transfer" of orders from the CEX into OpenDEX and creates an arbitrage revenue stream for you as liquidity provider. Arby issues orders on the OpenDEX network based on the CEX price, adding a margin
as premium. When orders are filled on OpenDEX, arby takes care of executing a counter trade on the CEX to lock in profits. At the time of writing, arby supports connecting to Binance and Kraken, but more exchanges will be added over time; check arby's FAQ for an up-to-date list. We'll use Binance as example in the following. You will need funds for at least one supported asset on Binance (e.g. BTC) for arby to start issuing orders. To activate arby, exit
from opendexd ctl
and run cp ~/.opendexd-docker/mainnet/sample-mainnet.conf ~/.opendexd-docker/mainnet/mainnet.conf
to create a config file for your environment. Then edit the following options in mainnet.conf
:
Re-enter opendex-ctl (bash ~/opendexd.sh
) and accept the prompt to add arby. After a minute you should see arby's automatically issued orders based on your Binance and OpenDEX balance via listorders
. Completed OpenDEX trades are listed in tradehistory
. You can follow actions taken by arby with logs arby
.
Check the official README to learn more about how arby works.
Report Issues
Please give us feedback and report bugs by running report
from within opendex ctl
or join our dedicated "-help" channel on Discord!
Tips 'n Tricks
No need to open/forward ports
An overview of all available commands within
opendex ctl
can be printed by typinghelp
inopendex ctl
. It allows to use client's cli (e.g.lncli
), check client status, logs and many more.The opendex-docker setup uses the fixed home directory
~/.opendex-docker
where blockchain & wallet data is stored in by default. Customize the wallet & chain data directory by creating a global opendex-docker config file withcp ~/.opendex-docker/sample-opendex-docker.conf ~/.opendex-docker/opendex-docker.conf
, then editdir
.All config options can temporary be set via cli parameters; run
bash opendex.sh --help
to get an overview of all available parameters. To e.g. use another directory for your mainnet environment, you can runbash opendex.sh --mainnet-dir /path/to/temp/mainnet/dir
.To permanently change options on a network level, create a network-specific config file with the latest options, e.g. for mainnet with
cp ~/.opendex-docker/mainnet/sample-mainnet.conf ~/.opendex-docker/mainnet/mainnet.conf
, then editmainnet.conf
.If you only have a small SSD available (<300GB) for a full setup, you can place your entire setup on a HDD, except for a small part of geth's data, which needs to be located on a fast SSD:
Sample config full setup:
You may use external full-nodes (including infura).
Sample config of your external bitcoind/litecoind to work with the defaults in the
<network>.conf
file:
Permanently set the alias
opendex
to launchopendex ctl
from anywhere: Add the linealias opendex="bash ~/opendex.sh"
to the end of~/.bashrc
or~/.bash_aliases
on Linux andbash_profile
on Mac, thensource
the file.You can
exit
fromopendex ctl
any time and re-enter withbash ~/opendex.sh
; the environment will stay up.A reboot of your host machine does not restart your
opendex-docker
environment by default. You will need to runbash ~/opendex.sh
andunlock
your environment with your password.Permanently stop the environment by typing
down
inopendex ctl
. A restart can be achieved withdown
first and then runningbash ~/opendex.sh
again.opendex-docker
only uses offical opendexd releases for mainnet. Testnet is running the latestopendexd
master and is updated frequently.If you are syncing the full setup, and
geth
shows sync status 99.99% for longer than 72h, you are probably running geth on a drive that is too slow for geth to catch up with the chain. In this case,down
the environment and run a performance test of the disk as desribed here. If results are below the 100 MB/s mark, you can either switch to a faster SSD, use the default light setup connecting to an open geth node or use infura.Docker might not play nicely with a VPN you are running on the host machine. If you see
Failed to launch environment
, try disconnecting the VPN.If you decide to remove
opendex-docker
from your machine, run the following commands when the environment isdown
:
References
Last updated