Skip to content

Commit

Permalink
don't use associated functions when the operation is not associated
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverNChalk committed Jul 7, 2024
1 parent b3ee4b2 commit d67540c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.

int256 lDiff = lData.getDecimalDifference();

lData = lDiff.packSimplePrice(aNewPrice);
lData = FlagsLib.packSimplePrice(lDiff, aNewPrice);
assembly {
sstore(lSlot, lData)
}
Expand Down Expand Up @@ -513,7 +513,7 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.

int256 lDiff = int256(lToken1Decimals) - int256(lToken0Decimals);

bytes32 lData = lDiff.packSimplePrice(0);
bytes32 lData = FlagsLib.packSimplePrice(lDiff, 0);
assembly {
// Write data to storage.
sstore(lSlot, lData)
Expand All @@ -525,12 +525,12 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg.
address lThirdToken = aRoute[2];

if (lRouteLength == 3) {
bytes32 lData = lSecondToken.pack2HopRoute();
bytes32 lData = FlagsLib.pack2HopRoute(lSecondToken);
assembly {
sstore(lSlot, lData)
}
} else if (lRouteLength == 4) {
(bytes32 lFirstWord, bytes32 lSecondWord) = lSecondToken.pack3HopRoute(lThirdToken);
(bytes32 lFirstWord, bytes32 lSecondWord) = FlagsLib.pack3HopRoute(lSecondToken, lThirdToken);

// Write two words to storage.
assembly {
Expand Down
1 change: 1 addition & 0 deletions src/libraries/FlagsLib.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// REVIEW: Rename `FlagsLib` -> `RoutesLib` as all operations are routes related?
library FlagsLib {
bytes32 public constant FLAG_UNINITIALIZED = bytes32(hex"00");
bytes32 public constant FLAG_SIMPLE_PRICE = bytes32(hex"01");
Expand Down

0 comments on commit d67540c

Please sign in to comment.