Beispiel #1
0
    def __init__(self, connection_manager, contract_address=None):

        network = connection_manager.network
        app_mode = connection_manager.options['networks'][network]['app_mode']

        if app_mode == "RRC20":
            self.contract_MoC = RDOCMoC(connection_manager,
                                        contract_address=contract_address,
                                        contracts_discovery=True)
        else:
            self.contract_MoC = MoC(connection_manager,
                                    contract_address=contract_address,
                                    contracts_discovery=True)

        if network in [
                'mocTestnetAlpha', 'mocTestnet', 'rdocTestnetAlpha',
                'rdocTestnet'
        ]:
            self.sc_Price_Provider = CoinPairPrice(
                connection_manager,
                contract_address=self.contract_MoC.sc_moc_state.price_provider(
                ))
        else:
            if app_mode == "RRC20":
                self.sc_Price_Provider = MoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())
            else:
                self.sc_Price_Provider = RDOCMoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())
Beispiel #2
0
class PriceProvider:
    log = logging.getLogger()
    precision = 10**18

    def __init__(self, connection_manager, contract_address=None):

        network = connection_manager.network
        app_mode = connection_manager.options['networks'][network]['app_mode']

        if app_mode == "RRC20":
            self.contract_MoC = RDOCMoC(connection_manager,
                                        contract_address=contract_address,
                                        contracts_discovery=True)
        else:
            self.contract_MoC = MoC(connection_manager,
                                    contract_address=contract_address,
                                    contracts_discovery=True)

        if network in [
                'mocTestnetAlpha', 'mocTestnet', 'rdocTestnetAlpha',
                'rdocTestnet'
        ]:
            self.sc_Price_Provider = CoinPairPrice(
                connection_manager,
                contract_address=self.contract_MoC.sc_moc_state.price_provider(
                ))
        else:
            if app_mode == "RRC20":
                self.sc_Price_Provider = MoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())
            else:
                self.sc_Price_Provider = RDOCMoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())

    def price(self,
              formatted: bool = True,
              block_identifier: BlockIdentifier = 'latest'):
        """Get price"""

        result = self.sc_Price_Provider.price(
            formatted=formatted, block_identifier=block_identifier)

        return result
Beispiel #3
0
Oracle price get current oracle from MOC
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.rdoc import RDOCMoC
from moneyonchain.rdoc import RDOCMoCMedianizer

# Network types
#
# rdocTestnet: Testnet
# rdocMainnet: Production Mainnet

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

print("Connecting to RDOC Main Contract")
moc_contract = RDOCMoC(connection_manager)

#oracle_provider = moc_contract.sc_moc_state.price_provider()
#print("Oracle address: {0}".format(oracle_provider))

#oracle_provider = '0x987ccC60c378a61d167B6DD1EEF7613c6f63938f'
#oracle_provider = '0xDC3551f16FfDeBAa3Cb8D3b6C16d2A5bB9646dA4'

#oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_provider)
oracle = RDOCMoCMedianizer(connection_manager)
print("RIF Price in USD: {0}".format(oracle.price()))
Beispiel #4
0
import logging
import logging.config

# logging module
# Initialize you log configuration using the base class
logging.basicConfig(level=logging.INFO)
# Retrieve the logger instance
log = logging.getLogger()

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

oracle_address = '0x01a165cC33Ff8Bd0457377379962232886be3DE6'

oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_address)

print("Peek:")
print(oracle.peek())
print("Compute:")
print(oracle.compute())

if not oracle.compute()[1] and oracle.peek()[1]:
    print("Recalculating oracle status...")
    oracle.poke()
    print("Oracle status updated!")
else:
    print("Not time to recalculate status!")
Beispiel #5
0
# Initialize you log configuration using the base class
logging.basicConfig(level=logging.INFO)
# Retrieve the logger instance
log = logging.getLogger()

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

oracle_address = '0x504EfCadFB020d6bBaeC8a5c5BB21453719d0E00'
feeder_address_1 = '0x461750b4824b14c3d9b7702bC6fBB82469082b23'
feeder_address_2 = '0xBEd51D83CC4676660e3fc3819dfAD8238549B975'

oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_address)

feeder_1 = RDOCPriceFeed(connection_manager,
                         contract_address=feeder_address_1,
                         contract_address_moc_medianizer=oracle_address)

print("Oracle price:")
print(oracle.peek())

