# OoO Router smart contract
Routes requests for data from Consumers to data providers. Data providers listen for requests and process data, sending it back to the Consumer's smart contract.
An ERC-20 Token fee is charged by the provider, and paid for by the consumer
# Functions:
constructor(address _token) public
registerAsProvider(uint256 _minFee) external
setProviderMinFee(uint256 _newMinFee) external
setProviderGranularFee(address _consumer, uint256 _newFee) external
withdraw(address _recipient, uint256 _amount) external
initialiseRequest(address _provider, uint256 _fee, bytes32 _data) external
fulfillRequest(bytes32 _requestId, uint256 _requestedData, bytes _signature) external
getTokenAddress() external
getDataRequestConsumer(bytes32 _requestId) external
getDataRequestProvider(bytes32 _requestId) external
requestExists(bytes32 _requestId) external
getRequestStatus(bytes32 _requestId) external
getProviderMinFee(address _provider) external
getProviderGranularFee(address _provider, address _consumer) external
getWithdrawableTokens(address _provider) external
# Events:
DataRequested(address consumer, address provider, uint256 fee, bytes32 data, bytes32 requestId)
RequestFulfilled(address consumer, address provider, bytes32 requestId, uint256 requestedData)
TokenSet(address tokenAddress)
ProviderRegistered(address provider, uint256 minFee)
SetProviderMinFee(address provider, uint256 oldMinFee, uint256 newMinFee)
SetProviderGranularFee(address provider, address consumer, uint256 oldFee, uint256 newFee)
WithdrawFees(address provider, address recipient, uint256 amount)
# Modifiers:
# Function constructor(address _token) public
Contract constructor. Accepts the address for a Token smart contract.
# Parameters:
# Function registerAsProvider(uint256 _minFee) external -> bool success
registerAsProvider - register as a provider
# Parameters:
_minFee
: uint256 - minimum fee provider will accept to fulfill request
# Function setProviderMinFee(uint256 _newMinFee) external -> bool success
setProviderMinFee - provider calls for setting its minimum fee
# Parameters:
_newMinFee
: uint256 - minimum fee provider will accept to fulfill request
# Function setProviderGranularFee(address _consumer, uint256 _newFee) external -> bool success
setProviderGranularFee - provider calls for setting its fee for the selected consumer
# Parameters:
_consumer
: address of consumer contract_newFee
: uint256 - minimum fee provider will accept to fulfill request
# Function withdraw(address _recipient, uint256 _amount) external
Allows the provider to withdraw their xFUND
# Parameters:
_recipient
: is the address the funds will be sent to_amount
: is the amount of xFUND transferred from the Coordinator contract
# Function initialiseRequest(address _provider, uint256 _fee, bytes32 _data) external -> bool success
initialiseRequest - called by Consumer contract to initialise a data request. Can only be called by a contract. Daata providers can watch for the DataRequested being emitted, and act on any requests for the provider. Only the provider specified in the request may fulfil the request.
# Parameters:
_provider
: address of the data provider._fee
: amount of Tokens to pay for data_data
: type of data being requested. E.g. PRICE.BTC.USD.AVG requests average price for BTC/USD pair
# Return Values:
# Function fulfillRequest(bytes32 _requestId, uint256 _requestedData, bytes _signature) external -> bool
fulfillRequest - called by data provider to forward data to the Consumer. Only the specified provider may fulfil the data request.
# Parameters:
_requestId
: the request the provider is sending data for_requestedData
: the data to send_signature
: data provider's signature of the _requestId, _requestedData and Consumer's address this will used to validate the data's origin in the Consumer's contract
# Return Values:
# Function getTokenAddress() external -> address
getTokenAddress - get the contract address of the Token being used for paying fees
# Return Values:
# Function getDataRequestConsumer(bytes32 _requestId) external -> address
getDataRequestConsumer - get the consumer for a request
# Parameters:
_requestId
: bytes32 request id
# Return Values:
# Function getDataRequestProvider(bytes32 _requestId) external -> address
getDataRequestProvider - get the consumer for a request
# Parameters:
_requestId
: bytes32 request id
# Return Values:
# Function requestExists(bytes32 _requestId) external -> bool
requestExists - check a request ID exists
# Parameters:
_requestId
: bytes32 request id
# Function getRequestStatus(bytes32 _requestId) external -> uint8
getRequestStatus - check a request status 0 = does not exist/not yet initialised 1 = Request initialised
# Parameters:
_requestId
: bytes32 request id
# Function getProviderMinFee(address _provider) external -> uint256
getProviderMinFee - returns minimum fee provider will accept to fulfill data request
# Parameters:
_provider
: address of data provider
# Function getProviderGranularFee(address _provider, address _consumer) external -> uint256
getProviderGranularFee - returns fee provider will accept to fulfill data request for the given consumer
# Parameters:
_provider
: address of data provider_consumer
: address of consumer contract
# Function getWithdrawableTokens(address _provider) external -> uint256
getWithdrawableTokens - returns withdrawable tokens for the given provider
# Parameters:
_provider
: address of data provider
# Event DataRequested(address consumer, address provider, uint256 fee, bytes32 data, bytes32 requestId)
DataRequested. Emitted when a data request is sent by a Consumer.
# Parameters:
consumer
: address of the Consumer's contractprovider
: address of the data providerfee
: amount of xFUND paid for data requestdata
: data being requested
# Event RequestFulfilled(address consumer, address provider, bytes32 requestId, uint256 requestedData)
RequestFulfilled. Emitted when a provider fulfils a data request
# Parameters:
consumer
: address of the Consumer's contractprovider
: address of the data providerrequestId
: the request ID being fulfilled
# Event TokenSet(address tokenAddress)
TokenSet. Emitted once during contract construction
# Parameters:
# Event ProviderRegistered(address provider, uint256 minFee)
ProviderRegistered. Emitted when a provider registers
# Parameters:
# Event SetProviderMinFee(address provider, uint256 oldMinFee, uint256 newMinFee)
SetProviderMinFee. Emitted when a provider changes their minimum token fee for providing data
# Parameters:
# Event SetProviderGranularFee(address provider, address consumer, uint256 oldFee, uint256 newFee)
SetProviderGranularFee. Emitted when a provider changes their token fee for providing data to a selected consumer contract
# Parameters:
provider
: address of the providerconsumer
: address of the consumeroldFee
: old fee value
# Event WithdrawFees(address provider, address recipient, uint256 amount)
WithdrawFees. Emitted when a provider withdraws their accumulated fees
# Parameters:
provider
: address of the provider withdrawingrecipient
: address of the recipientamount
: uint256 amount being withdrawn
# Modifier paidSufficientFee(uint256 _feePaid, address _provider)
Reverts if amount is not at least what the provider has set as their min fee
# Parameters:
# Modifier hasAvailableTokens(uint256 _amount)
Reverts if amount requested is greater than withdrawable balance
# Parameters:
_amount
: The given amount to compare towithdrawableTokens