PythOracle

PythOracle

PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores the updated prices from external sources

Solidity API

struct TokenConfig {
  bytes32 pythId;
  address asset;
  uint64 maxStalePeriod;
}

EXP_SCALE

Exponent scale (decimal precision) of prices

uint256 EXP_SCALE

BNB_ADDR

Set this as asset address for BNB. This is the underlying for vBNB

address BNB_ADDR

underlyingPythOracle

The actual pyth oracle address fetch & store the prices

contract IPyth underlyingPythOracle

tokenConfigs

Token configs by asset address

mapping(address => struct PythOracle.TokenConfig) tokenConfigs

constructor

Constructor for the implementation contract.

constructor() public

initialize

Initializes the owner of the contract and sets required contracts

function initialize(address underlyingPythOracle_, address accessControlManager_) external

Parameters

NameTypeDescription

underlyingPythOracle_

address

Address of the Pyth oracle

accessControlManager_

address

Address of the access control manager contract


setTokenConfigs

Batch set token configs

function setTokenConfigs(struct PythOracle.TokenConfig[] tokenConfigs_) external

Parameters

NameTypeDescription

tokenConfigs_

struct PythOracle.TokenConfig[]

Token config array

⛔️ Access Requirements

  • Only Governance

❌ Errors

  • Zero length error is thrown if length of the array in parameter is 0


setUnderlyingPythOracle

Set the underlying Pyth oracle contract address

function setUnderlyingPythOracle(contract IPyth underlyingPythOracle_) external

Parameters

NameTypeDescription

underlyingPythOracle_

contract IPyth

Pyth oracle contract address

📅 Events

  • Emits PythOracleSet event with address of Pyth oracle.

⛔️ Access Requirements

  • Only Governance

❌ Errors

  • NotNullAddress error thrown if underlyingPythOracle_ address is zero


setTokenConfig

Set single token config. maxStalePeriod cannot be 0 and asset cannot be a null address

function setTokenConfig(struct PythOracle.TokenConfig tokenConfig) public

Parameters

NameTypeDescription

tokenConfig

struct PythOracle.TokenConfig

Token config struct

⛔️ Access Requirements

  • Only Governance

❌ Errors

  • Range error is thrown if max stale period is zero

  • NotNullAddress error is thrown if asset address is null


getPrice

Gets the price of a asset from the pyth oracle

function getPrice(address asset) public view returns (uint256)

Parameters

NameTypeDescription

asset

address

Address of the asset

Return Values

NameTypeDescription

[0]

uint256

Price in USD


Last updated