Skip to content

Setting up Liquidity Provider (LP) Node

Saddam Hossain edited this page Mar 6, 2018 · 23 revisions

!!! This guide is deprecated !!!

For setting up a LP node, follow this guide.

Windows users can use this guide.

The API documentation is found here.


Prerequisites

Hardware

Minimum specs:

  • 2 (virtual) cores
  • 4GB RAM
  • 200 GB HDD (HDD because the bitcoin blockchain size is currently ~150 GB).

Recommended hardware specs:

  • Hired (virtual) server in a data center with fast network and direct network accessibility (no NAT)
  • 4 (virtual) cores
  • 12GB RAM
  • 400 GB HDD for long-term and storing more blockchains locally

Software

The software currently works only on Linux.

You must have synchronized full nodes of the following cryptocurrencies installed and running on your system:

Besides your usual security measures, you have to open several potentially firewalled ports so as they can accept incoming connections. 7770 (komodo node), 7775 (iguana), 8333 (bitcoin).

External services

  • Bittrex.com account with activated API key. LP node will put funds on both Centralised Exchange and on it's local wallet to gain more liquidity.
  • Blocktrail.com account with activated API key. It is needed for querying blockchain data from explorer. No funds needed to be in Blocktrail.com. Basilisk needs to query explorer level data which is not available locally, and neither the notary nodes have them. So, in this case Blocktrail.com API is used to query explorer level data ONLY.

Coin supply

  • A Bitcoin address with an accessible balance. example. 0.2 BTC
  • A Komodo address with an accessible balance. example. 200 KMD

WARNINGS

  • This server must NOT be set up as a Notary Node. Never use a Notary Node as a LP node.
  • For security, do not use a general purpose BTC/KMD/etc address that contains significant funds.

Installing Liquidity Provider (LP) Node on Ubuntu/Debian System

Liquidity Provider (LP) node is using the same iguana daemon codebase which is used at many other places like Notary Nodes, Agama Wallet and such.

For Liquidity Provider we'll need to compile iguana daemon & marketmaker daemon with Market Maker capabilities.

Setting up SuperNET/Iguana.

Log in as the user to your system, and issue these commands to make sure your Linux machine is up to date.

sudo apt-get update
sudo apt-get upgrade (and say Y when it wants to upgrade stuff)

Install the dependency packages:

sudo apt-get install build-essential pkg-config libc6-dev m4 \
		g++-multilib autoconf libtool ncurses-dev unzip git python \
		zlib1g-dev wget bsdmainutils automake libboost-all-dev \
		libssl-dev libprotobuf-dev protobuf-compiler libqt4-dev \
		libqrencode-dev libdb++-dev ntp ntpdate vim software-properties-common \
		curl libcurl4-gnutls-dev cmake clang

Some Linux machines are now providing nanomsg package version 1.0. If it is available via package manager, you can install it from there. Else, you should use github repo of nanomsg and compile it yourself.

For Ubuntu 14.04 you need to install it yourself

cd /tmp
wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz -O nanomsg-1.0.0.tar.gz
tar -xzvf nanomsg-1.0.0.tar.gz
cd nanomsg-1.0.0
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
cmake --build .
sudo cmake --build . --target install
sudo ldconfig

Or the following for 16.04

git clone https://github.com/nanomsg/nanomsg
cd nanomsg
cmake .
make
sudo make install
sudo ldconfig

Time to compile iguana daemon from SuperNET github repo

cd ~
git clone https://github.com/jl777/SuperNET
cd SuperNET/iguana
git checkout dev
./m_LP

This will compile iguana daemon and place it under ~/SuperNET/agents/iguana. To start iguana daemon follow these exact steps:

cd ~/SuperNET/iguana/
../agents/iguana

Make sure to follow the above steps exactly to start iguana daemon properly. Once you see output like below iguana is ready and serving it's API on http://127.0.0.1:7778 or http://localhost://7778

>>>>>>>>>> iguana_rpcloop 127.0.0.1:7778 bind sock.17 iguana API enabled <<<<<<<<<
mainloop

Setup link between iguana, KMD and BTC

Link between these three is that iguana API starts talking to Native Komodo RPC and Native Bitcoin RPC.

This let iguana and marketmaker do transaction and OP Script operations.

So, in this sense, iguana and marketmaker are basically working as external Smart Contract daemon.

