Skip to content

Commit 951b716

Browse files
committed
feat: replace ACLTrait with Ownable in LPPriceFeed and update contract types
1 parent 1145591 commit 951b716

34 files changed

+104
-144
lines changed

contracts/oracles/BoundedPriceFeed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract BoundedPriceFeed is IPriceFeed, SanityCheckTrait, PriceFeedValidationTr
1717
using LibString for bytes32;
1818

1919
uint256 public constant override version = 3_10;
20-
bytes32 public constant override contractType = "PF_BOUNDED_ORACLE";
20+
bytes32 public constant override contractType = "PRICE_FEED::BOUNDED";
2121

2222
uint8 public constant override decimals = 8; // U:[BPF-2]
2323
bool public constant override skipPriceCheck = true; // U:[BPF-2]

contracts/oracles/CompositePriceFeed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ contract CompositePriceFeed is IPriceFeed, PriceFeedValidationTrait, SanityCheck
1616
using LibString for bytes32;
1717

1818
uint256 public constant override version = 3_10;
19-
bytes32 public constant override contractType = "PF_COMPOSITE_ORACLE";
19+
bytes32 public constant override contractType = "PRICE_FEED::COMPOSITE";
2020

2121
uint8 public constant override decimals = 8; // U:[CPF-2]
2222
bool public constant override skipPriceCheck = true; // U:[CPF-2]

contracts/oracles/LPPriceFeed.sol

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
// (c) Gearbox Foundation, 2024.
44
pragma solidity ^0.8.23;
55

