Skip to content

Commit

Permalink
fix: addresses #1
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Dec 7, 2024
1 parent ddaca12 commit a098bb9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/ReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
// STORAGE //
///////////////////////////////////////////////////////////////////////////////////////////////

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

/// @notice The PriceOracle to call if this router is not configured for base/quote.
/// @dev If `address(0)` then there is no fallback.
address public fallbackOracle;

// The following 2 storage variables take up 1 storage slot.

/// @notice This number is multiplied by the base fee to determine the reward for keepers.
uint64 public rewardGasAmount;

/// @notice TWAP period (in seconds) for querying the oracle.
uint64 public twapPeriod;
uint16 public twapPeriod;

/// @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 @@ -67,7 +67,7 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
// CONSTRUCTOR, FALLBACKS //
///////////////////////////////////////////////////////////////////////////////////////////////

constructor(uint64 aTwapPeriod, uint64 aMultiplier, PriceType aType) {
constructor(uint16 aTwapPeriod, uint64 aMultiplier, PriceType aType) {
updateTwapPeriod(aTwapPeriod);
updateRewardGasAmount(aMultiplier);
PRICE_TYPE = aType;
Expand Down Expand Up @@ -452,7 +452,7 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
emit FallbackOracleSet(aFallbackOracle);
}

function updateTwapPeriod(uint64 aNewPeriod) public onlyOwner {
function updateTwapPeriod(uint16 aNewPeriod) public onlyOwner {
require(aNewPeriod != 0 && aNewPeriod <= Constants.MAX_TWAP_PERIOD, OracleErrors.InvalidTwapPeriod());

twapPeriod = aNewPeriod;
Expand Down
2 changes: 1 addition & 1 deletion test/__fixtures/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract BaseTest is Test {
using FactoryStoreLib for GenericFactory;

uint64 internal constant DEFAULT_REWARD_GAS_AMOUNT = 200_000;
uint64 internal constant DEFAULT_TWAP_PERIOD = 15 minutes;
uint16 internal constant DEFAULT_TWAP_PERIOD = 15 minutes;

GenericFactory internal _factory = new GenericFactory();
ReservoirPair internal _pair;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ReservoirPriceOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ contract ReservoirPriceOracleTest is BaseTest {

function testUpdateTwapPeriod(uint256 aNewPeriod) external {
// assume
uint64 lNewPeriod = uint64(bound(aNewPeriod, 1, 1 hours));
uint16 lNewPeriod = uint16(bound(aNewPeriod, 1, 1 hours));

// act
_oracle.updateTwapPeriod(lNewPeriod);
Expand Down Expand Up @@ -939,7 +939,7 @@ contract ReservoirPriceOracleTest is BaseTest {

function testUpdateTwapPeriod_InvalidTwapPeriod(uint256 aNewPeriod) external {
// assume
uint64 lNewPeriod = uint64(bound(aNewPeriod, 1 hours + 1, type(uint64).max));
uint16 lNewPeriod = uint16(bound(aNewPeriod, 1 hours + 1, type(uint16).max));

// act & assert
vm.expectRevert(OracleErrors.InvalidTwapPeriod.selector);
Expand Down

0 comments on commit a098bb9

Please sign in to comment.