ExchangeRateModel.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

struct ExchangeRateInfo {
 address exchangeRateModel,
 uint256 exchangeRate,
 uint256 maxSwingRate,
 uint256 maxSwingDuration
}

Anchor

struct Anchor {
 uint256 period,
 uint256 priceMantissa
}

SetPriceLocalVars

struct SetPriceLocalVars {
 struct Exponential.Exp price,
 struct Exponential.Exp swing,
 struct Exponential.Exp anchorPrice,
 uint256 anchorPeriod,
 uint256 currentPeriod,
 bool priceCapped,
 uint256 cappingAnchorPriceMantissa,
 uint256 pendingAnchorMantissa
}

Contract Members

Constants & Variables

bool public paused;
uint256 public constant numBlocksPerPeriod;
uint256 public constant maxSwingMantissa;
mapping(address => struct PriceOracle.ExchangeRateInfo) public exchangeRates;
mapping(address => struct Exponential.Exp) public _assetPrices;
address public anchorAdmin;
address public pendingAnchorAdmin;
address public poster;
struct Exponential.Exp public maxSwing;
mapping(address => struct PriceOracle.Anchor) public anchors;
mapping(address => uint256) public pendingAnchors;

Events

event OracleFailure(address  msgSender, address  asset, uint256  error, uint256  info, uint256  detail);
event NewPendingAnchor(address  anchorAdmin, address  asset, uint256  oldScaledPrice, uint256  newScaledPrice);
event SetExchangeRate(address  asset, address  exchangeRateModel, uint256  exchangeRate, uint256  maxSwingRate, uint256  maxSwingDuration);
event SetMaxSwingRate(address  asset, uint256  oldMaxSwingRate, uint256  newMaxSwingRate, uint256  maxSwingDuration);
event PricePosted(address  asset, uint256  previousPriceMantissa, uint256  requestedPriceMantissa, uint256  newPriceMantissa);
event CappedPricePosted(address  asset, uint256  requestedPriceMantissa, uint256  anchorPriceMantissa, uint256  cappedPriceMantissa);
event SetPaused(bool  newState);
event NewPendingAnchorAdmin(address  oldPendingAnchorAdmin, address  newPendingAnchorAdmin);
event NewAnchorAdmin(address  oldAnchorAdmin, address  newAnchorAdmin);
event NewPoster(address  oldPoster, address  newPoster);

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

function scale() external view
returns(uint256)

Arguments

getExchangeRate

function getExchangeRate() external view
returns(uint256)

Arguments

getMaxSwingRate

function getMaxSwingRate(uint256 interval) external view
returns(uint256)

Arguments

getFixedInterestRate

function getFixedInterestRate(uint256 interval) external view
returns(uint256)

Arguments

getFixedExchangeRate

function getFixedExchangeRate(uint256 interval) public view
returns(uint256)

Arguments

Do not pay into PriceOracle

function () public payable

Arguments

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

function failOracle(address asset, enum PriceOracle.OracleError err, enum PriceOracle.OracleFailureInfo info) internal nonpayable
returns(uint256)

Arguments

failOracleWithDetails

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

function failOracleWithDetails(address asset, enum PriceOracle.OracleError err, enum PriceOracle.OracleFailureInfo info, uint256 details) internal nonpayable
returns(uint256)

Arguments

_setPendingAnchor

provides ability to override the anchor price for an asset

function _setPendingAnchor(address asset, uint256 newScaledPrice) public nonpayable
returns(uint256)

Returns

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

Arguments

_setPaused

set paused to the specified state

function _setPaused(bool requestedState) public nonpayable
returns(uint256)

Returns

uint 0=success, otherwise a failure

Arguments

_setPendingAnchorAdmin

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

function _setPendingAnchorAdmin(address newPendingAnchorAdmin) public nonpayable
returns(uint256)

Returns

uint 0=success, otherwise a failure

Arguments

_acceptAnchorAdmin

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

function _acceptAnchorAdmin() public nonpayable
returns(uint256)

Returns

uint 0=success, otherwise a failure

Arguments

_setPoster

Set new poster.

function _setPoster(address newPoster) public nonpayable
returns(uint256)

Returns

uint 0=success, otherwise a failure

Arguments

setExchangeRate

set new exchange rate model

function setExchangeRate(address asset, address exchangeRateModel, uint256 maxSwingDuration) public nonpayable
returns(uint256)

Returns

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

Arguments

setMaxSwingRate

set new exchange rate maxSwingRate

function setMaxSwingRate(address asset, uint256 maxSwingDuration) public nonpayable
returns(uint256)

Returns

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

Arguments

assetPrices

retrieves price of an asset

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

Returns

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

Arguments

getPrice

retrieves price of an asset

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

Returns

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

Arguments

setPrice

entry point for updating prices

function setPrice(address asset, uint256 requestedPriceMantissa) public nonpayable
returns(uint256)

Returns

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

Arguments

setPriceInternal

function setPriceInternal(address asset, uint256 requestedPriceMantissa) internal nonpayable
returns(uint256)

Arguments

setPriceStorageInternal

function setPriceStorageInternal(address asset, uint256 priceMantissa) internal nonpayable

Arguments

calculateSwing

function calculateSwing(struct Exponential.Exp anchorPrice, struct Exponential.Exp price) internal pure
returns(enum ErrorReporter.Error, struct Exponential.Exp)

Arguments

capToMax

function capToMax(struct Exponential.Exp anchorPrice, struct Exponential.Exp price) internal view
returns(enum ErrorReporter.Error, bool, struct Exponential.Exp)

Arguments

setPrices

entry point for updating multiple prices

function setPrices(address[] assets, uint256[] requestedPriceMantissas) public nonpayable
returns(uint256[])

Returns

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

Arguments

Last updated