GithubHelp home page GithubHelp logo

saturnbot's Introduction

Saturnbot

Generic badge PyPI version Build Status codecov Codacy Badge Binder Colab nbviewer

Saturn.py

Version 0.0.2 by WizardsOrb and PseudoDeterminist, Oct 2019 This version includes the well-formed-trades version of Saturnpy. INVALID TRADES WILL NOT BE SENT to the exchange contract.

Optional Settings

The following flag values default to False, to allow the simplest and best trading experience for most users.

  • SBTKN (default: False) means TRADES ARE REQUESTED IN DECIMAL TOKEN UNITS. True means they are requested in integer subtoken units.
  • BNDL (default: False) means WE DO NOT ALLOW BUNDLE PRICING ON NEW ORDERS, ONLY INTEGER PRICES. True means we allow Fraction prices.
  • STRICT (default: False) means WE CREATE OR EXECUTE NEAREST VALID TRADE <= REQUESTED TRADE. True means invalid trades throw an error.
  • DEBUG (default: False) enables logs to console
  • TESTMODE (default: False) enables testmode, forcedisable send transaction
  • These flags can and should be ignored and left out of function calls unless the user wants to change them.

Depencies

Install

  • pip3 install -r requirements.txt

Note!!

  • Newer versions of web3.py (> 5.0.0b5) will run into an error -> TypeError: 'cytoolz.functoolz.curry' object is not subscriptable feel free to fix it.

Sample Usage

NOTE: The biggest difference to saturn.js is, that you have to create seperate instances if you want to use ETH and ETC!

#!/usr/bin/env python3
from saturnpy import Saturn

# EDIT / LOAD etcprofile.json or create settings-obj in file.

settings = {
    "blockchain": "ETC",
    "apiUrl": "https://ticker.saturn.network/api/v2/",
    "providerUrl": "https://etc-rpc.binancechain.io",
    "mnemonicKey": "legal winner thank year wave sausage worth useful legal winner thank yellow",
    "testMode": True,
    "DEBUG": True
}

#you can also add privateKey to settings
settingsETH = {
    "blockchain": "ETH",
    "apiUrl": "https://ticker.saturn.network/api/v2/",
    "providerUrl": "http://localhost:8545",
    "privateKey": "0xKeyToShuttle",
    "testMode": False,
    "DEBUG": False
}

# Saturn instances
etc = Saturn(settings)
eth = Saturn(settingsETH)

orderbook_saturnetc = etc.query.orderbook("0xac55641cbb734bdf6510d1bbd62e240c2409040f")
orderbook_saturneth = eth.query.orderbook("0xb9440022a095343b440d590fcd2d7a3794bd76c8")

print(orderbook_saturnetc, orderbook_saturneth)

myorders = etc.exchange.ordersForAddress(etc.myaddress)
print(myorders)

etc.exchange.newOrder("0xac55641cbb734bdf6510d1bbd62e240c2409040f", "buy", "5000", "0.0001")




#orderbook = saturn.query.orderbook("0xac55641cbb734bdf6510d1bbd62e240c2409040f")
#print(orderbook)

#txhash = saturn.exchange.newOrder("0xac55641cbb734bdf6510d1bbd62e240c2409040f", "buy", "0.001", "0.00007")
#print(txhash)

#tradehash = saturn.exchange.newTrade("1", "0x682d3a524b93351a57b7f14ea3e9bddfe78309de8d5ee9af9eeb0ce1b24c255a")
#print(tradehash)

#Getting token infos
tokeninfo = saturn.query.getTokenInfo("0xac55641cbb734bdf6510d1bbd62e240c2409040f")
ti = JsonToObject(tokeninfo)
pprint.pprint(tokeninfo)

tradehash = saturn.exchange.newTrade("1", ti["best_sell_order_tx"])
print(tradehash)

decodedlog = etc.exchange.decoder.allEvents(ti["best_sell_order_tx"])

print(decodedlog)

order = etc.query.getOrderByTx("0x0c5eaf9ec7c55117bfc69a065b896194de2d17f46cc69920cb7bd265f371847b")
veryfiy = etc.exchange.verifyCapacity("200.0", order)
#print(veryfiy)

gasPrice = etc.exchange.getGasPrice("etc")
print(gasPrice)

checkERC = etc.exchange.isERC223("0xac55641cbb734bdf6510d1bbd62e240c2409040f")
print(checkERC)

Test Results

https://blockscout.com/etc/mainnet/tx/0x9b1af87133bc1b21373b5049bff56356e56f7ff92579c5473d6b82e500c0e498/token_transfers https://blockscout.com/etc/mainnet/tx/0x489514c9eb3a7476e5ade01a41d64a38d7ed6140fca7f1c14fb53355ab6113e3/token_transfers

Authors

  • PseudoDetermist
  • BigRalph
  • OldCryptoGeek
  • WizardsOrb
  • Saturn.Network

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.