PriceAggregatorUtils
GNSPriceAggregator facet external library
initializePriceAggregator
function initializePriceAggregator(address _linkErc677, contract IChainlinkFeed _linkUsdPriceFeed, uint24 _twapInterval, uint8 _minAnswers, address[] _oracles, bytes32[2] _jobIds, uint8[] _collateralIndices, struct IPriceAggregator.LiquidityPoolInput[] _gnsCollateralLiquidityPools, contract IChainlinkFeed[] _collateralUsdPriceFeeds) external
Check IPriceAggregatorUtils interface for documentation
updateLinkUsdPriceFeed
function updateLinkUsdPriceFeed(contract IChainlinkFeed _value) public
Check IPriceAggregatorUtils interface for documentation
updateCollateralUsdPriceFeed
function updateCollateralUsdPriceFeed(uint8 _collateralIndex, contract IChainlinkFeed _value) public
Check IPriceAggregatorUtils interface for documentation
updateCollateralGnsLiquidityPool
function updateCollateralGnsLiquidityPool(uint8 _collateralIndex, struct IPriceAggregator.LiquidityPoolInput _liquidityPoolInput) public
Check IPriceAggregatorUtils interface for documentation
updateTwapInterval
function updateTwapInterval(uint24 _twapInterval) public
Check IPriceAggregatorUtils interface for documentation
updateMinAnswers
function updateMinAnswers(uint8 _value) public
Check IPriceAggregatorUtils interface for documentation
addOracle
function addOracle(address _a) public
Check IPriceAggregatorUtils interface for documentation
replaceOracle
function replaceOracle(uint256 _index, address _a) external
Check IPriceAggregatorUtils interface for documentation
removeOracle
function removeOracle(uint256 _index) external
Check IPriceAggregatorUtils interface for documentation
setMarketJobId
function setMarketJobId(bytes32 _jobId) public
Check IPriceAggregatorUtils interface for documentation
setLimitJobId
function setLimitJobId(bytes32 _jobId) public
Check IPriceAggregatorUtils interface for documentation
getPrice
function getPrice(uint8 _collateralIndex, uint16 _pairIndex, struct ITradingStorage.Id _tradeId, struct ITradingStorage.Id _orderId, enum ITradingStorage.PendingOrderType _orderType, uint256 _positionSizeCollateral, uint256 _fromBlock) external
Check IPriceAggregatorUtils interface for documentation
fulfill
function fulfill(bytes32 _requestId, uint256 _priceData) external
Check IPriceAggregatorUtils interface for documentation
claimBackLink
function claimBackLink() external
Check IPriceAggregatorUtils interface for documentation
getLinkFee
function getLinkFee(uint8 _collateralIndex, address _trader, uint16 _pairIndex, uint256 _positionSizeCollateral) public view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getCollateralPriceUsd
function getCollateralPriceUsd(uint8 _collateralIndex) public view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getUsdNormalizedValue
function getUsdNormalizedValue(uint8 _collateralIndex, uint256 _collateralValue) public view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getCollateralFromUsdNormalizedValue
function getCollateralFromUsdNormalizedValue(uint8 _collateralIndex, uint256 _normalizedValue) external view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getGnsPriceUsd
function getGnsPriceUsd(uint8 _collateralIndex) external view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getGnsPriceUsd
function getGnsPriceUsd(uint8 _collateralIndex, uint256 _gnsPriceCollateral) public view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getGnsPriceCollateralAddress
function getGnsPriceCollateralAddress(address _collateral) external view returns (uint256 _price)
Check IPriceAggregatorUtils interface for documentation
getGnsPriceCollateralIndex
function getGnsPriceCollateralIndex(uint8 _collateralIndex) public view returns (uint256 _price)
Check IPriceAggregatorUtils interface for documentation
getLinkUsdPriceFeed
function getLinkUsdPriceFeed() external view returns (contract IChainlinkFeed)
Check IPriceAggregatorUtils interface for documentation
getTwapInterval
function getTwapInterval() external view returns (uint24)
Check IPriceAggregatorUtils interface for documentation
getMinAnswers
function getMinAnswers() external view returns (uint8)
Check IPriceAggregatorUtils interface for documentation
getMarketJobId
function getMarketJobId() external view returns (bytes32)
Check IPriceAggregatorUtils interface for documentation
getLimitJobId
function getLimitJobId() external view returns (bytes32)
Check IPriceAggregatorUtils interface for documentation
getOracle
function getOracle(uint256 _index) external view returns (address)
Check IPriceAggregatorUtils interface for documentation
getOracles
function getOracles() external view returns (address[])
Check IPriceAggregatorUtils interface for documentation
getCollateralGnsLiquidityPool
function getCollateralGnsLiquidityPool(uint8 _collateralIndex) external view returns (struct IPriceAggregator.LiquidityPoolInfo)
Check IPriceAggregatorUtils interface for documentation
getCollateralUsdPriceFeed
function getCollateralUsdPriceFeed(uint8 _collateralIndex) external view returns (contract IChainlinkFeed)
Check IPriceAggregatorUtils interface for documentation
getPriceAggregatorOrder
function getPriceAggregatorOrder(bytes32 _requestId) external view returns (struct IPriceAggregator.Order)
Check IPriceAggregatorUtils interface for documentation
getPriceAggregatorOrderAnswers
function getPriceAggregatorOrderAnswers(struct ITradingStorage.Id _orderId) external view returns (struct IPriceAggregator.OrderAnswer[])
Check IPriceAggregatorUtils interface for documentation
getChainlinkToken
function getChainlinkToken() public view returns (address)
Check IPriceAggregatorUtils interface for documentation
getRequestCount
function getRequestCount() external view returns (uint256)
Check IPriceAggregatorUtils interface for documentation
getPendingRequest
function getPendingRequest(bytes32 _id) external view returns (address)
Check IPriceAggregatorUtils interface for documentation
_getSlot
function _getSlot() internal pure returns (uint256)
Returns storage slot to use when fetching storage relevant to library
_getStorage
function _getStorage() internal pure returns (struct IPriceAggregator.PriceAggregatorStorage s)
Returns storage pointer for storage struct in diamond contract, at defined slot
_getMultiCollatDiamond
function _getMultiCollatDiamond() internal view returns (contract IGNSMultiCollatDiamond)
Returns current address as multi-collateral diamond interface to call other facets functions.
validCollateralIndex
modifier validCollateralIndex(uint8 _collateralIndex)
Reverts if collateral index is not valid
_median
function _median(struct IPriceAggregator.OrderAnswer[] _array) internal pure returns (uint64)
returns median price of array (1 price only)
Parameters
_medianLookbacks
function _medianLookbacks(struct IPriceAggregator.OrderAnswer[] _array) internal pure returns (uint64 open, uint64 high, uint64 low)
returns median prices of array (open, high, low)
Parameters
_swap
function _swap(uint256[] _array, uint256 _i, uint256 _j) internal pure
swaps two elements in array
Parameters
_array
uint256[]
array of values
_i
uint256
index of first element
_j
uint256
index of second element
_sort
function _sort(uint256[] _array, uint256 begin, uint256 end) internal pure
sorts array of uint256 values
Parameters
_array
uint256[]
array of values
begin
uint256
start index
end
uint256
end index
_getCollateralPrecisionDelta
function _getCollateralPrecisionDelta(uint8 _collateralIndex) internal view returns (uint256)
Returns precision delta of collateral as uint256
Parameters
_collateralIndex
uint8
index of collateral
Last updated
Was this helpful?