Skip to content

Commit

Permalink
fix: make priceType immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Jun 14, 2024
1 parent 16d77f3 commit c95b6c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
16 changes: 5 additions & 11 deletions src/ReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
event SetPriceType(PriceType priceType);
event TwapPeriod(uint256 newPeriod);

/// @notice The type of price queried and stored, possibilities as defined by `PriceType`.
PriceType public immutable priceType;

Check warning on line 46 in src/ReservoirPriceOracle.sol

View workflow job for this annotation

GitHub Actions / lint

Immutable variables name are set to be in capitalized SNAKE_CASE

///////////////////////////////////////////////////////////////////////////////////////////////
// STORAGE //
///////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -50,7 +53,7 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
/// @dev If `address(0)` then there is no fallback.
address public fallbackOracle;

// The following 4 storage variables take up 1 storage slot.
// The following 3 storage variables take up 1 storage slot.

/// @notice percentage change greater than which, a price update may result in a reward payout of native tokens,
/// subject to availability of rewards.
Expand All @@ -63,10 +66,6 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
/// @notice TWAP period (in seconds) for querying the oracle
uint64 public twapPeriod;

// TODO: What's the use case for changing between price types? Should this be immutable or removed and one type be hardcoded?
/// @notice The type of price queried and stored, possibilities as defined by `PriceType`.
PriceType public priceType;

/// @notice Designated pairs to serve as price feed for a certain token0 and token1
mapping(address token0 => mapping(address token1 => ReservoirPair pair)) public pairs;

Expand All @@ -82,7 +81,7 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
updatePriceDeviationThreshold(aThreshold);
updateTwapPeriod(aTwapPeriod);
updateRewardGasAmount(aMultiplier);
setPriceType(aType);
priceType = aType;
}

/// @dev contract will hold native tokens to be distributed as gas bounty for updating the prices
Expand Down Expand Up @@ -526,11 +525,6 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
emit DesignatePair(aToken0, aToken1, ReservoirPair(address(0)));
}

function setPriceType(PriceType aType) public onlyOwner {
priceType = aType;
emit SetPriceType(aType);
}

// TODO: What's the use case for these vaults? Is it to price wrapped tokens
// without needing a market?
function setResolvedVault(address aVault, bool aSet) external onlyOwner {
Expand Down
6 changes: 0 additions & 6 deletions test/unit/ReservoirPriceOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,6 @@ contract ReservoirPriceOracleTest is BaseTest {
_oracle.updatePrice(address(_tokenB), address(_tokenC), address(0));
}

function setPriceType() external {
vm.prank(address(123));
vm.expectRevert("UNAUTHORIZED");
_oracle.setPriceType(PriceType.RAW_PRICE);
}

function testSetRoute_SameToken() external {
// arrange
address lToken0 = address(0x1);
Expand Down

0 comments on commit c95b6c1

Please sign in to comment.