NFTFloorOracle

Offchain clients can update the prices in this contract. The public can read prices aggeregate prices which are not expired from different feeders, if number of valid/unexpired prices not enough, we do not aggeregate and just use previous price

AssetAdded

event AssetAdded(address asset)

AssetRemoved

event AssetRemoved(address asset)

AssetDataSet

event AssetDataSet(address asset, uint256 price, uint256 lastUpdated)

OracleNodesSet

event OracleNodesSet(address[] nodes)

OracleConfigSet

event OracleConfigSet(uint128 expirationPeriod, uint128 maxPriceDeviation)

OracleNftPaused

event OracleNftPaused(address asset, bool paused)

UPDATER_ROLE

bytes32 UPDATER_ROLE

priceMap

mapping(address => struct PriceInformation) priceMap

Aggregated price with address

feeders

address[] feeders

All feeders

nfts

address[] nfts

All asset list

priceFeederMap

mapping(address => struct FeederRegistrar) priceFeederMap

Original raw value to aggregate with

config

struct OracleConfig config

storage for oracle configurations

whenNotPaused

modifier whenNotPaused(address _nftContract)

onlyWhenKeyExisted

modifier onlyWhenKeyExisted(address _nftContract)

onlyWhenKeyNotExisted

modifier onlyWhenKeyNotExisted(address _nftContract)

_whenNotPaused

function _whenNotPaused(address _nftContract) internal view

setPause

function setPause(address _nftContract, bool val) external

_isExistedKey

function _isExistedKey(address _nftContract) internal view returns (bool)

_addAsset

function _addAsset(address _nftContract) internal

_removeAsset

function _removeAsset(address _nftContract) internal

addAssets

function addAssets(address[] _nftContracts) external

removeAsset

function removeAsset(address _nftContract) external

_addAssets

function _addAssets(address[] assets) internal

set nft assets.

Parameters

NameTypeDescription

assets

address[]

assets to set

initialize

function initialize(address admin, address[] updaters, address[] assets) public

Allow contract creator to set admin and first updater

Parameters

NameTypeDescription

admin

address

The admin who can change roles

updaters

address[]

The initial updaters

assets

address[]

The initial nft assets

_setConfig

function _setConfig(uint128 _expirationPeriod, uint128 _maxPriceDeviation) internal

set oracle configs

Parameters

NameTypeDescription

_expirationPeriod

uint128

only prices not expired will be aggregated with

_maxPriceDeviation

uint128

use to reject when price increase/decrease rate more than this value

_setOracles

function _setOracles(address[] nodes) internal

set oracles.

Parameters

NameTypeDescription

nodes

address[]

feeders to set

setOracles

function setOracles(address[] nodes) external

Allows owner to change oracles.

Parameters

NameTypeDescription

nodes

address[]

feeders to set

setConfig

function setConfig(uint64 expirationPeriod, uint128 maxPriceDeviation) external

Allows owner to update oracle configs

_checkValidityOfPrice

function _checkValidityOfPrice(address _nftContract, uint256 _price) internal view returns (bool)

setPrice

function setPrice(address token, uint256 twap) public

Allows updater to set new price on PriceInformation and updates the internal TWAP cumulativePrice.

Parameters

NameTypeDescription

token

address

The nft contracts to set a floor price for

twap

uint256

The last floor twap

_finalizePrice

function _finalizePrice(address token, uint256 twap) internal

_addRawValue

function _addRawValue(address token, uint256 twap) internal

_combine

function _combine(address token, uint256 twap) internal view returns (bool, uint256)

setMultiplePrices

function setMultiplePrices(address[] tokens, uint256[] twaps) external

Allows owner to set new price on PriceInformation and updates the internal TWAP cumulativePrice.

Parameters

NameTypeDescription

tokens

address[]

The nft contract to set a floor price for

twaps

uint256[]

getTwap

function getTwap(address token) external view returns (uint256 twap)

Parameters

NameTypeDescription

token

address

The nft contract

Return Values

NameTypeDescription

twap

uint256

The most recent twap on chain

getLastUpdateTime

function getLastUpdateTime(address token) external view returns (uint256 timestamp)

Parameters

NameTypeDescription

token

address

The nft contract

Return Values

NameTypeDescription

timestamp

uint256

The timestamp of the last update for an asset

_quickSort

function _quickSort(uint256[] arr, int256 left, int256 right) internal pure