Skip to content

Commit 342206b

Browse files
committed
fix: prevent getPrice from revert in UniswapPairPriceAdapter
1 parent b99255f commit 342206b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

contracts/protocol/integration/oracles/UniswapPairPriceAdapter.sol

+9-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ contract UniswapPairPriceAdapter is Ownable {
117117
* @param _assetOne Address of first asset in pair
118118
* @param _assetTwo Address of second asset in pair
119119
*/
120-
function getPrice(address _assetOne, address _assetTwo) external view returns (bool, uint256) {
120+
function getPoolPrice(address _assetOne, address _assetTwo) external view returns (bool, uint256) {
121121
require(controller.isSystemContract(msg.sender), "Must be system contract");
122122

123123
bool isAllowedUniswapPoolOne = uniswapPoolsToSettings[_assetOne].isValid;
@@ -148,6 +148,14 @@ contract UniswapPairPriceAdapter is Ownable {
148148
return (true, assetOnePriceToMaster.preciseDiv(assetTwoPriceToMaster));
149149
}
150150

151+
function getPrice(address _assetOne, address _assetTwo) external view returns (bool, uint256) {
152+
try this.getPoolPrice(_assetOne, _assetTwo) returns (bool found, uint256 price) {
153+
if (found) {
154+
return (true, price);
155+
}
156+
} catch {}
157+
}
158+
151159
function addPool(address _poolAddress) external onlyOwner {
152160
require (
153161
!uniswapPoolsToSettings[_poolAddress].isValid,

0 commit comments

Comments
 (0)