From 017a1b7f3f7d92caee3786813fbb67fcda6e9640 Mon Sep 17 00:00:00 2001 From: Brean0 Date: Wed, 13 Dec 2023 20:22:23 -0600 Subject: [PATCH] generalize gpPerBdv --- .../sun/SeasonFacet/SeasonGettersFacet.sol | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/protocol/contracts/beanstalk/sun/SeasonFacet/SeasonGettersFacet.sol b/protocol/contracts/beanstalk/sun/SeasonFacet/SeasonGettersFacet.sol index b9c940460c..8fb2dc1596 100644 --- a/protocol/contracts/beanstalk/sun/SeasonFacet/SeasonGettersFacet.sol +++ b/protocol/contracts/beanstalk/sun/SeasonFacet/SeasonGettersFacet.sol @@ -192,13 +192,37 @@ contract SeasonGettersFacet { return uint256(s.seedGauge.lastStalkGrowthUpdate).add(ONE_WEEK); } + /** + * @notice returns the Gauge Points per BDV for a given token. + * @param token The token to get the Gauge Points per BDV for. + */ + function getGaugePointsPerBdvForToken(address token) public view returns (uint256) { + if (token == C.BEAN) { + return getBeanGaugePointsPerBdv(); + } else { + return getGaugePointsPerBdvForWell(token); + } + } + + /** + * gets the Gauge Points per BDV for a given well. + * @param well + */ + function getGaugePointsPerBdvForWell(address well) public view returns (uint256) { + if(LibWell.isWell(well)) { + uint256 wellGaugePoints = s.ss[well].gaugePoints; + uint256 wellDepositedBdv = s.siloBalances[well].depositedBdv; + return wellGaugePoints.mul(LibGauge.BDV_PRECISION).div(wellDepositedBdv); + } else { + revert ("Token not supported"); + } + } + /** * @notice calculates the BEANETH Gauge Points (GP) per BDV. */ function getBeanEthGaugePointsPerBdv() public view returns (uint256) { - uint256 beanEthGaugePoints = s.ss[C.BEAN_ETH_WELL].gaugePoints; - uint256 beanEthDepositedBdv = s.siloBalances[C.BEAN_ETH_WELL].depositedBdv; - return beanEthGaugePoints.mul(LibGauge.BDV_PRECISION).div(beanEthDepositedBdv); + return getGaugePointsPerBdvForWell(C.BEAN_ETH_WELL); } /**