NFT Oracles

A price oracle is any tool used to view price information about a given asset.

While many oracle designs on Ethereum (as well as on BSC and HECO) have been implemented to provide data for fungible token prices, few attempts have been made to construct a price oracle for NFTs.

NFTs are generally less frequently traded, therefore creating the difficuilty for third parties to observe and retrieve price data. To solve this problem, we need the following two things (this only works for NFTs that have been traded for more than once, otherwise it does not have a price History):

Record NFT's Traded Price History

contract GameItem is ERC721 {
    uint256 public lastTradedPrice;
    uint256 [] public priceHistory;
    //...
}

As long as the last traded price can be stored on chain, we can proceed to the next step.

Time-Weighted Average Prices (TWAPs)

We can add last traded price to a single cumulative-price variable in the core contract weighted by the amount of time this price existed. This variable represents a sum of the price for every second in the entire history of the contract.

With such data, we can then calculate TWAP using the following formula:

Conclusion

While NFTs are quite new to the market, we believe it is necessary and useful to have a price oracle that can make the price history of NFTs more transparent and easier to predict. The above solution may not be perfect, and we welcome everyone to give this problem a thought.

Last updated