Skip to content

Commit

Permalink
natspec for the oracle registry and added a symbol function to get th…
Browse files Browse the repository at this point in the history
…e symbol of the oracles in the registry
  • Loading branch information
MrDeadCe11 committed Jul 24, 2024
1 parent ddd2e41 commit 762cdb1
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/contracts/oracles/OracleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ contract OracleRegistry is Authorizable, IOracleRegistry {
return address(usdDenominatedFeed[_token]) != address(0);
}

function symbol(address _token) public view returns (string memory _symbol) {
_symbol = usdDenominatedFeed[_token].symbol();
}

function _isValidOracle(address _oracle) internal view returns (bool) {
(, bytes memory _data) = _oracle.staticcall(abi.encodeWithSelector(IBaseOracle.symbol.selector));
return _data.length != 0;
Expand Down
63 changes: 61 additions & 2 deletions src/interfaces/oracles/IOracleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,73 @@ pragma solidity 0.8.26;
import {IBaseOracle} from '@interfaces/oracles/IBaseOracle.sol';

interface IOracleRegistry {
event OracleAdded(address _token, address denominatedChainlinkFeed);
// --- Events ---

/**
* @notice emmitted when an oracle is added to the registry
* @param _token the token that the oracle is giving the usd denominated price of
* @param _denominatedChainlinkFeed the address of the IBaseOracle
*/
event OracleAdded(address _token, address _denominatedChainlinkFeed);

/**
* @notice emitted when an oracle is deleted from the registry
* @param _token the token whose oracle was cleared
*/
event OracleCleared(address _token);

// --- Methods ---

/**
* @notice Returns an an IBaseOracle, denominated in usd, for getting the price of the input token
* @param _token the address of the token who's price you need
*/
function usdDenominatedFeed(address _token) external returns (IBaseOracle);

/**
* @notice Adds a single new oracle to the registry
* @param _token the address of the token who's oracle is being added
* @param _denominatedOracle the oracle being added
*/
function addOracle(address _token, IBaseOracle _denominatedOracle) external;
function addOracles(address[] memory _token, IBaseOracle[] memory _denominatedOracle) external;

/**
* @notice Adds a multiple new oracles to the registry
* @param _tokens the address of the token who's oracle is being added
* @param _denominatedOracles the oracles being added
*/
function addOracles(address[] memory _tokens, IBaseOracle[] memory _denominatedOracles) external;

/**
* @notice Deletes a single oracle in the registry
* @param _token the address of the token being removed
*/
function clearOracle(address _token) external;

/**
* @notice Fetch the latest oracle result and whether it is valid or not
* @param _token the address of the token who's result is being fetched
* @return _result , _validity the oracle result and a bool indicating whether the price is valid
*/
function getResultWithValidity(address _token) external returns (uint256 _result, bool _validity);

/**
* @notice Fetch the latest oracle result, reverts if invalid
* @param _token the address of the token who's result is being fetched
* @return _result
*/
function read(address _token) external returns (uint256 _result);

/**
* @notice Fetch the symbol of the token oracle
* @param _token the address of the token who's oracle you'd like the symbol of
* @return _symbol the oracle symbol
*/
function symbol(address _token) external view returns (string memory _symbol);

/**
* @notice find out if a token has an oracle in the registry
* @param _token the address of the token you'd like to check
*/
function isSupported(address _token) external view returns (bool);
}
4 changes: 2 additions & 2 deletions src/interfaces/oracles/pendle/IStandardizedYield.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ interface IStandardizedYield is IERC20Metadata {

/**
* @notice Calculates the a mount of tokens to be given for a potential share redemption
* @param tokenIn address of the token being claimed
* @param amountTokenToDeposit the amount of the shares to be redeemed
* @param tokenOut address of the token being claimed
* @param amountSharesToRedeem the amount of the shares to be redeemed
* @return amountTokenOut the amount of token you would get if this deposit was made
*/
function previewRedeem(address tokenOut, uint256 amountSharesToRedeem) external view returns (uint256 amountTokenOut);
Expand Down

0 comments on commit 762cdb1

Please sign in to comment.