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

For trusted feeds, PriceOracleV3._getPriceSafe uses main price feed even when reserve one is activated #168

Open
lekhovitsky opened this issue Dec 22, 2023 · 0 comments · Fixed by #200

Comments

@lekhovitsky
Copy link
Collaborator

lekhovitsky commented Dec 22, 2023

function _getPriceSafe(address token) internal view returns (uint256 price, uint256 scale) {
(address priceFeed, uint32 stalenessPeriod, bool skipCheck, uint8 decimals,, bool trusted) =
_getPriceFeedParams(token);
(price, scale) = _getPrice(priceFeed, stalenessPeriod, skipCheck, decimals); // U:[PO-11]
if (!trusted) {
if (_priceFeedsParams[_getTokenReserveKey(token)].priceFeed == address(0)) return (0, scale); // U:[PO-11]
(uint256 reservePrice,) = _getPriceRaw(token, true);
price = Math.min(price, reservePrice); // U:[PO-11]
}

If the main feed starts reporting inflated prices and controller activates the reserve one, a user would be able fall back to the main one by adding a dummy withdrawal in a multicall.

A proper behaviour would be to return the active feed price for trusted feeds, and min of both feeds for untrusted feeds.

Also, when the feed is not trusted and reserve feed is not set, there is no need to spend gas for the main feed price computation because the result would be zero anyways.

@lekhovitsky lekhovitsky linked a pull request Jan 25, 2024 that will close this issue
@lekhovitsky lekhovitsky linked a pull request Apr 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant