IOracleRelayer

Git Source

Inherits: IAuthorizable, IDisableable, IModifiable, IModifiablePerCollateral

Functions

safeEngine

The SAFEEngine is called to update the price of the collateral in the system

function safeEngine() external view returns (ISAFEEngine _safeEngine);

Returns

NameTypeDescription
_safeEngineISAFEEngineAddress of the contract that handles the state of the SAFEs

systemCoinOracle

The oracle used to fetch the system coin market price

function systemCoinOracle() external view returns (IBaseOracle _systemCoinOracle);

Returns

NameTypeDescription
_systemCoinOracleIBaseOracleAddress of the contract that provides the system coin price

params

Getter for the contract parameters struct

function params() external view returns (OracleRelayerParams memory _oracleRelayerParams);

Returns

NameTypeDescription
_oracleRelayerParamsOracleRelayerParamsAn OracleRelayerParams struct

_params

Getter for the unpacked contract parameters struct

function _params() external view returns (uint256 _redemptionRateUpperBound, uint256 _redemptionRateLowerBound);

Returns

NameTypeDescription
_redemptionRateUpperBounduint256Upper bound for the per-second redemption rate [ray]
_redemptionRateLowerBounduint256Lower bound for the per-second redemption rate [ray]

cParams

Getter for the collateral parameters struct

function cParams(bytes32 _cType) external view returns (OracleRelayerCollateralParams memory _oracleRelayerCParams);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_oracleRelayerCParamsOracleRelayerCollateralParamsAn OracleRelayerCollateralParams struct

_cParams

Getter for the unpacked collateral parameters struct

function _cParams(bytes32 _cType)
  external
  view
  returns (IBaseOracle _oracle, uint256 _safetyCRatio, uint256 _liquidationCRatio);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_oracleIBaseOracleUsually a DelayedOracle that enforces delays to fresh price feeds
_safetyCRatiouint256CRatio used to compute the 'safePrice' - the price used when generating debt in SAFEEngine [ray]
_liquidationCRatiouint256CRatio used to compute the 'liquidationPrice' - the price used when liquidating SAFEs [ray]

calcRedemptionPrice

View method to fetch the current redemption price

function calcRedemptionPrice() external view returns (uint256 _redemptionPrice);

Returns

NameTypeDescription
_redemptionPriceuint256The current calculated redemption price [ray]

marketPrice

The current system coin market price

function marketPrice() external view returns (uint256 _marketPrice);

Returns

NameTypeDescription
_marketPriceuint256The current system coin market price [ray]

redemptionRate

The redemption rate is the rate at which the redemption price changes over time

By changing the redemption rate, it changes the incentives of the system users

The redemption rate is a per-second rate [ray]

function redemptionRate() external view returns (uint256 _redemptionRate);

Returns

NameTypeDescription
_redemptionRateuint256The current updated redemption rate [ray]

redemptionPriceUpdateTime

Last time when the redemption price was changed

Used to calculate the current redemption price

function redemptionPriceUpdateTime() external view returns (uint256 _redemptionPriceUpdateTime);

Returns

NameTypeDescription
_redemptionPriceUpdateTimeuint256The last time when the redemption price was changed [unix timestamp]

redemptionPrice

Fetch the latest redemption price by first updating it

function redemptionPrice() external returns (uint256 _updatedPrice);

Returns

NameTypeDescription
_updatedPriceuint256The newly updated redemption price [ray]

updateCollateralPrice

Update the collateral price inside the system (inside SAFEEngine)

Usually called by a keeper, incentivized by the system to keep the prices up to date

function updateCollateralPrice(bytes32 _cType) external;

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

updateRedemptionRate

Update the system redemption rate, the rate at which the redemption price changes over time

Usually called by the PIDRateSetter

function updateRedemptionRate(uint256 _redemptionRate) external;

Parameters

NameTypeDescription
_redemptionRateuint256The newly calculated redemption rate [ray]

Events

UpdateRedemptionPrice

Emitted when the redemption price is updated

event UpdateRedemptionPrice(uint256 _redemptionPrice);

Parameters

NameTypeDescription
_redemptionPriceuint256The new redemption price [ray]

UpdateCollateralPrice

Emitted when a collateral type price is updated

event UpdateCollateralPrice(
  bytes32 indexed _cType, uint256 _priceFeedValue, uint256 _safetyPrice, uint256 _liquidationPrice
);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_priceFeedValueuint256The new collateral price [wad]
_safetyPriceuint256The new safety price [ray]
_liquidationPriceuint256The new liquidation price [ray]

UpdateRedemptionRate

Emitted when the redemption rate is updated

event UpdateRedemptionRate(uint256 _redemptionRate);

Parameters

NameTypeDescription
_redemptionRateuint256The new redemption rate [ray]

Errors

OracleRelayer_RedemptionPriceNotUpdated

Throws if the redemption price is not updated when updating the rate

error OracleRelayer_RedemptionPriceNotUpdated();

OracleRelayer_CollateralTypeAlreadyInitialized

Throws when trying to initialize a collateral type that is already initialized

error OracleRelayer_CollateralTypeAlreadyInitialized();

Structs

OracleRelayerParams

struct OracleRelayerParams {
  uint256 redemptionRateUpperBound;
  uint256 redemptionRateLowerBound;
}

OracleRelayerCollateralParams

struct OracleRelayerCollateralParams {
  IBaseOracle oracle;
  uint256 safetyCRatio;
  uint256 liquidationCRatio;
}