Exemple #1
0
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.changers import DexAddTokenPairChanger

import logging
import logging.config

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')

network = 'dexTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

contract = DexAddTokenPairChanger(connection_manager)
"""
RDOC: 0xC3De9F38581f83e281f260d0DdbaAc0e102ff9F8
DOC: 0xCB46c0ddc60D18eFEB0E586C17Af6ea36452Dae0
ERBTC: 0xA274d994F698Dd09256674960d86aBa22C086669
BPRO: 0x4dA7997A819bb46B6758B9102234c289dD2Ad3bf

RIF: 


DOC / RDOC
Exemple #2
0
"""
This is script getting historic data from MOC State contract
16/03/2020
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoCState
from moneyonchain.rdoc import RDOCMoCState

import datetime
import csv
import time

network = 'rdocMainnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

if connection_manager.options['networks'][network]['app_mode'] == 'MoC':
    moc_state = MoCState(connection_manager)
else:
    moc_state = RDOCMoCState(connection_manager)

from_block = 2243000  # can be manually setting
to_block = 2244000  # can be manually setting
block_steps = 2880
block_skip = 120
hours_delta = 0
last_block_number = int(connection_manager.block_number)
Exemple #3
0
                    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')


def options_from_settings(filename='settings.json'):
    """ Options from file settings.json """

    with open(filename) as f:
        config_options = json.load(f)

    return config_options


network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

# load settings from file
settings = options_from_settings()

contact_address = settings[network]['CommissionSplitter']

splitter = CommissionSplitter(connection_manager, contract_address=contact_address)

info_dict = dict()
info_dict['before'] = dict()
info_dict['after'] = dict()
info_dict['proportion'] = dict()
Exemple #4
0
import datetime
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.rdoc import RDOCFeedFactory

network = 'rdocMainnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_feedfactory = RDOCFeedFactory(connection_manager)

events_functions = ['Created']
hours_delta = 0
from_block = 2331218  # from block start
to_block = 2335218  # block end or 0 to last block
l_events = moc_feedfactory.logs_from(events_functions,
                                     from_block,
                                     to_block,
                                     block_steps=2880)

l_info = list()
if 'Created' in l_events:
    if l_events['Created']:
        count = 0
        for e_event_block in l_events['Created']:
            for e_event in e_event_block:

                count += 1
                ts = connection_manager.block_timestamp(e_event['blockNumber'])
Exemple #5
0
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.dex import MoCDecentralizedExchange


network = 'dexTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))


print(Web3.fromWei(connection_manager.balance("0xCD8A1c9aCc980ae031456573e34dC05cD7daE6e3"), 'ether'))
"""
0.369947978838833479

0.369931379918578111

**1.6598920255350702e-05

0.0001

"""
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.token import RIF

network = 'rdocMainnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

rif_token = RIF(connection_manager)

account_address = '0xc61820BFb8F87391d62cD3976DDC1D35E0cF7128'

block_number = 2405000

balance_on_block = Web3.fromWei(
    connection_manager.balance_block_number(account_address, block_number),
    'ether')
print("Balance: [{0}] on block: [{1}] Balance: [{2}] RBTC".format(
    account_address, block_number, balance_on_block))

balance_on_block = rif_token.balance_of(account_address,
                                        block_identifier=block_number)
print("Balance: [{0}] on block: [{1}] Balance: [{2}] RIF".format(
    account_address, block_number, balance_on_block))

block_number = 2467288

