Skip to content

Commit f036559

Browse files
authored
Merge pull request #11 from Gearbox-protocol/pricefeed-optimisation
fix: additional price feeds fixes and cleanup
2 parents 72d4aaf + be4031f commit f036559

File tree

11 files changed

+290
-439
lines changed

11 files changed

+290
-439
lines changed

contracts/oracles/LPPriceFeed.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ abstract contract LPPriceFeed is ILPPriceFeed, AbstractPriceFeed, ACLNonReentran
5555
/// @dev Returns upper-bounded LP token exhcange rate and its scale, reverts if rate falls below the lower bound
5656
/// @dev When computing LP token price, this MUST be used to get the exchange rate
5757
function _getValidatedLPExchangeRate() internal view returns (uint256 exchangeRate) {
58-
exchangeRate = _getLPExchangeRate();
58+
exchangeRate = getLPExchangeRate();
5959

6060
uint256 lb = lowerBound;
6161
if (exchangeRate < lb) revert ValueOutOfRangeException();
@@ -65,7 +65,7 @@ abstract contract LPPriceFeed is ILPPriceFeed, AbstractPriceFeed, ACLNonReentran
6565
}
6666

6767
/// @dev Returns LP token exchange rate, must be implemented by derived price feeds
68-
function _getLPExchangeRate() internal view virtual returns (uint256 exchangeRate);
68+
function getLPExchangeRate() public view virtual returns (uint256 exchangeRate);
6969

7070
/// @dev Computes upper bound as `lowerBound * (1 + delta)`
7171
function _upperBound(uint256 lb) internal view returns (uint256) {
@@ -84,7 +84,7 @@ abstract contract LPPriceFeed is ILPPriceFeed, AbstractPriceFeed, ACLNonReentran
8484
override
8585
controllerOnly // F:[LPF-4]
8686
{
87-
uint256 exchangeRate = _getLPExchangeRate();
87+
uint256 exchangeRate = getLPExchangeRate();
8888
if (newLowerBound == 0 || exchangeRate < newLowerBound || exchangeRate > _upperBound(newLowerBound)) {
8989
revert IncorrectLimitsException(); // F:[LPF-4]
9090
}
@@ -96,7 +96,7 @@ abstract contract LPPriceFeed is ILPPriceFeed, AbstractPriceFeed, ACLNonReentran
9696
/// @dev Derived price feeds MUST call this in the constructor after initializing all the
9797
/// state variables needed for exchange rate calculation
9898
function _initLimiter() internal {
99-
uint256 newLowerBound = _getLPExchangeRate();
99+
uint256 newLowerBound = getLPExchangeRate();
100100
lowerBound = newLowerBound;
101101
emit SetBounds(newLowerBound, _upperBound(newLowerBound));
102102
}

contracts/oracles/SingleAssetLPPriceFeed.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ abstract contract SingleAssetLPPriceFeed is LPPriceFeed {
4040
returns (uint80, int256 answer, uint256, uint256 updatedAt, uint80)
4141
{
4242
(answer, updatedAt) = _getValidatedPrice(priceFeed, stalenessPeriod, skipCheck); // F:[OCLP-6]
43-
answer = int256((_getValidatedLPExchangeRate() * uint256(answer)) / _getScale()); // F: [OAPF-3]
43+
answer = int256((_getValidatedLPExchangeRate() * uint256(answer)) / getScale()); // F: [OAPF-3]
4444
return (0, answer, 0, updatedAt, 0);
4545
}
4646

4747
/// @dev Returns LP token exchange rate scale, must be implemented by derived price feeds
48-
function _getScale() internal view virtual returns (uint256 scale);
48+
function getScale() public view virtual returns (uint256 scale);
4949
}

contracts/oracles/aave/WrappedAaveV2PriceFeed.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ contract WrappedAaveV2PriceFeed is SingleAssetLPPriceFeed {
2020
_initLimiter();
2121
}
2222

23-
function _getLPExchangeRate() internal view override returns (uint256) {
23+
function getLPExchangeRate() public view override returns (uint256) {
2424
return IWrappedATokenV2(lpToken).exchangeRate();
2525
}
2626

27-
function _getScale() internal pure override returns (uint256) {
27+
function getScale() public pure override returns (uint256) {
2828
return WAD;
2929
}
3030
}

contracts/oracles/balancer/BPTStablePriceFeed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ contract BPTStablePriceFeed is LPPriceFeed {
106106
return (0, answer, 0, updatedAt, 0);
107107
}
108108

109-
function _getLPExchangeRate() internal view override returns (uint256) {
109+
function getLPExchangeRate() public view override returns (uint256) {
110110
return IBalancerStablePool(lpToken).getRate();
111111
}
112112
}

0 commit comments

Comments
 (0)