MoC - Oracles

Consume MOC Oracles in your contracts



Get rBTC price from mainnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IOracle {
  function peek() external view returns(uint256, bool);
  function getLastPublicationBlock() external view returns (uint256);
}

interface IMoCState {
  function getBitcoinPrice() external view returns(uint256);
  function getBtcPriceProvider() external view returns(address);
}

contract Example {
    address IMoCState_addr = 0xb9C42EFc8ec54490a37cA91c423F7285Fa01e257;

    // Return the current price
    function getPrice() external view returns(uint256){
        return IMoCState(IMoCState_addr).getBitcoinPrice();
    }

    // Legacy function compatible with old MOC Oracle.
    // returns a tuple (uint256, bool) that corresponds
    // to the price and if it is not expired.
    function peek() external view returns(uint256, bool){
        return IOracle(IMoCState(IMoCState_addr).getBtcPriceProvider()).peek();
    }

    // In the near close future it will implement this function
    // that returns the block number of the last publication.
    function getLastPublicationBlock() external view returns (uint256){
        return IOracle(IMoCState(IMoCState_addr).getBtcPriceProvider()).getLastPublicationBlock();
    }
}



Get BPro price from mainnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IMoCState {
  function bproUsdPrice() external view returns(uint256);
}

contract Example {
    address IMoCState_addr = 0xb9C42EFc8ec54490a37cA91c423F7285Fa01e257;

    function getPrice() external view returns(uint256){
        return IMoCState(IMoCState_addr).bproUsdPrice();
    }
}



Get rBTC price from testnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IOracle {
  function peek() external view returns(uint256, bool);
  function getLastPublicationBlock() external view returns (uint256);
}

interface IMoCState {
  function getBitcoinPrice() external view returns(uint256);
  function getBtcPriceProvider() external view returns(address);
}

contract Example {
    address IMoCState_addr = 0x0adb40132cB0ffcEf6ED81c26A1881e214100555;

    // Return the current price
    function getPrice() external view returns(uint256){
        return IMoCState(IMoCState_addr).getBitcoinPrice();
    }

    // Legacy function compatible with old MOC Oracle.
    // returns a tuple (uint256, bool) that corresponds
    // to the price and if it is not expired.
    function peek() external view returns(uint256, bool){
        return IOracle(IMoCState(IMoCState_addr).getBtcPriceProvider()).peek();
    }

    // In the near close future it will implement this function
    // that returns the block number of the last publication.
    function getLastPublicationBlock() external view returns (uint256){
        return IOracle(IMoCState(IMoCState_addr).getBtcPriceProvider()).getLastPublicationBlock();
    }
}



Get BPro price from testnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IMoCState {
  function bproUsdPrice() external view returns(uint256);
}

contract Example {
    address IMoCState_addr = 0x0adb40132cB0ffcEf6ED81c26A1881e214100555;

    function getPrice() external view returns(uint256){
        return IMoCState(IMoCState_addr).bproUsdPrice();
    }
}



Get RIF price from mainnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IOracle {
  function peek() external view returns(uint256, bool);
  function getLastPublicationBlock() external view returns (uint256);
}

interface IRoCState {
  function getReserveTokenPrice() external view returns(uint256);
  function getPriceProvider() external view returns(address);
}

contract Example {
    address IRoCState_addr = 0x541F68a796Fe5ae3A381d2Aa5a50b975632e40A6;

    // Return the current price
    function getPrice() external view returns(uint256){
        return IRoCState(IRoCState_addr).getReserveTokenPrice();
    }

    // Legacy function compatible with old MOC Oracle.
    // returns a tuple (uint256, bool) that corresponds
    // to the price and if it is not expired.
    function peek() external view returns(uint256, bool){
        return IOracle(IRoCState(IRoCState_addr).getPriceProvider()).peek();
    }

    // In the near close future it will implement this function
    // that returns the block number of the last publication.
    function getLastPublicationBlock() external view returns (uint256){
        return IOracle(IRoCState(IRoCState_addr).getPriceProvider()).getLastPublicationBlock();
    }
}



Get RIFP price from mainnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IRoCState {
  function riskProUsdPrice() external view returns(uint256);
}

contract Example {
    address IRoCState_addr = 0x541F68a796Fe5ae3A381d2Aa5a50b975632e40A6;

    function getPrice() external view returns(uint256){
        return IRoCState(IRoCState_addr).riskProUsdPrice();
    }
}



Get RIF price from testnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IOracle {
  function peek() external view returns(uint256, bool);
  function getLastPublicationBlock() external view returns (uint256);
}

interface IRoCState {
  function getReserveTokenPrice() external view returns(uint256);
  function getPriceProvider() external view returns(address);
}

contract Example {
    address IRoCState_addr = 0x496eD67F77D044C8d9471fe86085Ccb5DC4d2f63;

    // Return the current price
    function getPrice() external view returns(uint256){
        return IRoCState(IRoCState_addr).getReserveTokenPrice();
    }

    // Legacy function compatible with old MOC Oracle.
    // returns a tuple (uint256, bool) that corresponds
    // to the price and if it is not expired.
    function peek() external view returns(uint256, bool){
        return IOracle(IRoCState(IRoCState_addr).getPriceProvider()).peek();
    }

    // In the near close future it will implement this function
    // that returns the block number of the last publication.
    function getLastPublicationBlock() external view returns (uint256){
        return IOracle(IRoCState(IRoCState_addr).getPriceProvider()).getLastPublicationBlock();
    }
}



Get RIFP price from testnet

Example contract code integracion:

pragma solidity 0.5.8;

interface IRoCState {
  function riskProUsdPrice() external view returns(uint256);
}

contract Example {
    address IRoCState_addr = 0x496eD67F77D044C8d9471fe86085Ccb5DC4d2f63;

    function getPrice() external view returns(uint256){
        return IRoCState(IRoCState_addr).riskProUsdPrice();
    }
}