Oracle Contract
Attention: Follow the examples carefully. It is recommended that you first test and deploy your code on Testnet before using the Pricing Sylo on Mainnet.
The Oracle contract is one half of a pricing system that allows users to request up-to-date token price data. The Pricing Sylo employs a hybrid on-chain/off-chain architecture through the Oracle contract and Pricing Daemon. The Pricing Daemon aggregates token data from multiple sources and relays that information through the Oracle contract. To get accurate price data users will request the Pricing Daemon’s service via the Oracle contract and pay in SYLO token. The price data is then written on-chain to the Oracle contract and becomes widely available for all those who require it. However, as time passes this data will become dated and need updating.
Core Functionality
The Oracle contract has three main functions:
- Accepts token price requests from users who have deposited SYLO tokens
- Allows authorised responders (Pricing Daemon) to provide price data for those requests
- Maintains a record of the latest price for each token
User Flow
- User deposits SYLO tokens using the
deposit
function
Note that this requires the Oracle contract to be approved for the specified amount before the call. When using the monitor both the approve and deposit functions will cost SYLOs, in addition to the actual deposit, so expect that the total SYLOs spent will slightly exceed the specific deposit amount.
- User requests price data with
createRequest
orcreateRequests
(batch) - Pricing Daemon will provide price data via
createResponse
- Users can query responses with
getResponse
or get the latest token price viagetLatestData
As per the interface below createRequest/createRequests
will return the request ID/IDs that correlate to the most recent requests made. Users will find it useful to store this ID value to use as the argument to getResponse
which will return the latest token data, as requested by the user.
Another useful aspect to note is that the latest requestId
is publicly available. With this information, a user can take advantage of the latest token data without making a request themselves. Simply query for the latest requestId
and include this value as the argument to getResponse
.
Deployments
Pricing Sylo Monitor deployments can be found at the following URL.
Monitor URL | Chain |
---|---|
https://pricing.sylo.io/ | Mainnet |
Pricing Sylo Oracle deployments can be found at the following contract addresses.
Chain | Contract address |
---|---|
Root Mainnet | 0xA1C10036F5398601f34d11F0be7Da26a8875Fb0d |
Root Porcini (Testnet) | 0xf459E82138096876C25cd5fbc54c487476640619 |
To start using the Pricing Sylo, you will need to use the following interface.
Here is an example of how to use the interface.
Data structures
- Request: Stores token ID, timestamp of the block when the request was processed, and processed status
- Response: Stores timestamp of the block when the response was processed, token price value, and request ID
Was this page helpful?