Facet #10: Price aggregator (does the requests to the Chainlink DON, takes the median, and executes callbacks)
constructor
initializePriceAggregator
function initializePriceAggregator(address _linkToken, contract IChainlinkFeed _linkUsdPriceFeed, uint24 _twapInterval, uint8 _minAnswers, address[] _nodes, bytes32[2] _jobIds, uint8[] _collateralIndices, struct IPriceAggregator.LiquidityPoolInput[] _gnsCollateralLiquidityPools, contract IChainlinkFeed[] _collateralUsdPriceFeeds) external
Initializes price aggregator facet
Parameters
updateLinkUsdPriceFeed
function updateLinkUsdPriceFeed(contract IChainlinkFeed _value) external
Updates LINK/USD chainlink price feed
Parameters
updateCollateralUsdPriceFeed
function updateCollateralUsdPriceFeed(uint8 _collateralIndex, contract IChainlinkFeed _value) external
Updates collateral/USD chainlink price feed
Parameters
updateCollateralGnsLiquidityPool
function updateCollateralGnsLiquidityPool(uint8 _collateralIndex, struct IPriceAggregator.LiquidityPoolInput _liquidityPoolInput) external
Updates collateral/GNS liquidity pool
Parameters
updateTwapInterval
function updateTwapInterval(uint24 _twapInterval) external
Updates TWAP interval
Parameters
updateMinAnswers
function updateMinAnswers(uint8 _value) external
Updates minimum answers count
Parameters
addOracle
function addOracle(address _a) external
Adds an oracle
Parameters
replaceOracle
function replaceOracle(uint256 _index, address _a) external
Replaces an oracle
Parameters
removeOracle
function removeOracle(uint256 _index) external
Removes an oracle
Parameters
setMarketJobId
function setMarketJobId(bytes32 _jobId) external
Updates market job id
Parameters
setLimitJobId
function setLimitJobId(bytes32 _jobId) external
Updates lookback job id
Parameters
getPrice
function getPrice(uint8 _collateralIndex, uint16 _pairIndex, struct ITradingStorage.Id _tradeId, struct ITradingStorage.Id _orderId, enum ITradingStorage.PendingOrderType _orderType, uint256 _positionSizeCollateral, uint256 _fromBlock) external virtual
Requests price from oracles
Parameters
fulfill
function fulfill(bytes32 _requestId, uint256 _priceData) external
Fulfills price request, called by chainlink oracles
Parameters
claimBackLink
function claimBackLink() external
Claims back LINK tokens, called by gov fund
getLinkFee
function getLinkFee(uint8 _collateralIndex, address _trader, uint16 _pairIndex, uint256 _positionSizeCollateral) external view returns (uint256)
Returns LINK fee for price request
Parameters
getCollateralPriceUsd
function getCollateralPriceUsd(uint8 _collateralIndex) external view returns (uint256)
Returns collateral/USD price
Parameters
getUsdNormalizedValue
function getUsdNormalizedValue(uint8 _collateralIndex, uint256 _collateralValue) external view returns (uint256)
Returns USD normalized value from collateral value
Parameters
getCollateralFromUsdNormalizedValue
function getCollateralFromUsdNormalizedValue(uint8 _collateralIndex, uint256 _normalizedValue) external view returns (uint256)
Returns collateral value (collateral precision) from USD normalized value
Parameters
getGnsPriceUsd
function getGnsPriceUsd(uint8 _collateralIndex) external view virtual returns (uint256)
Returns GNS/USD price based on GNS/collateral price
Parameters
getGnsPriceUsd
function getGnsPriceUsd(uint8 _collateralIndex, uint256 _gnsPriceCollateral) external view returns (uint256)
Returns GNS/USD price based on GNS/collateral price
Parameters
getGnsPriceCollateralIndex
function getGnsPriceCollateralIndex(uint8 _collateralIndex) external view virtual returns (uint256)
Returns GNS/collateral price
Parameters
getGnsPriceCollateralAddress
function getGnsPriceCollateralAddress(address _collateral) external view virtual returns (uint256)
Returns GNS/collateral price
Parameters
getLinkUsdPriceFeed
function getLinkUsdPriceFeed() external view returns (contract IChainlinkFeed)
Returns the link/usd price feed address
getTwapInterval
function getTwapInterval() external view returns (uint24)
Returns the twap interval in seconds
getMinAnswers
function getMinAnswers() external view returns (uint8)
Returns the minimum answers to execute an order and take the median
getMarketJobId
function getMarketJobId() external view returns (bytes32)
Returns the market job id
getLimitJobId
function getLimitJobId() external view returns (bytes32)
Returns the limit job id
getOracle
function getOracle(uint256 _index) external view returns (address)
Returns a specific oracle
Parameters
getOracles
function getOracles() external view returns (address[])
Returns all oracles
getCollateralGnsLiquidityPool
function getCollateralGnsLiquidityPool(uint8 _collateralIndex) external view returns (struct IPriceAggregator.LiquidityPoolInfo)
Returns collateral/gns liquidity pool info
Parameters
getCollateralUsdPriceFeed
function getCollateralUsdPriceFeed(uint8 _collateralIndex) external view returns (contract IChainlinkFeed)
Returns collateral/usd chainlink price feed
Parameters
getPriceAggregatorOrder
function getPriceAggregatorOrder(bytes32 _requestId) external view returns (struct IPriceAggregator.Order)
Returns order data
Parameters
getPriceAggregatorOrderAnswers
function getPriceAggregatorOrderAnswers(struct ITradingStorage.Id _orderId) external view returns (struct IPriceAggregator.OrderAnswer[])
Returns order data
Parameters
getChainlinkToken
function getChainlinkToken() external view returns (address)
Returns chainlink token address
getRequestCount
function getRequestCount() external view returns (uint256)
Returns requestCount (used by ChainlinkClientUtils)
getPendingRequest
function getPendingRequest(bytes32 _id) external view returns (address)
Returns pendingRequests mapping entry (used by ChainlinkClientUtils)