To start BTC passthru link between iguana and Native Bitcoin RPC do these steps:

cd ~/SuperNET/iguana/coins
./btc

To start KMD passthru link between iguana and Native Komodo RPC do these steps:

cd ~/SuperNET/iguana/coins
./kmd

Now we are ready for next step.

Time to compile Market Maker

Keep iguana daemon running in separate window, and open a new Terminal window and follow these steps:

cd ~
cd SuperNET/iguana
git checkout dev
./m_mm

This will compile marketmaker daemon which you can find in ~/SuperNET/iguana/marketmaker.

Making your wallets ready

With DEX Client and DEX LP node, you should use a new wallet passphrase for this testing, and doing so will include steps to get the privkeys of the addresses from this new wallet and importing them to your Komodo, Bitcoin and Assetchain wallets. And then fund these addresses with some funds to be ready.

First thing is gettig privkey/wifkey of your wallet's addresses. For that I assume you have iguana daemon already running as mentioned in earlier steps. Now execute this following curl command in linux terminal to get the output with your wallet's main address and it's privkey:

# In this example I used the passphrase "your very long passphrase". replace it with your own unique passphrase
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"KMD\",\"agent\":\"bitcoinrpc\",\"method\":\"encryptwallet\",\"passphrase\":\"your very long passphrase here\"}"

This will result in following JSON output:

{
  "pubkey": "0c7fea2075c428a69a86df4d45360afe5c8adcadeee9204ed6c5f2b18511a912",
  "RS": "NXT-2F22-TWB8-ZMZG-68YMR",
  "NXT": "5462803465692525568",
  "btcpubkey": "0386c7c588014b9c5554d4229f452c45bfd1476300efd3c28ac147fff803ea7f53",
  "rmd160": "c610ab0802643c453dd78bb252fb8478dfded61c",
  "KMD": "RTLTqcnMqMmiVDNiRD71b6oHQvATTgV4U8",
  "BTC": "1K4Gm6u5EXy9RD1Wx37tVaU5eehrtvSEkf",
  "JUMBLR": "RTLTqcnMqMmiVDNiRD71b6oHQvATTgV4U8",
  "REVS": "RTLTqcnMqMmiVDNiRD71b6oHQvATTgV4U8",
  "result": "success",
  "handle": "",
  "persistent": "0c7fea2075c428a69a86df4d45360afe5c8adcadeee9204ed6c5f2b18511a912",
  "status": "unlocked",
  "duration": 3600,
  "privkey": "38bb9c8695dbf2421b88aa67ea3c3326c88bbe6b21b3f642bb6174e6807bf160",
  "KMDwif": "UqupoW6P857JhmzjNnEEJN81rGUTTt3nweZvbLQZ2FEBmneZQ4F8",
  "BTCwif": "Ky7zVpUQcr94EjCeCEYeXvSnvCRKNmnBB9C725csZY1UsvjYUR56",
  "tag": "445121851597586507"
}

In the above example output your KMD and BTC addresses, and their privkeys are:

"KMD": "RTLTqcnMqMmiVDNiRD71b6oHQvATTgV4U8"
"KMDwif": "UqupoW6P857JhmzjNnEEJN81rGUTTt3nweZvbLQZ2FEBmneZQ4F8"

"BTC": "1K4Gm6u5EXy9RD1Wx37tVaU5eehrtvSEkf"
"BTCwif": "Ky7zVpUQcr94EjCeCEYeXvSnvCRKNmnBB9C725csZY1UsvjYUR56"

Importing and validating your KMD and BTC addresses to Native Wallets

Now that you have the main addresses linked to your passphrase/seed, you can use the privkeys to import them to your Native Wallets.

To import privkey to Komodo:

komodo-cli importprivkey "UqupoW6P857JhmzjNnEEJN81rGUTTt3nweZvbLQZ2FEBmneZQ4F8"

To import privkey to Bitcoin:

bitcoin-cli importprivkey "UqupoW6P857JhmzjNnEEJN81rGUTTt3nweZvbLQZ2FEBmneZQ4F8"

To import privkey to and Assetchain like REVS:

komodo-cli -ac_name=REVS importprivkey "UqupoW6P857JhmzjNnEEJN81rGUTTt3nweZvbLQZ2FEBmneZQ4F8"

