diff --git a/src/ReservoirPriceOracle.sol b/src/ReservoirPriceOracle.sol index b60195a..d5afea1 100644 --- a/src/ReservoirPriceOracle.sol +++ b/src/ReservoirPriceOracle.sol @@ -8,7 +8,7 @@ import { OracleErrors } from "src/libraries/OracleErrors.sol"; import { IReservoirPriceOracle, OracleAverageQuery, - OracleLatestQuery, + OracleLatestQuery } from "src/interfaces/IReservoirPriceOracle.sol"; import { IPriceOracle } from "src/interfaces/IPriceOracle.sol"; import { QueryProcessor, ReservoirPair, PriceType } from "src/libraries/QueryProcessor.sol"; @@ -277,7 +277,7 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg. assembly { lSecondWord := sload(add(lSlot, 1)) } - address lThirdToken = lFirstWord.getThirdToken(lSecondWord); + address lThirdToken = lSecondWord.getThirdToken(); lResults[2] = lThirdToken; lResults[3] = aToken1; diff --git a/src/libraries/FlagsLib.sol b/src/libraries/FlagsLib.sol index a955e85..3d7ad57 100644 --- a/src/libraries/FlagsLib.sol +++ b/src/libraries/FlagsLib.sol @@ -47,12 +47,8 @@ library FlagsLib { pure returns (bytes32 rFirstWord, bytes32 rSecondWord) { - bytes32 lThirdTokenTop10Bytes = bytes32(bytes20(aThirdToken)) >> 176; - // Trim away the first 10 bytes since we only want the last 10 bytes. - bytes32 lThirdTokenBottom10Bytes = bytes32(bytes20(aThirdToken) << 80); - - rFirstWord = FLAG_3_HOP_ROUTE | bytes32(bytes20(aSecondToken)) >> 8 | lThirdTokenTop10Bytes; - rSecondWord = lThirdTokenBottom10Bytes; + rFirstWord = FLAG_3_HOP_ROUTE | bytes32(bytes20(aSecondToken)) >> 8; + rSecondWord = bytes20(aThirdToken); } function getPrice(bytes32 aData) internal pure returns (uint256 rPrice) { @@ -64,9 +60,7 @@ library FlagsLib { address(uint160(uint256(aData & 0x00ffffffffffffffffffffffffffffffffffffffff0000000000000000000000) >> 88)); } - function getThirdToken(bytes32 aFirstWord, bytes32 aSecondWord) internal pure returns (address rToken) { - bytes32 lTop10Bytes = (aFirstWord & 0x00000000000000000000000000000000000000000000ffffffffffffffffffff) << 80; - bytes32 lBottom10Bytes = aSecondWord >> 176; - rToken = address(uint160(uint256(lTop10Bytes | lBottom10Bytes))); + function getThirdToken(bytes32 aSecondWord) internal pure returns (address rToken) { + rToken = address(bytes20(aSecondWord)); } } diff --git a/test/unit/ReservoirPriceOracle.t.sol b/test/unit/ReservoirPriceOracle.t.sol index 6ec1f4d..00fa54d 100644 --- a/test/unit/ReservoirPriceOracle.t.sol +++ b/test/unit/ReservoirPriceOracle.t.sol @@ -5,12 +5,10 @@ import { BaseTest, console2, ReservoirPair, MintableERC20 } from "test/__fixture import { Utils } from "src/libraries/Utils.sol"; import { - Buffer, FixedPointMathLib, PriceType, OracleErrors, OracleLatestQuery, - OracleAccumulatorQuery, OracleAverageQuery, ReservoirPriceOracle, IERC20,