Code Monkey home page Code Monkey logo

thorchain-arb's Introduction

Recent Update

This repo is in progress, I was able to already arb between ftx and thorchain MCCN using BUSD as a base asset. This arb is not ready for public use, you must understand the code in order to use it, this can serve as a basis for people who want to develop arb bots. I will be making updates to this repo constantly.

Donation: if this repo ended up helping you, feel free to donate:

  • THOR.RUNE: thor194dh5grmq405kvajtfylvkc4639frzkwu38r7p

Installing Dependencies

update midgard and thornode api client

midgard api client isn't being supported currently, you can download the openapi json directly at "https://midgard.thorchain.info/v2/doc" I am using siaskynet as a decentralized cloud for uploading swagger client

pip install siaskynet
(cd script/ && python init_api_client.py)
pip install midgard_client/
pip install thornode_client/
HINT: since the opnapi json isn't completed, sometimes
the swagger client generated can contain small bugs,
usually the fix is to change return type of 
api endpoint from None to Object

creating mnemonic phrase and store in secret/

pip install mnemonic
mkdir secret/
python utils/thorchain_mnemonic.py

ls secret/ returns real_mnemonic

(Not sure of the status, 12 words should be fine for now)issue with 12 words mnemonic

xchainpy_binance module has problem with 12 words mnemonic, using 24 words for now. python words = Mnemonic(language).generate(strength=256)

thorchain deposit function not available

install xchainpy module

pip install xchainpy_ethereum xchainpy_bitcoin xchainpy_bitcoincash xchainpy_binance xchainpy_litecoin xchainpy_thorchain xchainpy_util

tips

binance dex

make sure you have some bnb to broadcast msg

arch

pacman -S libsecp256k1

mac with m1 chip

you need to compile libsecp256k1 from source, then

CFLAGS="-Wno-error=implicit-function-declaration" pip install secp256k1

to install numpy:

pip install Cython
git clone https://github.com/numpy/numpy.git
cd numpy
pip install . --no-binary :all: --no-use-pep517

install cex module

pip install pyotp
pip install ccxt

install db module

I am using MongoDb as a backend for storing transactions happened on thorchain that needs to be handled by cex module, you can use your personal favourite database or just execute the orders inmediately.

pip install pymongo dnspython

work flow

specify mnemonic

in account.py you can specify the location of your phrase:

MNEMONICFILE = "secret/real_mnemonic"

check account balance and address

python tests/test_account.py
2021-05-11 15:20:03,571 - DEBUG - thornode : Initial seeds: ['54.217.4.198', '34.214.69.203'] (oracle.py:107)
2021-05-11 15:20:04,196 - INFO - thornode : probing 52.32.91.52 (oracle.py:128)
2021-05-11 15:20:04,575 - INFO - thornode : probing 54.158.161.189 (oracle.py:128)
2021-05-11 15:20:04,831 - INFO - thornode : probing 13.58.177.135 (oracle.py:128)
2021-05-11 15:20:05,116 - INFO - thornode : probing 134.209.137.123 (oracle.py:128)
2021-05-11 15:20:05,209 - INFO - thornode : probing 18.188.225.254 (oracle.py:128)
2021-05-11 15:20:05,493 - INFO - thornode : probing 54.217.4.198 (oracle.py:128)
2021-05-11 15:20:05,586 - INFO - thornode : probing 34.214.69.203 (oracle.py:128)
2021-05-11 15:20:05,985 - INFO - thornode : probing 157.90.34.75 (oracle.py:128)
2021-05-11 15:20:06,073 - DEBUG - thornode : Network: https://seed.thorchain.info/ Seeds collected: ['52.32.91.52', '54.158.161.189', '13.58.177.135', '134.209.137.123', '18.188.225.254', '54.217.4.198', '34.214.69.203', '157.90.34.75'] (oracle.py:72)
2021-05-11 15:20:06,974 - INFO - thornode : Oracle Module On (oracle.py:77)
2021-05-11 15:20:08,683 - INFO - account : BTC asset: BTC.BTC amount:0.0 address: bc1q55mqk9z7gtj7u6hfptqmp7qrscrljest7pqjq5 (account.py:55)
2021-05-11 15:20:08,818 - INFO - account : ETH balance :0 address: 0xceC1Fec03F320531234321360302456105b6d9E3 (account.py:63)
2021-05-11 15:20:09,131 - INFO - account : LTC asset: LTC.LTC amount:0.0 address: ltc1qh8mhk2hpsr8n95mycqajwjw2gwmuqwwf44k8za (account.py:69)
2021-05-11 15:20:09,438 - INFO - account : BNB DEX: no balance (account.py:79)
2021-05-11 15:20:09,438 - INFO - account : address: bnb18hy3ar2gcyekdvq7r3ryk0nwuca7pxz7zlxuex (account.py:80)