print("Price Feeder 1")
print("===============")

print(
    "Price feeder price and have value (if have value if false, no price setted) :"
)
print(feeder_1.peek())
Beispiel #6
0
from moneyonchain.manager import ConnectionManager
from moneyonchain.rdoc import RDOCMoCMedianizer

import logging
import logging.config

# logging module
# Initialize you log configuration using the base class
logging.basicConfig(level=logging.INFO)
# Retrieve the logger instance
log = logging.getLogger()


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

#oracle_address = '0x2B54819531B7126bDEE2CeFDD9c5342d6c307595'
#oracle_address = '0x01a165cC33Ff8Bd0457377379962232886be3DE6'
#oracle_address = '0x9d4b2c05818A0086e641437fcb64ab6098c7BbEc'
#oracle_address = '0x9315AFD6aEc0bb1C1FB3fdcdC2E43797B0A61853'
#oracle_address = '0xb856Ca7c722cfb202D81c55DC7925e02ed3f0A2F'
#oracle_address = '0xCEE08e06617f8b5974Db353E2c8C66424F91c42A'
oracle_address = '0x9d4b2c05818A0086e641437fcb64ab6098c7BbEc'
oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_address) #contract_address=oracle_address
#print(oracle.price())
print(oracle.peek())
"""
Oracle price get current oracle from MOC
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.rdoc import RDOCMoCMedianizer

# Network types
#
# rdocTestnet: Testnet
# rdocMainnet: Production Mainnet

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

oracle_provider = '0xDC3551f16FfDeBAa3Cb8D3b6C16d2A5bB9646dA4'
oracle = RDOCMoCMedianizer(connection_manager,
                           contract_address=oracle_provider)

print("Before")
print("Min: {0}".format(oracle.min()))
oracle.set_min(2)
print("After")
print("Min: {0}".format(oracle.min()))
count += 1
line = '| {0} | {1}  | {2}  | {3} |'.format(count, 'MoCBProxManager',
                                            addresses['MoCBProxManager'],
                                            contract.implementation())
lines.append(line)

# RIFDoC
contract = RIFDoC(connection_manager)
count += 1
line = '| {0} | {1}  | {2}  | {3} |'.format(count, 'RIFDoC', '',
                                            contract.address())
lines.append(line)

# RIFPro
contract = RIFPro(connection_manager)
count += 1
line = '| {0} | {1}  | {2}  | {3} |'.format(count, 'RIFPro', '',
                                            contract.address())
lines.append(line)

# Oracle
contract = RDOCMoCMedianizer(connection_manager)
count += 1
line = '| {0} | {1}  | {2}  | {3} |'.format(count, 'MoCMedianizer', '',
                                            contract.address())
lines.append(line)

# finally print
print(md_header)
print('\n'.join(lines))
Beispiel #9
0
"""
Oracle price get current oracle from MOC
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.rdoc import RDOCMoC
from moneyonchain.rdoc import RDOCMoCMedianizer

# Network types
#
# rdocTestnet: Testnet
# rdocMainnet: Production Mainnet


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

print("Connecting to RDOC Main Contract")
moc_contract = RDOCMoC(connection_manager)

oracle_provider = moc_contract.sc_moc_state.price_provider()
print("Oracle address: {0}".format(oracle_provider))

oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_provider)

print("RIF Price in USD: {0}".format(oracle.price()))
# Initialize you log configuration using the base class
logging.basicConfig(level=logging.INFO)
# Retrieve the logger instance
log = logging.getLogger()

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

oracle_address = '0x504EfCadFB020d6bBaeC8a5c5BB21453719d0E00'
feeders = [('0x461750b4824b14c3d9b7702bC6fBB82469082b23', '# MOC'),
           ('0xBEd51D83CC4676660e3fc3819dfAD8238549B975', '# RSK')]

oracle = RDOCMoCMedianizer(connection_manager, contract_address=oracle_address)

print("Oracle price:")
print(oracle.peek())
print('')

for feed_c in feeders:
    feeder_cl = RDOCPriceFeed(connection_manager,
                              contract_address=feed_c[0],
                              contract_address_moc_medianizer=oracle_address)

    print("Price Feeder: {0}".format(feed_c[1]))
    print("===============")
    print('Address: {0}'.format(feed_c[0]))
    print('Price: {0}'.format(feeder_cl.peek()))
    if int(oracle.indexes(feed_c[0])) > 0: