PriceOracle
Overview
License: MIT
Structs info
GovernedPrice
PriceInfo
Events info
PriceUpdated
Emitted when the price of a token is updated.
Parameters:
token
address
The address of the token.
GrantModeratorRole
Emitted when the moderator role is granted to a new address.
Parameters:
newModerator
address
The address of the new moderator.
RevokeModeratorRole
Emitted when the moderator role is revoked from an address.
Parameters:
moderator
address
The address of the moderator to be revoked.
SetVolatilityCapFixedPercent
Emitted when the new volatilityCapFixedPercent value is set.
Parameters:
tvcUp
uint16
The new tvcUp value.
tvcDown
uint16
The new tvcDown value.
SetPriceProviderAggregator
Emitted when the PriceProviderAggregator contract is set.
Parameters:
newPriceProviderAggregator
address
The address of PriceProviderAggregator contract.
Constants info
MODERATOR_ROLE (0x797669c9)
PERCENTAGE_DECIMALS (0x90706425)
SECONDS_PER_HOUR (0x4df86126)
State variables info
priceProviderAggregator (0x407e906e)
tokenPriceDecimals (0x7420b62b)
tvcUp (0x465d98a3)
The up time-based volatility cap (TVC-up) in percentage.
tvcDown (0x8e8a4131)
The down time-based volatility cap (TVC-down) in percentage.
mostGovernedPrice (0x086dc126)
Used in volatility cap rule calculations. Mapping address of token => GovernedPrice
priceInfo (0x6d048d53)
The final price after update price by calcFinalPrices function. Mapping address of token => PriceInfo.
Modifiers info
onlyAdmin
Modifier to restrict access to functions to only the contract's admin.
onlyModerator
Modifier to restrict access to functions to only the contract's moderator.
Functions info
initialize (0x1c4b995a)
Initializes the contract by setting up the access control roles and assigning them to the contract deployer. The DEFAULT_ADMIN_ROLE
and MODERATOR_ROLE
roles are set up with the contract deployer as the initial role bearer. tokenPriceDecimals
is set to 10.
Parameters:
_priceProviderAggregator
address
The address of PriceProviderAggregator contract.
_tvcUp
uint16
The tvcUp value.
_tvcDown
uint16
The tvcDown value.
grantModerator (0x6981c7ae)
Grants the moderator role to a new address.
Parameters:
newModerator
address
The address of the new moderator.
revokeModerator (0x36445636)
Revokes the moderator role from an address.
Parameters:
moderator
address
The address of the moderator to be revoked.
setPriceProviderAggregator (0x5ff22c42)
Set the price provider aggregator contract address
Requirements:
The caller must be the moderator.
newPriceProviderAggregator
cannot be the zero address.
Parameters:
newPriceProviderAggregator
address
The address of the new price provider aggregator contract
setVolatilityCapFixedPercent (0x079957a9)
Set the volatility cap fixed percent
Requirements:
The caller must be the moderator.
_volatilityCapFixedPercent
cannot be greater PERCENTAGE_DECIMALS.
Parameters:
_tvcUp
uint16
The new tvcUp value
_tvcDown
uint16
The new tvcDown value
updateFinalPrices (0x8bb6b7f9)
Calculates the final TWAP prices of a token.
Parameters:
token
address
The address of the token.
getUpdatedReportedPrice (0x41f2231a)
price = priceMantissa / (10 ** priceDecimals)
returns tuple (priceMantissa, priceDecimals) after update price.
Parameters:
token
address
the address of token which price is to return
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
getMostTWAPprice (0xbc124cfd)
Returns the most recent TWAP price of a token.
Parameters:
token
address
The address of the token.
Return values:
priceDecimals
uint8
The decimals of the price.
timestamp
uint64
The last updated timestamp of the price.
collateralPrice
uint256
The collateral price of the token.
capitalPrice
uint256
The capital price of the token.
getEstimatedTWAPprice (0x29f839b2)
Returns the non-TWAP price of a token.
Parameters:
token
address
The address of the token.
Return values:
priceDecimals
uint8
The decimals of the price.
timestamp
uint64
The last updated timestamp of the price.
collateralPrice
uint256
The collateral price of the token.
capitalPrice
uint256
The capital price of the token.
getEvaluation (0x81fd01ea)
returns the most TWAP price in USD evaluation of token by its tokenAmount
Parameters:
token
address
the address of token to evaluate
tokenAmount
uint256
the amount of token to evaluate
Return values:
collateralEvaluation
uint256
the USD evaluation of token by its tokenAmount
in collateral price
capitalEvaluation
uint256
the USD evaluation of token by its tokenAmount
in capital price
getEstimatedEvaluation (0xebb19c1a)
returns the estimated-TWAP price in USD evaluation of token by its tokenAmount
Parameters:
token
address
the address of token to evaluate
tokenAmount
uint256
the amount of token to evaluate
Return values:
collateralEvaluation
uint256
the USD evaluation of token by its tokenAmount
in collateral price
capitalEvaluation
uint256
the USD evaluation of token by its tokenAmount
in capital price
getReportedPrice (0xdbd57337)
price = priceMantissa / (10 ** priceDecimals)
returns tuple (priceMantissa, priceDecimals)
Parameters:
token
address
the address of token which price is to return
Last updated