-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
Hello! I'm facing issue with UniswapPairPriceAdapter. I've add the pools but getPrice returns always false.
I think this is because of a bug in the contract.
addPool function saves into uniswapPoolsToSettings by the pool address
function addPool(address _poolAddress) external onlyOwner {
require (
!uniswapPoolsToSettings[_poolAddress].isValid,
"Uniswap pool address already added"
);
IUniswapV2Pair poolToken = IUniswapV2Pair(_poolAddress);
uniswapPoolsToSettings[_poolAddress].tokenOne = poolToken.token0();
uniswapPoolsToSettings[_poolAddress].tokenTwo = poolToken.token1();
uint256 tokenOneDecimals = ERC20(uniswapPoolsToSettings[_poolAddress].tokenOne).decimals();
uniswapPoolsToSettings[_poolAddress].tokenOneBaseUnit = 10 ** tokenOneDecimals;
uint256 tokenTwoDecimals = ERC20(uniswapPoolsToSettings[_poolAddress].tokenTwo).decimals();
uniswapPoolsToSettings[_poolAddress].tokenTwoBaseUnit = 10 ** tokenTwoDecimals;
uniswapPoolsToSettings[_poolAddress].isValid = true;
allowedUniswapPools.push(_poolAddress);
}
But getPrice function check by the assets addresses
function getPrice(address _assetOne, address _assetTwo) external view returns (bool, uint256) {
require(controller.isSystemContract(msg.sender), "Must be system contract");
bool isAllowedUniswapPoolOne = uniswapPoolsToSettings[_assetOne].isValid;
bool isAllowedUniswapPoolTwo = uniswapPoolsToSettings[_assetTwo].isValid;
// If assetOne and assetTwo are both not Uniswap pools, then return false
if (!isAllowedUniswapPoolOne && !isAllowedUniswapPoolTwo) {
return (false, 0);
}
IPriceOracle priceOracle = controller.getPriceOracle();
address masterQuoteAsset = priceOracle.masterQuoteAsset();
uint256 assetOnePriceToMaster;
if(isAllowedUniswapPoolOne) {
assetOnePriceToMaster = _getUniswapPrice(priceOracle, _assetOne, masterQuoteAsset);
} else {
assetOnePriceToMaster = priceOracle.getPrice(_assetOne, masterQuoteAsset);
}
uint256 assetTwoPriceToMaster;
if(isAllowedUniswapPoolTwo) {
assetTwoPriceToMaster = _getUniswapPrice(priceOracle, _assetTwo, masterQuoteAsset);
} else {
assetTwoPriceToMaster = priceOracle.getPrice(_assetTwo, masterQuoteAsset);
}
return (true, assetOnePriceToMaster.preciseDiv(assetTwoPriceToMaster));
}
So this will be return always false
// If assetOne and assetTwo are both not Uniswap pools, then return false
if (!isAllowedUniswapPoolOne && !isAllowedUniswapPoolTwo) {
return (false, 0);
}
Am I missing something?
Metadata
Metadata
Assignees
Labels
No labels