Gearbox-protocol / core-v3

Other
28 stars 4 forks source link

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

Open lekhovitsky opened 9 months ago

lekhovitsky commented 9 months ago

https://github.com/Gearbox-protocol/core-v3/blob/e16559ae82f0f24c3dc29693c444f40d676ebff9/contracts/core/PriceOracleV3.sol#L127-L136

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.