PriceProviderAggregatorPyth

Overview

License: MIT

contract PriceProviderAggregatorPyth is PriceProviderAggregator

The PriceProviderAggregatorPyth contract is the contract that provides the functionality of getting the latest price from PythNetwork.

Contract that provides the functionality of getting the latest price from PythNetwork. Inherit from PriceProviderAggregator.

Events info

SetPythPriceProvider

event SetPythPriceProvider(address indexed newPythPriceProvider)

Emitted when a new Pyth price provider is set.

State variables info

pythPriceProvider (0x5ea2a7a9)

address pythPriceProvider

Functions info

setPythPriceProvider (0x2ebccb0f)

function setPythPriceProvider(
    address newPythPriceProvider
) external onlyModerator

Sets PythPriceProvider contract.

Requirements:

  • The caller must be the moderator.

  • newPythPriceProvider must not be the zero address.

Parameters:

NameTypeDescription

newPythPriceProvider

address

The address of PythPriceProvider contract.

updatePrices (0x0aa9adbc)

function updatePrices(
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Performs a price update if the price is no longer valid.

Parameters:

NameTypeDescription

priceIds

bytes32[]

The priceIds need to update.

updateData

bytes[]

The updateData provided by PythNetwork.

getUpdatedPrice (0xe8ad2b23)

function getUpdatedPrice(
    address token,
    bytes[] calldata updateData
) external payable returns (uint256 priceMantissa, uint8 priceDecimals)

Returns the latest price of a given token in USD after update price if price provider is pythPriceProvider.

Parameters:

NameTypeDescription

token

address

The address of the token to get the price of.

updateData

bytes[]

The updateData provided by PythNetwork.

Return values:

NameTypeDescription

priceMantissa

uint256

The price of the token in USD, represented as a mantissa.

priceDecimals

uint8

The number of decimal places in the price of the token.

getExpiredPriceFeeds (0xe1f67b13)

function getExpiredPriceFeeds(
    address[] memory token,
    uint256 timeBeforeExpiration
) external view returns (bytes32[] memory priceIds, uint256 updateFee)

Returns the priceId array to update the price before expiration and the update fee.

Parameters:

NameTypeDescription

token

address[]

The address array of tokens needs to check if the price is about to expire.

timeBeforeExpiration

uint256

Time before expiration.

Return values:

NameTypeDescription

priceIds

bytes32[]

The priceId array needs to update the price.

updateFee

uint256

The update fee.

getEvaluationUnsafe (0xb03ec98d)

function getEvaluationUnsafe(
    address token,
    uint256 tokenAmount
) public view returns (uint256 evaluation)

Returns the evaluation of a given token amount based on the last updated price.

Parameters:

NameTypeDescription

token

address

The address of the token to evaluate.

tokenAmount

uint256

The amount of tokens to evaluate.

Return values:

NameTypeDescription

evaluation

uint256

The evaluation of the token amount.

Last updated