6-
import {ILPPriceFeed} from "../interfaces/ILPPriceFeed.sol";
6+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
77
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
8-
import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol";
8+
9+
import {IUpdatablePriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IPriceFeed.sol";
910
import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol";
10-
import {ACLTrait} from "@gearbox-protocol/core-v3/contracts/traits/ACLTrait.sol";
1111
import {PriceFeedValidationTrait} from "@gearbox-protocol/core-v3/contracts/traits/PriceFeedValidationTrait.sol";
12-
import {IUpdatablePriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IPriceFeed.sol";
12+
import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol";
13+
14+
import {ILPPriceFeed} from "../interfaces/ILPPriceFeed.sol";
1315

1416
/// @dev Window size in bps, used to compute upper bound given lower bound
1517
uint256 constant WINDOW_SIZE = 200;
@@ -25,7 +27,7 @@ uint256 constant UPDATE_BOUNDS_COOLDOWN = 1 days;
2527
/// It is assumed that the price of an LP token is the product of its exchange rate and some aggregate function
2628
/// of underlying tokens prices. This contract simplifies creation of such price feeds and provides standard
2729
/// validation of the LP token exchange rate that protects against price manipulation.
28-
abstract contract LPPriceFeed is ILPPriceFeed, ACLTrait, SanityCheckTrait, PriceFeedValidationTrait {
30+
abstract contract LPPriceFeed is ILPPriceFeed, Ownable, SanityCheckTrait, PriceFeedValidationTrait {
2931
/// @notice Answer precision (always 8 decimals for USD price feeds)
3032
uint8 public constant override decimals = 8; // U:[LPPF-2]
3133

@@ -42,16 +44,16 @@ abstract contract LPPriceFeed is ILPPriceFeed, ACLTrait, SanityCheckTrait, Price
4244
uint256 public override lowerBound;
4345

4446
/// @notice Constructor
45-
/// @param _acl Address of the ACL contract
47+
/// @param _owner Owner of the price feed that can update exchange rate bounds
4648
/// @param _lpToken LP token for which the prices are computed
4749
/// @param _lpContract LP contract (can be different from LP token)
4850
/// @dev Derived price feeds must call `_setLimiter` in their constructor after
4951
/// initializing all state variables needed for exchange rate calculation
50-
constructor(address _acl, address _lpToken, address _lpContract)
51-
ACLTrait(_acl) // U:[LPPF-1]
52+
constructor(address _owner, address _lpToken, address _lpContract)
5253
nonZeroAddress(_lpToken) // U:[LPPF-1]
5354
nonZeroAddress(_lpContract) // U:[LPPF-1]
5455
{
56+
transferOwnership(_owner); // U:[LPPF-1]
5557
lpToken = _lpToken; // U:[LPPF-1]
5658
lpContract = _lpContract; // U:[LPPF-1]
5759
}
@@ -106,7 +108,7 @@ abstract contract LPPriceFeed is ILPPriceFeed, ACLTrait, SanityCheckTrait, Price
106108
function setLimiter(uint256 newLowerBound)
107109
external
108110
override
109-
configuratorOnly // U:[LPPF-6]
111+
onlyOwner // U:[LPPF-6]
110112
{
111113
_setLimiter(newLowerBound); // U:[LPPF-6]
112114
}

contracts/oracles/SingleAssetLPPriceFeed.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ abstract contract SingleAssetLPPriceFeed is LPPriceFeed {
1414
uint32 public immutable stalenessPeriod;
1515
bool public immutable skipCheck;
1616

17-
constructor(address _acl, address _lpToken, address _lpContract, address _priceFeed, uint32 _stalenessPeriod)
18-
LPPriceFeed(_acl, _lpToken, _lpContract) // U:[SAPF-1]
17+
constructor(address _owner, address _lpToken, address _lpContract, address _priceFeed, uint32 _stalenessPeriod)
18+
LPPriceFeed(_owner, _lpToken, _lpContract) // U:[SAPF-1]
1919
nonZeroAddress(_priceFeed) // U:[SAPF-1]
2020
{
2121
priceFeed = _priceFeed; // U:[SAPF-1]

contracts/oracles/ZeroPriceFeed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {IPriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IP
99
/// @notice Always returns zero price as answer
1010
contract ZeroPriceFeed is IPriceFeed {
1111
uint256 public constant override version = 3_10;
12-
bytes32 public constant override contractType = "PF_ZERO_ORACLE";
12+
bytes32 public constant override contractType = "PRICE_FEED::ZERO";
1313

1414
uint8 public constant override decimals = 8; // U:[ZPF-1]
1515
string public constant override description = "Zero price feed"; // U:[ZPF-1]

contracts/oracles/balancer/BPTStablePriceFeed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {IBalancerStablePool} from "../../interfaces/balancer/IBalancerStablePool
1212
/// @dev Similarly to Curve stableswap, aggregate function is minimum of underlying tokens prices
1313
contract BPTStablePriceFeed is LPPriceFeed {
1414
uint256 public constant override version = 3_10;
15-
bytes32 public constant override contractType = "PF_BALANCER_STABLE_LP_ORACLE";
15+
bytes32 public constant override contractType = "PRICE_FEED::BALANCER_STABLE";
1616

1717
uint8 public immutable numAssets;
1818

@@ -36,8 +36,8 @@ contract BPTStablePriceFeed is LPPriceFeed {
3636
uint32 public immutable stalenessPeriod4;
3737
bool public immutable skipCheck4;
3838

39-
constructor(address _acl, uint256 lowerBound, address _balancerPool, PriceFeedParams[5] memory priceFeeds)
40-
LPPriceFeed(_acl, _balancerPool, _balancerPool) // U:[BAL-S-1]
39+
constructor(address _owner, uint256 lowerBound, address _balancerPool, PriceFeedParams[5] memory priceFeeds)
40+
LPPriceFeed(_owner, _balancerPool, _balancerPool) // U:[BAL-S-1]
4141
nonZeroAddress(priceFeeds[0].priceFeed) // U:[BAL-S-2]
4242
nonZeroAddress(priceFeeds[1].priceFeed) // U:[BAL-S-2]
4343
{

contracts/oracles/balancer/BPTWeightedPriceFeed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ contract BPTWeightedPriceFeed is LPPriceFeed {
3232
using FixedPoint for uint256;
3333

3434
uint256 public constant override version = 3_10;
35-
bytes32 public constant override contractType = "PF_BALANCER_WEIGHTED_LP_ORACLE";
35+
bytes32 public constant override contractType = "PRICE_FEED::BALANCER_WEIGHTED";
3636

3737
/// @notice Balancer vault address
3838
address public immutable vault;
@@ -96,8 +96,8 @@ contract BPTWeightedPriceFeed is LPPriceFeed {
9696
uint256 immutable scale6;
9797
uint256 immutable scale7;
9898

99-
constructor(address _acl, uint256 lowerBound, address _vault, address _pool, PriceFeedParams[] memory priceFeeds)
100-
LPPriceFeed(_acl, _pool, _pool) // U:[BAL-W-1]
99+
constructor(address _owner, uint256 lowerBound, address _vault, address _pool, PriceFeedParams[] memory priceFeeds)
100+
LPPriceFeed(_owner, _pool, _pool) // U:[BAL-W-1]
101101
nonZeroAddress(_vault) // U:[BAL-W-1]
102102
nonZeroAddress(priceFeeds[0].priceFeed) // U:[BAL-W-2]
103103
nonZeroAddress(priceFeeds[1].priceFeed) // U:[BAL-W-2]

contracts/oracles/curve/CurveCryptoLPPriceFeed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contract CurveCryptoLPPriceFeed is LPPriceFeed {
1818
using FixedPoint for uint256;
1919

2020
uint256 public constant override version = 3_10;
21-
bytes32 public constant override contractType = "PF_CURVE_CRYPTO_LP_ORACLE";
21+
bytes32 public constant override contractType = "PRICE_FEED::CURVE_CRYPTO";
2222

2323
uint16 public immutable nCoins;
2424

@@ -34,8 +34,8 @@ contract CurveCryptoLPPriceFeed is LPPriceFeed {
3434
uint32 public immutable stalenessPeriod2;
3535
bool public immutable skipCheck2;
3636

37-
constructor(address _acl, uint256 lowerBound, address _token, address _pool, PriceFeedParams[3] memory priceFeeds)
38-
LPPriceFeed(_acl, _token, _pool) // U:[CRV-C-1]
37+
constructor(address _owner, uint256 lowerBound, address _token, address _pool, PriceFeedParams[3] memory priceFeeds)
38+
LPPriceFeed(_owner, _token, _pool) // U:[CRV-C-1]
3939
nonZeroAddress(priceFeeds[0].priceFeed) // U:[CRV-C-2]
4040
nonZeroAddress(priceFeeds[1].priceFeed) // U:[CRV-C-2]
4141
{

contracts/oracles/curve/CurveStableLPPriceFeed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {WAD} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol";
1313
/// @dev Older pools may be decoupled from their LP token, so constructor accepts both token and pool
1414
contract CurveStableLPPriceFeed is LPPriceFeed {
1515
uint256 public constant override version = 3_10;
16-
bytes32 public constant override contractType = "PF_CURVE_STABLE_LP_ORACLE";
16+
bytes32 public constant override contractType = "PRICE_FEED::CURVE_STABLE";
1717

1818
uint16 public immutable nCoins;
1919

@@ -33,8 +33,8 @@ contract CurveStableLPPriceFeed is LPPriceFeed {
3333
uint32 public immutable stalenessPeriod3;
3434
bool public immutable skipCheck3;
3535

36-
constructor(address _acl, uint256 lowerBound, address _token, address _pool, PriceFeedParams[4] memory priceFeeds)
37-
LPPriceFeed(_acl, _token, _pool) // U:[CRV-S-1]
36+
constructor(address _owner, uint256 lowerBound, address _token, address _pool, PriceFeedParams[4] memory priceFeeds)
37+
LPPriceFeed(_owner, _token, _pool) // U:[CRV-S-1]
3838
nonZeroAddress(priceFeeds[0].priceFeed) // U:[CRV-S-2]
3939
nonZeroAddress(priceFeeds[1].priceFeed) // U:[CRV-S-2]
4040
{

contracts/oracles/curve/CurveUSDPriceFeed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import {WAD} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol";
1313
/// is reused. Particularly, the same bounding mechanism is applied to the pool exchange rate.
1414
contract CurveUSDPriceFeed is SingleAssetLPPriceFeed {
1515
uint256 public constant override version = 3_10;
16-
bytes32 public constant override contractType = "PF_CURVE_USD_ORACLE";
16+
bytes32 public constant override contractType = "PRICE_FEED::CURVE_USD";
1717

1818
constructor(
19-
address _acl,
19+
address _owner,
2020
uint256 lowerBound,
2121
address _crvUSD,
2222
address _pool,
2323
address _priceFeed,
2424
uint32 _stalenessPeriod
2525
)
26-
SingleAssetLPPriceFeed(_acl, _crvUSD, _pool, _priceFeed, _stalenessPeriod) // U:[CRV-D-1]
26+
SingleAssetLPPriceFeed(_owner, _crvUSD, _pool, _priceFeed, _stalenessPeriod) // U:[CRV-D-1]
2727
{
2828
_setLimiter(lowerBound); // U:[CRV-D-1]
2929
}

0 commit comments

Comments
 (0)