From ac9ffd1cbc91e5eb9c6e7e2a94ad33009413d17a Mon Sep 17 00:00:00 2001 From: Dan Liu Date: Sun, 27 Mar 2022 23:30:10 +0800 Subject: [PATCH] remove uniswapFactory in UniswapPairPriceAdapter --- .../integration/oracles/UniswapPairPriceAdapter.sol | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/contracts/protocol/integration/oracles/UniswapPairPriceAdapter.sol b/contracts/protocol/integration/oracles/UniswapPairPriceAdapter.sol index cc7c70e2b..0997f021d 100644 --- a/contracts/protocol/integration/oracles/UniswapPairPriceAdapter.sol +++ b/contracts/protocol/integration/oracles/UniswapPairPriceAdapter.sol @@ -60,27 +60,21 @@ contract UniswapPairPriceAdapter is Ownable { // Uniswap allowed pools address[] public allowedUniswapPools; - // Address of Uniswap factory - address public uniswapFactory; - /* ============ Constructor ============ */ /** * Set state variables * * @param _controller Instance of controller contract - * @param _uniswapFactory Address of Uniswap factory * @param _uniswapPools Array of allowed Uniswap pools */ constructor( IController _controller, - address _uniswapFactory, IUniswapV2Pair[] memory _uniswapPools ) public { controller = _controller; - uniswapFactory = _uniswapFactory; // Add each of initial addresses to state for (uint256 i = 0; i < _uniswapPools.length; i++) { @@ -199,11 +193,7 @@ contract UniswapPairPriceAdapter is Ownable { uint256 tokenOnePriceToMaster = _priceOracle.getPrice(poolInfo.tokenOne, _masterQuoteAsset); uint256 tokenTwoPriceToMaster = _priceOracle.getPrice(poolInfo.tokenTwo, _masterQuoteAsset); - // Get reserve amounts - ( - uint256 tokenOneReserves, - uint256 tokenTwoReserves - ) = UniswapV2Library.getReserves(uniswapFactory, poolInfo.tokenOne, poolInfo.tokenTwo); + (uint256 tokenOneReserves, uint256 tokenTwoReserves, ) = IUniswapV2Pair(_poolAddress).getReserves(); uint256 normalizedTokenOneBaseUnit = tokenOneReserves.preciseDiv(poolInfo.tokenOneBaseUnit); uint256 normalizedTokenBaseTwoUnits = tokenTwoReserves.preciseDiv(poolInfo.tokenTwoBaseUnit);