Skip to content

Commit

Permalink
add natspec and sections
Browse files Browse the repository at this point in the history
  • Loading branch information
danoctavian committed Sep 17, 2024
1 parent db424e5 commit aedbbd9
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/ynEIGEN/ynEigenViewer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import {IEigenStrategyManager} from "../interfaces/IEigenStrategyManager.sol";
contract ynEigenViewer {

//--------------------------------------------------------------------------------------
//---------------------------------- ERRORS ------------------------------------------
//---------------------------------- STRUCTS -----------------------------------------
//--------------------------------------------------------------------------------------

error ArrayLengthMismatch(uint256 expected, uint256 actual);

struct AssetInfo {
address asset;
Expand All @@ -28,6 +26,23 @@ contract ynEigenViewer {
uint256 totalBalanceInUnitOfAccount;
uint256 totalBalanceInAsset;
}

//--------------------------------------------------------------------------------------
//---------------------------------- ERRORS ------------------------------------------
//--------------------------------------------------------------------------------------

error ArrayLengthMismatch(uint256 expected, uint256 actual);

//--------------------------------------------------------------------------------------
//---------------------------------- CONSTANTS ---------------------------------------
//--------------------------------------------------------------------------------------

uint256 public constant DECIMALS = 1_000_000;
uint256 public constant UNIT = 1 ether;

//--------------------------------------------------------------------------------------
//---------------------------------- VARIABLES ---------------------------------------
//--------------------------------------------------------------------------------------

/* solhint-disable immutable-vars-naming */
AssetRegistry public immutable assetRegistry;
Expand All @@ -36,8 +51,9 @@ contract ynEigenViewer {
IRateProvider public immutable rateProvider;
/* solhint-enable immutable-vars-naming */

uint256 public constant DECIMALS = 1_000_000;
uint256 public constant UNIT = 1 ether;
//--------------------------------------------------------------------------------------
//---------------------------------- INITIALIZATION ----------------------------------
//--------------------------------------------------------------------------------------

constructor(address _assetRegistry, address _ynEIGEN, address _tokenStakingNodesManager, address _rateProvider) {
assetRegistry = AssetRegistry(_assetRegistry);
Expand All @@ -46,16 +62,26 @@ contract ynEigenViewer {
rateProvider = IRateProvider(_rateProvider);
}

/**
* @notice Retrieves all staking nodes from the TokenStakingNodesManager
* @dev This function calls the getAllNodes() function of the tokenStakingNodesManager contract
* @return An array of ITokenStakingNode interfaces representing all staking nodes
*/
function getAllStakingNodes() external view returns (ITokenStakingNode[] memory) {
return tokenStakingNodesManager.getAllNodes();
}

/**
* @notice Retrieves information about all assets in the ynEigen system
* @dev This function fetches asset data from the asset registry and ynEigen system
* and computes various metrics for each asset
* @return _assetsInfo An array of AssetInfo structs containing detailed information about each asset
*/
function getYnEigenAssets() external view returns (AssetInfo[] memory _assetsInfo) {
IERC20[] memory _assets = assetRegistry.getAssets();
uint256 _assetsLength = _assets.length;
_assetsInfo = new AssetInfo[](_assetsLength);


uint256[] memory assetBalances = assetRegistry.getAllAssetBalances();
// Assert that the lengths of _assets and assetBalances are the same
if (_assetsLength != assetBalances.length) {
Expand Down

0 comments on commit aedbbd9

Please sign in to comment.