In case you don't have REVS assetchain running, you can go to SuperNET directory and see example scripts:

cd SuperNET/iguana/coins/
$ cat revs

~/komodo/src/komodod -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 &
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"REVS.conf\",\"path\":\"${HOME#"/"}/.komodo/REVS\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"REVS\",\"name\":\"REVS\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"905c3498\",\"p2p\":10195,\"rpc\":10196,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}"

The above example displays the script revs content which starts the REVS assetchain using komodod daemon. If your komodod daemon's path is different, then edit this file and use different path.

After editing and making sure the paths are correct, execut it

cd SuperNET/iguana/coins/
./revs

This should start the assetchain and also link it to iguana so that iguana can talk to this Assetchain's RPC.

You can find more examples of the assetchains in same coins directory and edit them accordingly, and start those assetchains.

Ready to start Market Maker

cd SuperNET/iguana/exchanges

Edit the file randval there and change it's value to your passphrase.

export randval="your long passphrase here"

Save the file after updating your wallet passphrase.

Now start marketmaker in client mode:

cd SuperNET/iguana/exchanges
./client

You can leave this terminal window running and show console log of marketmaker.

You can now use the Ugly EasyDEX GUI, which you can find here: https://github.com/SuperNETorg/dexuglygui/tree/v0.1

Doing DEX trades via command line

If you have been following this guide, you must be running:

  • iguana daemon
  • komodod daemon
  • REVS assetchain using komodod daemon
  • marketmaker daemon
  • You have imported the privkey of coin's address which you get using your passphrase. If you haven't done this part, scroll up and check the importprivkey instructions. It is important step, and without that you'll not be able to use DEX trades. The reason for this is marketmaker will only read the transactions linked to the smartaddresses which are linked to the passphrase used with marketmaker. If you don't have these smartaddresses imported in your native coin wallet's doesn't matter those addresses has any funds or UTXOs marketmaker can not read these transactions.

If you want to look at the example commands and scripts you can take a look at the shell scripts available in directory ~/SuperNET/iguana/exchanges/.

Setting up passphrase of your wallet for MarketMaker

To get started with client side DEX trades, you need to first update/create randval file with the passphrase that you used to get the privkeys and imported them to their native wallets.

cd SuperNET/iguana/exchanges
nano randval

and enter your this line with your passphrase. Replace place your passphrase here with your passphrase:

export randval="place your passphrase here"

To save the file use keyboard shortcut CTRL+O.

To exit nano editor use keyboard shortcut CTRL+X.

You can verify if randval file has correct data in it by doing:

cat randval

And it should just print the contents of randval file in terminal.

Getting userpass for your wallet commands

Next step is to get the userpass value which is used in API commands. userpass is used in DEX API calls and without that, you won't be able to issue any API calls to marketmaker

You'll get errors like this for the shell scripts if there is no userpass file created:

@dexlp:~/SuperNET/iguana/exchanges$ ./getpeers
./getpeers: line 1: userpass: No such file or directory
curl: (7) Failed to connect to 127.0.0.1 port 7779: Connection refused

If there is no existing userpass file in SuperNET/iguana/exchanges/ directory, just create one:

nano userpass

