Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove uniswapFactory in UniswapPairPriceAdapter to support all uniswap compatible factories #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -200,10 +194,7 @@ contract UniswapPairPriceAdapter is Ownable {
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);
Expand Down