PriceOracle.sol

View Source: contracts/test/PriceOracle.sol

↗ Extends: Exponential

Enums

OracleError

enum OracleError {
 NO_ERROR,
 UNAUTHORIZED,
 FAILED_TO_SET_PRICE
}

OracleFailureInfo

enum OracleFailureInfo {
 ACCEPT_ANCHOR_ADMIN_PENDING_ANCHOR_ADMIN_CHECK,
 SET_PAUSED_OWNER_CHECK,
 SET_PENDING_ANCHOR_ADMIN_OWNER_CHECK,
 SET_PENDING_ANCHOR_PERMISSION_CHECK,
 SET_PRICE_CALCULATE_SWING,
 SET_PRICE_CAP_TO_MAX,
 SET_PRICE_MAX_SWING_CHECK,
 SET_PRICE_NO_ANCHOR_PRICE_OR_INITIAL_PRICE_ZERO,
 SET_PRICE_PERMISSION_CHECK,
 SET_PRICE_ZERO_PRICE,
 SET_PRICES_PARAM_VALIDATION,
 SET_PRICE_IS_READER_ASSET
}

Structs

ExchangeRateInfo

Anchor

SetPriceLocalVars

Contract Members

Constants & Variables

Events

Functions

  • scale()

  • getExchangeRate()

  • getMaxSwingRate(uint256 interval)

  • getFixedInterestRate(uint256 interval)

  • getFixedExchangeRate(uint256 interval)

  • ()

  • failOracle(address asset, enum PriceOracle.OracleError err, enum PriceOracle.OracleFailureInfo info)

  • failOracleWithDetails(address asset, enum PriceOracle.OracleError err, enum PriceOracle.OracleFailureInfo info, uint256 details)

  • _setPendingAnchor(address asset, uint256 newScaledPrice)

  • _setPaused(bool requestedState)

  • _setPendingAnchorAdmin(address newPendingAnchorAdmin)

  • _acceptAnchorAdmin()

  • _setPoster(address newPoster)

  • setExchangeRate(address asset, address exchangeRateModel, uint256 maxSwingDuration)

  • setMaxSwingRate(address asset, uint256 maxSwingDuration)

  • assetPrices(address asset)

  • getPrice(address asset)

  • setPrice(address asset, uint256 requestedPriceMantissa)

  • setPriceInternal(address asset, uint256 requestedPriceMantissa)

  • setPriceStorageInternal(address asset, uint256 priceMantissa)

  • calculateSwing(struct Exponential.Exp anchorPrice, struct Exponential.Exp price)

  • capToMax(struct Exponential.Exp anchorPrice, struct Exponential.Exp price)

  • setPrices(address[] assets, uint256[] requestedPriceMantissas)

scale

Arguments

Name

Type

Description

getExchangeRate

Arguments

Name

Type

Description

getMaxSwingRate

Arguments

Name

Type

Description

interval

uint256

getFixedInterestRate

Arguments

Name

Type

Description

interval

uint256

getFixedExchangeRate

Arguments

Name

Type

Description

interval

uint256

Do not pay into PriceOracle

Arguments

Name

Type

Description

failOracle

use this when reporting a known error from the price oracle or a non-upgradeable collaborator Using Oracle in name because we already inherit a fail function from ErrorReporter.sol via Exponential.sol

Arguments

Name

Type

Description

asset

address

err

enum PriceOracle.OracleError

info

enum PriceOracle.OracleFailureInfo

failOracleWithDetails

Use this when reporting an error from the Alkemi Earn Verified. Give the Alkemi Earn Verified result as details

Arguments

Name

Type

Description

asset

address

err

enum PriceOracle.OracleError

info

enum PriceOracle.OracleFailureInfo

details

uint256

_setPendingAnchor

provides ability to override the anchor price for an asset

Returns

uint 0=success, otherwise a failure (see enum OracleError for details)

Arguments

Name

Type

Description

asset

address

Asset for which to override the anchor price

newScaledPrice

uint256

New anchor price

_setPaused

set paused to the specified state

Returns

uint 0=success, otherwise a failure

Arguments

Name

Type

Description

requestedState

bool

value to assign to paused

_setPendingAnchorAdmin

Begins transfer of anchor admin rights. The newPendingAnchorAdmin must call _acceptAnchorAdmin to finalize the transfer.

Returns

uint 0=success, otherwise a failure

Arguments

Name

Type

Description

newPendingAnchorAdmin

address

New pending anchor admin.

_acceptAnchorAdmin

Accepts transfer of anchor admin rights. msg.sender must be pendingAnchorAdmin

Returns

uint 0=success, otherwise a failure

Arguments

Name

Type

Description

_setPoster

Set new poster.

Returns

uint 0=success, otherwise a failure

Arguments

Name

Type

Description

newPoster

address

New poster.

setExchangeRate

set new exchange rate model

Returns

uint 0=success, otherwise a failure (see enum OracleError for details)

Arguments

Name

Type

Description

asset

address

asset for which to set the exchangeRateModel

exchangeRateModel

address

exchangeRateModel address, if the exchangeRateModel is address(0), cancel the exchangeRates

maxSwingDuration

uint256

maxSwingDuration uint, Is a value greater than zero and less than a second of a week

setMaxSwingRate

set new exchange rate maxSwingRate

Returns

uint 0=success, otherwise a failure (see enum OracleError for details)

Arguments

Name

Type

Description

asset

address

asset for which to set the exchange rate maxSwingRate

maxSwingDuration

uint256

Interval time

assetPrices

retrieves price of an asset

Returns

uint mantissa of asset price (scaled by 1e18) or zero if unset or contract paused

Arguments

Name

Type

Description

asset

address

Asset for which to get the price

getPrice

retrieves price of an asset

Returns

uint mantissa of asset price (scaled by 1e18) or zero if unset or contract paused

Arguments

Name

Type

Description

asset

address

Asset for which to get the price

setPrice

entry point for updating prices

Returns

uint 0=success, otherwise a failure (see enum OracleError for details)

Arguments

Name

Type

Description

asset

address

Asset for which to set the price

requestedPriceMantissa

uint256

requested new price, scaled by 10**18

setPriceInternal

Arguments

Name

Type

Description

asset

address

requestedPriceMantissa

uint256

setPriceStorageInternal

Arguments

Name

Type

Description

asset

address

priceMantissa

uint256

calculateSwing

Arguments

Name

Type

Description

anchorPrice

struct Exponential.Exp

price

struct Exponential.Exp

capToMax

Arguments

Name

Type

Description

anchorPrice

struct Exponential.Exp

price

struct Exponential.Exp

setPrices

entry point for updating multiple prices

Returns

uint values in same order as inputs. For each: 0=success, otherwise a failure (see enum OracleError for details)

Arguments

Name

Type

Description

assets

address[]

a list of up to assets for which to set a price. required: 0 < assets.length == requestedPriceMantissas.length

requestedPriceMantissas

uint256[]

requested new prices for the assets, scaled by 10**18. required: 0 < assets.length == requestedPriceMantissas.length

Last updated

Was this helpful?