Then enter this text in the file with blank userpass value. (We'll get the userpass in next commands):

export userpass=""

To save the file use keyboard shortcut CTRL+O.

To exit nano editor use keyboard shortcut CTRL+X.

To get the userpass value, just execute any shell script for DEX like getpeers, orderbook, help, etc.

@dexlp:~/SuperNET/iguana/exchanges$ ./getpeers
{"userpass":"062ccd962540ab7f3b6af0b0fadd2eb8b80d64c935ff140e8614295a4b2ce11e","mypubkey":"020dab751abe21dd729b64ef58ecd4c6c70b4dde125c592b4b04c5bfe637ee63","coins":[{"coin":"BTC","status":"inactive","smartaddress":"19iFW39QJS7SqD6fPKwBhh5fQCgxMhUftb","rpc":"127.0.0.1:8332","pubtype":0,"p2shtype":5,"wiftype":128,"estimatedrate":300,"txfee":50000}, {"coin":"KMD","status":"active","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:7771","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"REVS","status":"active","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:10196","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"JUMBLR","status":"active","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:15106","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"HUSH","status":"inactive","smartaddress":"t1SarWNZYGku3Rr9ZKkkJqWBaert35wDzxC","rpc":"127.0.0.1:8822","pubtype":184,"p2shtype":189,"wiftype":128,"estimatedrate":20,"txfee":10000}, {"coin":"LTC","status":"inactive","smartaddress":"LTwCmFTEP6MW61npZTvUyi9RcR4EShxWse","rpc":"127.0.0.1:9332","pubtype":48,"p2shtype":5,"wiftype":176,"estimatedrate":20,"txfee":100000}, {"coin":"SUPERNET","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:11341","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"WLC","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:12167","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"PANGEA","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:14068","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"DEX","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:11890","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"BET","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:14250","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"CRYPTO","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:8516","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"HODL","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:14431","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"SHARK","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:10114","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"BOTS","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:11964","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"MGW","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:12386","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"MVP","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:8655","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"KV","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:9747","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"CEAL","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:11116","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}, {"coin":"MESH","status":"inactive","smartaddress":"RHzSaZ2guFv1uDTrrVvJoDQsAU9YzTvjAz","rpc":"127.0.0.1:9455","pubtype":60,"p2shtype":85,"wiftype":188,"estimatedrate":20,"txfee":10000}]}
@dexlp:~/SuperNET/iguana/exchanges$ 

If you try to execute the same LP/DEX shell script again it will now say "authentication error":

@dexlp:~/SuperNET/iguana/exchanges$ ./getpeers
{"error":"authentication error"}
@dexlp:~/SuperNET/iguana/exchanges$ 

NOTE: Just after starting/restarting ./client script, which actually starts/restarts marketmaker daemon ANY LP/DEX command that you'll execute the first time, it will reflect the above JSON output giving your information of your logged in wallet's userpass, public key linked to the logged in wallet, and the addresses of all the coins enabled/disabled with marketmaker.

Note this userpass string. You'll only get it once as first command supplied to marketmaker. If you need to get this userpass again, restart marketmaker by executing shell script ./client as covered in heading "Ready to start Market Maker".

Now edit the userpass file in SuperNET/iguana/exchanges/ and update it with this userpass value:

nano userpass
export userpass="062ccd962540ab7f3b6af0b0fadd2eb8b80d64c935ff140e8614295a4b2ce11e"

Of course, your userpass value will be different because your passphrase will be different. Don't really use this example's userpass. It is just an example.

To save the file use keyboard shortcut CTRL+O.

To exit nano editor use keyboard shortcut CTRL+X.

Now that you have updated userpass value, any shell script for LP/DEX you execute should give you it's answer:

@dexlp:~/SuperNET/iguana/exchanges$ ./getpeers
[{"ipaddr":"5.9.253.202","port":7779,"profit":0.01017000}, {"ipaddr":"5.9.253.196","port":7779,"profit":0.01037000}, {"ipaddr":"5.9.253.199","port":7779,"profit":0.01079000}, {"ipaddr":"5.9.253.201","port":7779,"profit":0.01065000}, {"ipaddr":"5.9.253.203","port":7779,"profit":0.01037000}, {"ipaddr":"5.9.253.195","port":7779,"profit":0.01094000}, {"ipaddr":"5.9.253.198","port":7779,"profit":0.01045000}, {"ipaddr":"5.9.253.197","port":7779,"profit":0.01042000}, {"ipaddr":"5.9.253.200","port":7779,"profit":0.01033000}, {"ipaddr":"86.89.42.9","port":7779,"profit":0.01089000}, {"ipaddr":"82.217.39.63","port":7779,"profit":0.01042000}, {"ipaddr":"131.164.235.194","port":7779,"profit":0.01019000}]
@dexlp:~/SuperNET/iguana/exchanges$ 

Ready for querying DEX related commands

Query for available coin Inventory

Now that you have your userpass and randval setup, you can make commands to get more info on local coins' data and orders on the network.

The first command is to get inventory information on a coin or assetchain like REVS or Jumblr. There is already an example shell script with API command there which queries inventory information of REVS. If you execute it you'll get and output similar to the following:

@dexlp:~/SuperNET/iguana/exchanges$ ./inv
{"result":"success","alice":[],"bob":[]}
@dexlp:~/SuperNET/iguana/exchanges$ 
So, what exactly this inventory command does?

The purpose of inventory command is to get the list of unspent transactions outputs (UTXOs) from the cryptocurrency's native wallet and show the bundle of these UTXOs. This inventory list will be similar to the outputs of native coin's own listunspent output but will show the bundles of big and small UTXOs in pairs.

If you see the contents of inv shell script it shows this:

satinder@dexlp:~/SuperNET/iguana/exchanges$ cat inv
source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"inventory\",\"coin\":\"REVS\"}"
@dexlp:~/SuperNET/iguana/exchanges$ 

If you want to instead query your Native Komodo Wallet, you can just make a copy of this inv shell script and then edit the value of "coin" to "KMD":

# copy inv script to inv_kmd file for example
@dexlp:~/SuperNET/iguana/exchanges$ cp -av inv inv_kmd
'inv' -> 'inv_kmd'
@dexlp:~/SuperNET/iguana/exchanges$ nano inv_kmd

Change it's contents to:

source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"inventory\",\"coin\":\"KMD\"}"

To save the file use keyboard shortcut CTRL+O.

To exit nano editor use keyboard shortcut CTRL+X.

When you execute this inv_kmd shell script it should give you inventory output for Komodo coin:

@dexlp:~/SuperNET/iguana/exchanges$ ./inv_kmd 

It will result in this JSON output:

{
  "result": "success",
  "alice": [
    {
      "method": "notified",
      "coin": "KMD",
      "now": 1498465665,
      "iambob": 0,
      "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
      "txid": "bbf1d0304bfa2f8f96d2c06480782c5078f7c32a968772b850b022c9ceb5074b",
      "vout": 0,
      "value": "200000000",
      "satoshis": "200000000",
      "txid2": "9d2cf55837d989a2d40b484f5ac3699b0f98277a5d5dbaf2d1cac05a10bef3e7",
      "vout2": 1,
      "value2": "9979057",
      "desthash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441"
    },
    {
      "method": "notified",
      "coin": "KMD",
      "now": 1498465665,
      "iambob": 0,
      "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
      "txid": "5824cc681ad3615c44c962a3fecb2fb6c328d9cdc52281597e9cb51ee5e41094",
      "vout": 0,
      "value": "200000000",
      "satoshis": "200000000",
      "txid2": "6b2b4603e91420c84911d9db928e9e84c67e4fa800a47407bf0ef68522ee8db4",
      "vout2": 1,
      "value2": "9980000",
      "desthash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441"
    },
    {
      "method": "notified",
      "coin": "KMD",
      "now": 1498465665,
      "iambob": 0,
      "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
      "txid": "f56077b63c3a4a7a3d90440d3bfcf0fb6b671d41a9f3c64f94aa76517e6c43a3",
      "vout": 1,
      "value": "186344423",
      "satoshis": "186344423",
      "txid2": "53b4f0be9310625b3284b0cd193a64ec5960e951b89f3cd2d51a40cb2f7d0fa3",
      "vout2": 0,
      "value2": "10000000",
      "desthash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441"
    }
  ],
  "bob": [
    {
      "method": "notified",
      "coin": "KMD",
      "now": 1498465665,
      "iambob": 1,
      "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
      "txid": "f56077b63c3a4a7a3d90440d3bfcf0fb6b671d41a9f3c64f94aa76517e6c43a3",
      "vout": 1,
      "value": "186344423",
      "satoshis": "177688888",
      "txid2": "bbf1d0304bfa2f8f96d2c06480782c5078f7c32a968772b850b022c9ceb5074b",
      "vout2": 0,
      "value2": "200000000",
      "srchash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441"
    },
    {
      "method": "notified",
      "coin": "KMD",
      "now": 1498465665,
      "iambob": 1,
      "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
      "txid": "6b2b4603e91420c84911d9db928e9e84c67e4fa800a47407bf0ef68522ee8db4",
      "vout": 1,
      "value": "9980000",
      "satoshis": "8800000",
      "txid2": "53b4f0be9310625b3284b0cd193a64ec5960e951b89f3cd2d51a40cb2f7d0fa3",
      "vout2": 0,
      "value2": "10000000",
      "srchash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441"
    }
  ]
}

You'll notice it showed some same UTXOs in both alice side and bob side.

  • Alice array shows the UTXO pairs available to use for spending. These are the funds you can use to BUY another coin pair offered by Liquidity Provider (LP) nodes.
  • Bob array shows the UTXO pairs avaialble which will be used to offer as Liquidity to the market being a Liquidity Provider (LP) node on the network.

This is something interesting and unique about our NativeDEX:

The same UTXOs which can be used to BUY other trading coin pair on the network, can also be used to SELL for another coin pairs. Means, if you have 1 KMD, and it is made of for example 4 utxos, these utxos will list at both alice side and bob side.

  • You can use the utxo funds for buying, for example, REVS asset coin, LTC, ZEC etc.
  • You can also use the same 1 KMD utxo funds to put sell order against PANGEA asset coin, HUSH, BTC, etc.

This feature multiplies liquidity of 1 KMD to N times over network to be able to fill orders for whichever coin pair fills that utxo order first and then adjust the orders to use the remaining funds which aren't sold/bought.

Anyway, let's get back to querying and verifying out unspent transactins output. If you want to look at the Komodo's own listunspent output, you can do so by doing this command:

cd ~/komodo/src/
./komodo-cli listunspent

It will result in this JSON output for example:

[
  {
    "txid": "bbf1d0304bfa2f8f96d2c06480782c5078f7c32a968772b850b022c9ceb5074b",
    "vout": 0,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 2.00000000,
    "interest": 0.00000000,
    "confirmations": 16331,
    "spendable": true
  },
  {
    "txid": "5824cc681ad3615c44c962a3fecb2fb6c328d9cdc52281597e9cb51ee5e41094",
    "vout": 0,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 2.00000000,
    "interest": 0.00000000,
    "confirmations": 16332,
    "spendable": true
  },
  {
    "txid": "53b4f0be9310625b3284b0cd193a64ec5960e951b89f3cd2d51a40cb2f7d0fa3",
    "vout": 0,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 0.10000000,
    "interest": 0.00000000,
    "confirmations": 16331,
    "spendable": true
  },
  {
    "txid": "f56077b63c3a4a7a3d90440d3bfcf0fb6b671d41a9f3c64f94aa76517e6c43a3",
    "vout": 1,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 1.86344423,
    "interest": 0.00000000,
    "confirmations": 403,
    "spendable": true
  },
  {
    "txid": "6b2b4603e91420c84911d9db928e9e84c67e4fa800a47407bf0ef68522ee8db4",
    "vout": 1,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 0.09980000,
    "interest": 0.00000000,
    "confirmations": 403,
    "spendable": true
  },
  {
    "txid": "9d2cf55837d989a2d40b484f5ac3699b0f98277a5d5dbaf2d1cac05a10bef3e7",
    "vout": 1,
    "address": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "account": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
    "scriptPubKey": "76a91493834d71ae00e22e793f000e25d28b2a021683be88ac",
    "amount": 0.09979057,
    "interest": 0.00000000,
    "confirmations": 1043,
    "spendable": true
  }
]

Check order book for a coin pair

The orderbook will give a list of asks and bids setup by LP nodes over the network. Take a look at the script orderbook in SuperNET/iguana/exchanges/:

@dexlp:~/SuperNET/iguana/exchanges$ cat orderbook 
source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}"

