NFT Price Oracle
Parallel requires NFT prices from an off chain Oracle. Currently we are using a customized Oracle implementation that consists of an off-chain client and an on-chain contract.
On-Chain (Contract)
The Parallel money market can make use of prices by interacting with the following contracts
Simple Contract Interface
Off-Chain (Client)
The off chain client collects NFT prices from various marketplaces to get a "Floor Price" this price is the lowest ask price that a NFT holder is willing to sell their asset.
The off-chain client collects these prices and uses them in the "pricing algorithm".
After the most recent values have been calculated we "conditionally write" the updates on chain.
A simplified visualization of the data can be seen below
Pricing Algorithm
Parallel uses a primary pricing metric to help stabilize the prices we report.
Time Weighted Average Price (TWAP)
Time Weighted Average Price
Where a_t
is the cumulative price at time t
, and t_2
is the time at time 2
. Currently we are using a time frame of 1440 minutes (24 hours) to calculate TWAP. The rational for this value can be seen on the research page
Conditional Write
In order to be responsive and optimize gas, we want to minimize the number of on chain updates possible. Therefore we only update the on chain prices conditionally, when at least one of the following statements are true:
New price timestamp must be later than the value on-chain
The last update was greater than or equal to 8 hours ago (EXPIRATION_PERIOD)
The current values deviate greater than 3% from the values stored on chain
Price Expiration
If EXPIRATION_PERIOD is reached for a price, any operation of the lending protocol such as borrowing or liquidating won't be allowed until a new valid price is fed.
Access Control
Currently our Oracle is controlled uses Role based access control to control the accounts that can make updates to the prices on chain. This role is only granted to a small set of highly secured accounts.
Resources
Last updated