@@ -10,22 +10,23 @@ import {PriceFeedType} from "@gearbox-protocol/sdk/contracts/PriceFeedType.sol";
1010
1111// EXCEPTIONS
1212import {
13- ZeroAddressException, NotImplementedException
14- } from "@gearbox-protocol/core-v2/contracts/interfaces/IErrors.sol " ;
13+ ZeroAddressException,
14+ NotImplementedException
15+ } from "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol " ;
1516
1617/// @title CurveLP pricefeed for 4 assets
1718contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
1819 /// @dev Price feed of coin 0 in the pool
19- AggregatorV3Interface public immutable priceFeed1;
20+ address public immutable priceFeed1;
2021
2122 /// @dev Price feed of coin 1 in the pool
22- AggregatorV3Interface public immutable priceFeed2;
23+ address public immutable priceFeed2;
2324
2425 /// @dev Price feed of coin 2 in the pool
25- AggregatorV3Interface public immutable priceFeed3;
26+ address public immutable priceFeed3;
2627
2728 /// @dev Price feed of coin 3 in the pool
28- AggregatorV3Interface public immutable priceFeed4;
29+ address public immutable priceFeed4;
2930
3031 PriceFeedType public constant override priceFeedType = PriceFeedType.CURVE_4LP_ORACLE;
3132
@@ -38,15 +39,12 @@ contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
3839 address _priceFeed4 ,
3940 string memory _description
4041 ) AbstractCurveLPPriceFeed (addressProvider, _curvePool, _description) {
41- if (
42- _priceFeed1 == address (0 ) || _priceFeed2 == address (0 ) || _priceFeed3 == address (0 )
43- || _priceFeed4 == address (0 )
44- ) revert ZeroAddressException ();
45-
46- priceFeed1 = AggregatorV3Interface (_priceFeed1); // F:[OCLP-1]
47- priceFeed2 = AggregatorV3Interface (_priceFeed2); // F:[OCLP-1]
48- priceFeed3 = AggregatorV3Interface (_priceFeed3); // F:[OCLP-1]
49- priceFeed4 = AggregatorV3Interface (_priceFeed4); // F:[OCLP-1]
42+ if (_priceFeed1 == address (0 ) || _priceFeed2 == address (0 )) revert ZeroAddressException ();
43+
44+ priceFeed1 = _priceFeed1; // F:[OCLP-1]
45+ priceFeed2 = _priceFeed2; // F:[OCLP-1]
46+ priceFeed3 = _priceFeed3; // F:[OCLP-1]
47+ priceFeed4 = _priceFeed4; // F:[OCLP-1]
5048 }
5149
5250 /// @dev Returns the USD price of the pool's LP token
@@ -57,19 +55,35 @@ contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
5755 view
5856 override
5957 returns (uint80 roundId , int256 answer , uint256 startedAt , uint256 updatedAt , uint80 answeredInRound )
58+ {
59+ (roundId, answer, startedAt, updatedAt, answeredInRound) = getAnswer (); // F:[OCLP-2]
60+
61+ uint256 virtualPrice = curvePool.get_virtual_price ();
62+
63+ // Checks that virtual_priceis in limits
64+ virtualPrice = _checkAndUpperBoundValue (virtualPrice); // F: [OCLP-7]
65+
66+ answer = (answer * int256 (virtualPrice)) / decimalsDivider; // F:[OCLP-4]
67+ }
68+
69+ function getAnswer ()
70+ internal
71+ view
72+ returns (uint80 roundId , int256 answer , uint256 startedAt , uint256 updatedAt , uint80 answeredInRound )
6073 {
6174 uint80 roundIdA;
6275 int256 answerA;
6376 uint256 startedAtA;
6477 uint256 updatedAtA;
6578 uint80 answeredInRoundA;
6679
67- (roundId, answer, startedAt, updatedAt, answeredInRound) = priceFeed1.latestRoundData (); // F:[OCLP-6]
80+ (roundId, answer, startedAt, updatedAt, answeredInRound) = AggregatorV3Interface ( priceFeed1) .latestRoundData (); // F:[OCLP-6]
6881
6982 // Sanity check for chainlink pricefeed
7083 _checkAnswer (roundId, answer, updatedAt, answeredInRound);
7184
72- (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) = priceFeed2.latestRoundData (); // F:[OCLP-6]
85+ (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) =
86+ AggregatorV3Interface (priceFeed2).latestRoundData (); // F:[OCLP-6]
7387
7488 // Sanity check for chainlink pricefeed
7589 _checkAnswer (roundIdA, answerA, updatedAtA, answeredInRoundA);
@@ -82,7 +96,12 @@ contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
8296 answeredInRound = answeredInRoundA;
8397 } // F:[OCLP-6]
8498
85- (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) = priceFeed3.latestRoundData (); // F:[OCLP-6]
99+ if (priceFeed3 == address (0 )) {
100+ return (roundId, answer, startedAt, updatedAt, answeredInRound);
101+ }
102+
103+ (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) =
104+ AggregatorV3Interface (priceFeed3).latestRoundData (); // F:[OCLP-6]
86105
87106 // Sanity check for chainlink pricefeed
88107 _checkAnswer (roundIdA, answerA, updatedAtA, answeredInRoundA);
@@ -95,7 +114,12 @@ contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
95114 answeredInRound = answeredInRoundA;
96115 } // F:[OCLP-6]
97116
98- (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) = priceFeed4.latestRoundData (); // F:[OCLP-6]
117+ if (priceFeed4 == address (0 )) {
118+ return (roundId, answer, startedAt, updatedAt, answeredInRound);
119+ }
120+
121+ (roundIdA, answerA, startedAtA, updatedAtA, answeredInRoundA) =
122+ AggregatorV3Interface (priceFeed4).latestRoundData (); // F:[OCLP-6]
99123
100124 // Sanity check for chainlink pricefeed
101125 _checkAnswer (roundIdA, answerA, updatedAtA, answeredInRoundA);
@@ -107,12 +131,5 @@ contract CurveLP4PriceFeed is AbstractCurveLPPriceFeed {
107131 updatedAt = updatedAtA;
108132 answeredInRound = answeredInRoundA;
109133 } // F:[OCLP-6]
110-
111- uint256 virtualPrice = curvePool.get_virtual_price ();
112-
113- // Checks that virtual_priceis in limits
114- virtualPrice = _checkAndUpperBoundValue (virtualPrice); // F: [OCLP-7]
115-
116- answer = (answer * int256 (virtualPrice)) / decimalsDivider; // F:[OCLP-4]
117134 }
118135}
0 commit comments