In this API command, base is the coin which you want to BUY, and rel is the coin using which you want to BUY the coin specified in base. In other words, you are selling the KMD you have to buy REVS.

If you execute this shell script you'll get ordebook enteries of KMD/REVS asks and bids:

@dexlp:~/SuperNET/iguana/exchanges$ ./orderbook

It will result in JSON output look this:

{
  "bids": [
    {
      "price": 1.07003092,
      "volume": 1.66059582,
      "txid": "aa2e49f8e41bde7a0acf2f8f3dbf64e5f1a185927369f0ae9d9a77b0efc9ffc3",
      "vout": 1,
      "pubkey": "6a6b25e369c31505421bfd689a288f7294766cc8f1ef2e296783c33975fdb522"
    },
    {
      "price": 1.07003092,
      "volume": 0.91217004,
      "txid": "4fb910b818eca949392785483413522d8af249050934ca6243c571f9fa569e1e",
      "vout": 1,
      "pubkey": "6a6b25e369c31505421bfd689a288f7294766cc8f1ef2e296783c33975fdb522"
    }
  ],
  "numbids": 25,
  "asks": [
    {
      "price": 1.11224634,
      "volume": 0.01086416,
      "txid": "5e5ad17aab3e4713367732546b5576fce5b2c94090ebd4aa66d437e007bb9b38",
      "vout": 1,
      "pubkey": "1bfcfc1d48dbe3e1332b09cb48e50e7789bdde2308b74f905299db12d093fa2d"
    },
    {
      "price": 1.11224634,
      "volume": 1,
      "txid": "862399c844098c085f8bafb6fc5941033ceea6a23bfeff343fc8f1c54d35d4a9",
      "vout": 1,
      "pubkey": "1bfcfc1d48dbe3e1332b09cb48e50e7789bdde2308b74f905299db12d093fa2d"
    }
  ],
  "numasks": 31,
  "base": "REVS",
  "rel": "KMD",
  "timestamp": 1498467702
}

