Skip to content

Commit

Permalink
feat: add reserveBalanceOf
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Jan 15, 2025
1 parent e49dc3e commit 63d501f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/interfaces/IXToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ interface IXToken {
**/
function pool() external view returns (address);

/**
* @dev Returns the reserve balance of the user that is backing the xTokens.
* @param user The user whose balance is calculated
* @return The reserve balance of the user
**/
function reserveBalanceOf(address user) external view returns (uint256);

/**
* @dev Returns the reserve total supply of the token.
* @return The reserve total supply
**/
function totalReserveSupply() external view returns (uint256);

/**
* @dev Mints `amount` xTokens to `account`
* @param account The address receiving the minted tokens
Expand Down
18 changes: 18 additions & 0 deletions src/protocol/xToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ contract xToken is IXToken, ERC20, ERC20Permit {
pool = msg.sender;
}

/**
* @notice Returns the reserve balance of an account
* @dev This balance is independent of the asset price and represents the user's share of the reserve tokens in the pool
* @param account The address of the account
* @return The reserve balance of the account
*/
function reserveBalanceOf(address account) public view returns (uint256) {
return _reserveBalances[account];
}

/**
* @notice Returns the total reserve supply
* @return The total reserve supply of tokens
*/
function totalReserveSupply() public view returns (uint256) {
return _totalReserveSupply;
}

/**
* @notice Mints new tokens to an account
* @dev Only callable by the pool contract
Expand Down

0 comments on commit 63d501f

Please sign in to comment.