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.

updateMultiFinalPricesWithUpdatePrice (0x2a92f7f1)

function updateMultiFinalPricesWithUpdatePrice(
    address[] memory token,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Calculates and update multiple the final TWAP prices of a token after update price.

Parameters:

NameTypeDescription

token

address[]

The token array needs to update the price.

priceIds

bytes32[]

The priceIds need to update.

updateData

bytes[]

The updateData provided by PythNetwork.

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 (0xb876879d)

function getUpdatedPrice(
    address token,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
)
    external
    payable
    returns (
        uint8 priceDecimals,
        uint64 timestamp,
        uint256 collateralPrice,
        uint256 capitalPrice
    )

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.

priceIds

bytes32[]

The priceIds need to update price.

updateData

bytes[]

The updateData provided by PythNetwork.

Return values:

NameTypeDescription

priceDecimals

uint8

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

timestamp

uint64

The timestamp of the price.

collateralPrice

uint256

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

capitalPrice

uint256

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

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.

Last updated