If you want to query for different coins pair's orderbook, you can either edit existing orderbook shell script or just copy it and edit the base/rel coin pair values in there. Then use that copied shell script to query that coin pair's orderbook.

In the end of orderbook JSON output you see it also shows base/rel coin it returned values for.

  • asks shows the the rel (KMD) price for base (REVS) coin.
  • which means, it is 1.11224634 KMD price for the volume of 0.01086416 REVS

Making an Autotrade for two coin pairs

Based on the orderbook asks/bids you need to adjust your volume and price and submit your autotrade API command, and that will provide you with the swap status JSON output. for autotrade you can check the shell script autotrade:

@dexlp:~/SuperNET/iguana/exchanges$ cat autotrade 
source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"autotrade\",\"base\":\"REVS\",\"rel\":\"KMD\",\"volume\":0.01,\"price\":1.234}"

You can see it is using REVS as the coin we want to buy with our KMD in this API command. The volume it mentions is 0.01 REVS, and the price of 1.234 KMD.

If you are using different coin pairs to make traders for the orderbook your queried previously you need to change these values in this shell script or in a copy of this shell script:

  • base: the coin you are buying
  • rel: the coin you are using to buy the base coin
  • volume: the amount of base coin you are buying. This can be adjusted to match the orderlist asks/bids.
  • price: this is the price you are inputing using the rel coin. It will spend the rel coin you have in your inventory and buy you the base coin you specify.

