OracleFeed

Git Source

Author: luoyhang003

Abstract contract for oracle price feeds. Provides a standard interface for retrieving asset prices.

This contract is meant to be inherited by specific oracle implementations that define the logic for fetching asset prices.

State Variables

token

The token address associated with this oracle feed.

Immutable after deployment to ensure the oracle is tied to a specific token.

address public immutable token;

name

The human-readable name of the oracle feed.

Can be used for UI or off-chain identification purposes.

string public name;

Functions

constructor

Sets the token address and feed name during deployment.

constructor(address _token, string memory _name);

Parameters

NameTypeDescription
_tokenaddressThe address of the token this oracle is associated with.
_namestringThe descriptive name for this oracle feed.

peek

Returns the current price of the specified asset.

Implementations must override this function to provide actual price logic.

function peek() external view virtual returns (uint256 price_);

Returns

NameTypeDescription
price_uint256The price of the asset with 18 decimals of precision.