Is an arbitrage trading bot between the Kraken CEX and the Karura Defi Platform. This project was created through Encode Club's Polkadot and Hack Defi Hackathons.
Medium Articles: Polkadot, Hack Defi
Finals Video: Polkadot, Hack Defi
The arbitrage bot constantly checks for pricing differences between the two platforms and executes trades when they are profitable as defined in the trading-config.js
file.
- KSM/KUSD
Make sure you have the projects source code.
git clone https://github.com/houtenbos/krakura-bot.git
The trading configuration of the arbitrage bot can be found at src/config/app/trading-config.js
. This file defines the max trading size of supported currency pairs and the minimal profit margin you are willing to take when executing trades. Adjust this file to your liking and level.
module.exports = {
currencies: ['KSM', 'KAR', 'USD', 'KUSD'],
currencyPairs: ['KSM/USD'],
maxTradeSize: {
'KSM/USD': 0.02,
'KAR/USD': 10
},
minProfitMargin: 0.005,
crossPlatforms: [['kraken', 'karura'], ['karura', 'kraken']]
}
- Install all dependencies by running
yarn
in the project directory. - Build the project by running
yarn build
. - Start the arbitrage bot by running
yarn start
.
Install Grafana Docker driver client by running the following command.
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
Verify the plugin was install successfully by running the following command.
docker plugin ls
Update Docker's daemon.json
file to set the default logging driver to Loki. To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon.json on Linux systems, or C:\ProgramData\docker\config\daemon.json on Windows. On MacOS go to the whale in the taskbar > Preferences > Docker Engine. Once updated, you have to restart Docker.
Grafana change the default logging driver
Docker configure logging drivers
Docker configure and troubleshoot the Docker daemon
{
"log-driver": "loki",
"log-opts": {
"loki-batch-size": "400",
"loki-url": "http://localhost:3100/loki/api/v1/push"
}
}
Run the arbitrage bot with Docker by running the following command.
docker-compose up -d --force-recreate && docker attach krakura
View the bot's Grafana Dashboard by navigating to localhost:3000
. To login the default username is admin
and the default password is admin
. You will then be prompted to updated the password for the admin account which you can do or skip.
Verify the Loki log aggregation service is ready to ingest logs by navigating to localhost:3100/ready
. A ready message will be outputted when the service is ready. If a waiting message is displayed, such as "Ingester not ready: waiting for 15s after being ready"
just refresh the page until the ready message is presented.
Stop the arbitrage bot with CTRL+C
and make sure to take down the docker containers with the following command. Make sure to run the take down command from within the root directory of the project. The Loki and Grafana containers sometimes take a while to stop.
docker-compose down
When the arbitrage bot starts for the first time, you will be presented with a series of questions to obtain platform credentials. Once all startup questions are answered, your credentials will be encrypted and stored locally on your machine in the project at src/config/app/credentials
. Now, when the arbitrage bot starts, you will only be required to enter your password for the arbitrage bot to access your platform credentials. If you need to reset your stored platform credentials, delete the credentials file at src/config/app/credentials
and restart the arbitrage bot. Once all startup questions are answered, then the arbitrage bot will start looking for profitable trades.
- Fill in your password:
- This is the password to encrypt your credentials.
- What is your kraken api key?
- This is the api key you generate on kraken.com.
- What is your kraken api secret?
- This is the private key of your kraken api key.
- What is your karura phrase?
- This is the phrase of the wallet address associated with your karura account.
- You are required to have balances on both platforms to cover transaction fees.
- The Kraken Exchange has a minimum order size for KSM. Kraken Minimum Order Sizes