balance_on_block = Web3.fromWei(
    connection_manager.balance_block_number(account_address, block_number),
from moneyonchain.manager import ConnectionManager
from web3 import Web3


network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

user_address = '0x5d2691B2F9f4F89e5d6a6759079dF629B36CCF51'

# Block Number
block_number = 2609806
balance = Web3.fromWei(connection_manager.balance_block_number(user_address, block_number=block_number), 'ether')

print("RBTC Balance of: {0} balance: {1} blockNumber: {2}".format(
    user_address,
    balance,
    block_number))


# Block Number
block_number = 2609807
balance = Web3.fromWei(connection_manager.balance_block_number(user_address, block_number=block_number), 'ether')

print("RBTC Balance of: {0} balance: {1} blockNumber: {2}".format(
    user_address,
    balance,
    block_number))
Exemple #8
0
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.dex import MoCDecentralizedExchange


network = 'dexTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))


print(Web3.fromWei(connection_manager.balance("0xF8C240521712488c50df208c9d66a7bcaB649bad"), 'ether'))
from moneyonchain.manager import ConnectionManager

connection_manager = ConnectionManager()
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))
print("Gas price: {gas_price}".format(gas_price=connection_manager.gas_price))
Exemple #10
0
def block_info(block):

    network = 'mocMainnet2'
    connection_manager = ConnectionManager(network=network)
    #print("Connecting to %s..." % network)
    #print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

    if connection_manager.options['networks'][network]['app_mode'] == 'MoC':
        moc_state = MoCState(connection_manager)
    else:
        moc_state = RDOCMoCState(connection_manager)

    n_block = int(block)

    if isinstance(block, int):
        n_block = int(connection_manager.block_number)
    if n_block <= 0:
        n_block = int(connection_manager.block_number)

    hours_delta = 0

    ts = connection_manager.block_timestamp(n_block)
    dt = ts - datetime.timedelta(hours=hours_delta)
    d_timestamp = dt.strftime("%Y-%m-%d %H:%M:%S")

    d_info_data = dict()

    d_info_data['blockNumber'] = n_block
    d_info_data['Timestamp'] = d_timestamp

    # bitcoin price

    d_info_data['BTCprice'] = float(
        moc_state.bitcoin_price(block_identifier=n_block))

    # Moving average
    d_info_data['EMAvalue'] = float(
        moc_state.bitcoin_moving_average(block_identifier=n_block))

    # days to settlement, 0 is the day of the settlement
    d_info_data['daysToSettlement'] = int(
        moc_state.days_to_settlement(block_identifier=n_block))

    # bkt_0 Storage DOC
    d_info_data['C0_getBucketNDoc'] = float(
        moc_state.bucket_ndoc(str.encode('C0'), block_identifier=n_block))

    # bkt_0 Storage BPro
    d_info_data['C0_getBucketNBPro'] = float(
        moc_state.bucket_nbpro(str.encode('C0'), block_identifier=n_block))

    # bkt_0 Storage BTC
    d_info_data['C0_getBucketNBTC'] = float(
        moc_state.bucket_nbtc(str.encode('C0'), block_identifier=n_block))

    # bkt_0 Storage InrateBag
    d_info_data['C0_getInrateBag'] = float(
        moc_state.get_inrate_bag(str.encode('C0'), block_identifier=n_block))

    # bkt_0 Storage Coverage
    d_info_data['C0_coverage'] = float(
        moc_state.coverage(str.encode('C0'), block_identifier=n_block))

    # bkt_0 Storage Leverage
    d_info_data['C0_leverage'] = float(
        moc_state.leverage(str.encode('C0'), block_identifier=n_block))

    # bkt_2 Storage DOC
    d_info_data['X2_getBucketNDoc'] = float(
        moc_state.bucket_ndoc(str.encode('X2'), block_identifier=n_block))

    # bkt_2 Storage BPro
    d_info_data['X2_getBucketNBPro'] = float(
        moc_state.bucket_nbpro(str.encode('X2'), block_identifier=n_block))

    # bkt_2 Storage BTC
    d_info_data['X2_getBucketNBTC'] = float(
        moc_state.bucket_nbtc(str.encode('X2'), block_identifier=n_block))

    # bkt_2 Inrate Bag
    d_info_data['X2_getInrateBag'] = float(
        moc_state.get_inrate_bag(str.encode('X2'), block_identifier=n_block))

    # bkt_2 Coverage
    d_info_data['X2_coverage'] = float(
        moc_state.coverage(str.encode('X2'), block_identifier=n_block))

    # bkt_2 Storage Leverage
    d_info_data['X2_leverage'] = float(
        moc_state.leverage(str.encode('X2'), block_identifier=n_block))

    # Global Coverage
    d_info_data['globalCoverage'] = float(
        moc_state.global_coverage(block_identifier=n_block))

    # Bitpro total supply in system
    d_info_data['bproTotalSupply'] = float(
        moc_state.bitpro_total_supply(block_identifier=n_block))

    # All DOC in circulation
    d_info_data['docTotalSupply'] = float(
        moc_state.doc_total_supply(block_identifier=n_block))

    # RBTC in sytem
    d_info_data['rbtcInSystem'] = float(
        moc_state.rbtc_in_system(block_identifier=n_block))

    # BPro Tec price
    d_info_data['bproTecPrice'] = float(
        moc_state.bpro_tec_price(block_identifier=n_block))

    # BTC2X Tec price
    d_info_data['BTC2XTecPrice'] = float(
        moc_state.btc2x_tec_price(str.encode('X2'), block_identifier=n_block))

    return d_info_data