On executing this shell script as is, this is the output:

@dexlp:~/SuperNET/iguana/exchanges$ ./autotrade 

JSON output:

{
  "base": "REVS",
  "rel": "KMD",
  "address": "RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk",
  "timestamp": 1498470303,
  "txid": "daf4fb6b932e98211aeb71cefc9020f2890f36538630568066580e67f19ee244",
  "vout": 1,
  "srchash": "756766f42122fc86280b196d51b9052a99d282f01d462e1ab3c97356b7b89659",
  "txfee": "10000",
  "satoshis": "9189700",
  "desthash": "9200ad4422472041ade4bb26511acaa7eb53b7132f0cbb45bc30448a10cbc441",
  "txid2": "70d89aed800070447ed4e1d5ff0266c41890e570c436503a9c07ee4c901bf3e8",
  "vout2": 0,
  "destaddr": "RNjAhmqZoPpadLF6sfFXTcTPmyXHnBdFvA",
  "desttxid": "f56077b63c3a4a7a3d90440d3bfcf0fb6b671d41a9f3c64f94aa76517e6c43a3",
  "destvout": 1,
  "feetxid": "53b4f0be9310625b3284b0cd193a64ec5960e951b89f3cd2d51a40cb2f7d0fa3",
  "feevout": 0,
  "desttxfee": "10000",
  "destsatoshis": "10325324",
  "price": 1.12357574,
  "maxprice": 1.234,
  "status": "no response to request"
}

The status says "no response to request", which means the autotrade request submitted did not filled or got accepted by any LP node.

Another output of this autotrade command with different volume price can be like this:

@dexlp:~/SuperNET/iguana/exchanges$ cat autotrade 
source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"autotrade\",\"base\":\"REVS\",\"rel\":\"KMD\",\"volume\":0.05,\"price\":1.234}"

@dexlp:~/SuperNET/iguana/exchanges$ ./autotrade 
{"error":"cant find utxo that is big enough"}

Which means the output of inv_kmd will show the inventory of KMD UTXOs we have doesn't have a pair of UTXOs which is big enough to complete the trade.

Let's change the volume and price again:

Clone this wiki locally