Skip to content

Commit

Permalink
QoL view functions for frontend (#104)
Browse files Browse the repository at this point in the history
* chore: adding QoL view functions

* fix: summing voting power

* chore: amending variable names to indicate func param
  • Loading branch information
RonTuretzky authored Oct 24, 2024
1 parent dbb2846 commit c05d3f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ButteredBread.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ contract ButteredBread is IButteredBread, ERC20VotesUpgradeable, OwnableUpgradea
revert NonDelegatable();
}

/// @notice Get the balance of a specific LP for a given account
/// @param _holder The address of the account to get the balance for
/// @param _lp The address of the LP to get the balance for
/// @return LPData memory The balance of the LP for the given account
function balanceOfLP(address _holder, address _lp) external view returns (LPData memory) {
return _accountToLPData[_holder][_lp];
}

/// @notice Deposit LP tokens and mint ButteredBread with corresponding LP scaling factor
function _deposit(address _account, address _lp, uint256 _amount) internal {
IERC20(_lp).transferFrom(_account, address(this), _amount);
Expand Down
9 changes: 9 additions & 0 deletions src/YieldDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ contract YieldDistributor is IYieldDistributor, OwnableUpgradeable {
);
}

/// @notice Get the current accumulated voting power for a user
/// @dev This is the voting power that has been accumulated since the last yield distribution
/// @param _account Address of the user to get the current accumulated voting power for
/// @return uint256 The current accumulated voting power for the user
function getCurrentAccumulatedVotingPower(address _account) public view returns (uint256) {
return this.getVotingPowerForPeriod(BUTTERED_BREAD, lastClaimedBlockNumber, block.number, _account)
+ this.getVotingPowerForPeriod(BREAD, lastClaimedBlockNumber, block.number, _account);
}

/**
* @notice Return the voting power for a specified user during a specified period of time
* @param _start Start time of the period to return the voting power for
Expand Down

0 comments on commit c05d3f9

Please sign in to comment.