you can see the api_client module probing different ip to get consensus

specify base-asset

in main.py you can find profile_1 = {'network': 'MCCN', 'unit_asset':'BNB.BUSD-BD1', 'trading_asset':['BCH.BCH'], 'cex_oracle': ftx, 'diff':4}

  • network: MCCN to arb on multichain-chaosnet
  • unit_asset: base asset of all trades, you increase in this asset
  • trading_asset: what pairs are you gonna use
  • cex_oracle: which cex are you using
  • diff: difference in output amount to execute trade

specify the consensus model

in main.py you can find thor = THORTrader(network=network, host=["134.209.137.123", "54.217.4.198"])

you can use https://thorchain.network/ to find a series of host that you trust, and pass them in a list. if you choose to ignore the parameter host, the default is to:

  • probe num_seeding number of random nodes, ensure they return same list of active-nodes
  • probe num_seeding number of random active nodes, ensure they return same pool depth for all pools
  • this probing process keeps on going, you can specify the time in cache_time all above variables can be modifed in oracle.py

testing

in root directory

pip install pytest pytest-asyncio
pytest midgard_client/test/
pytest thornode_client/test/

thorchain-arb's People

Contributors

hoodieonwho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

thorchain-arb's Issues

Cannot seem to install secp256k1==0.13.2

ERROR: Could not find a version that satisfies the requirement secp256k1==0.13.2 (from xchainpy-thorchain) (from versions: 0.1.1, 0.1.2, 0.1.5, 0.2.0, 0.3.0, 0.3.1, 0.5.1, 0.7.0, 0.7.2, 0.8.1, 0.8.2, 0.8.5, 0.9.0, 0.10.0, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2)

Update xchainpy_ethereum source

I believe the new source of xchainpy_ethereum is:
https://github.com/xchainjs/xchainpy-lib
As opposed to the testnet version as stated in the README?

Using this new version it solves account.py line 5's import error:
from xchainpy_ethereum.models.client_types import XChainClientParams

For others:

  • Git clone from repo above
  • cd into xchainpy/
  • run pip install xchainpy_ethereum/

MONGO missing from main.py

Latest commit removed from line 20:

    cred = open("secret/mongodb", 'r')
    MONGO = DB(cred=cred.read())
    cred.close()

This breaks the code which follows when making calls to the db, since MONGO is not defined. Was this intentional?

thornode client doesn't seem to be the right one ?

Hi there,

I was trying to get this to run last night, finally got all the various pips installed. But it seemed like the thornode client that i pulled in (using the instructions) is not what the code is expecting. The API being called on in the code is not to be found in source of the venv thornode client.

This is what i have ...

(venv) ronoc@Conors-MacBook-Pro thorchain-arb % ls venv/lib/python3.8/site-packages/thor*
venv/lib/python3.8/site-packages/thornode_client:
__init__.py             api                     api_client.py           configuration.py        models                  rest.py

venv/lib/python3.8/site-packages/thornode_client-1.0.0.dist-info:
INSTALLER       METADATA        RECORD          REQUESTED       WHEEL           top_level.txt
(venv) ronoc@Conors-MacBook-Pro thorchain-arb %

In oracle.py (from line 57),
none of these method calls seem supported by the above dependency ?

        self.thorNode_network = thornode_client.NetworkApi()
        self.thorNode_node = thornode_client.NodesApi()
        self.thorNode_pool = thornode_client.PoolsApi()
        self.thorNode_tx = thornode_client.TxApi()
        self.thorNode_vault = thornode_client.VaultsApi()
grep -r NodesApi venv/lib/python3.8/site-packages/thornode_client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.