lindy-labs / opus_contracts

Opus Source Code
https://opus.money
Other
0 stars 0 forks source link

dev: price feed handling #503

Closed milancermak closed 3 months ago

milancermak commented 11 months ago

Thanks for #486 we have the Seer module and can integrate with multiple oracles / price feed providers. It opens up the possibility to do more with the read price values, for example average them from multiple sources.

In the Seer's review, @bllu404 has pointed out that we can change the price validity logic.

Likewise, @tserg noted that the force update & fallback logic is not quite optimal.

This is then a tracking issue to note and discuss these and other possible improvements to the price feed handling and computation logic.

milancermak commented 11 months ago

Early Dec'23, wstETH / ETH feed of Chainlink on Arbitrum did something wacky. tweet 1, tweet 2

We should prevent against this. Maybe disregard a price update if it deviates more than X% from the last reported price and use the fallback oracle? The value of X will have to take the update frequency into account.

0xBRM commented 11 months ago

We should prevent against this. Maybe disregard a price update if it deviates more than X% from the last reported price and use the fallback oracle? The value of X will have to take the update frequency into account.

This is already the plan: @tserg came up with the idea to simplify my pessimistic oracle and make it simpler, more robust!

milancermak commented 10 months ago

Maybe disregard a price update if it deviates more than X% from the last reported price and use the fallback oracle?

On Jan 3, 2024, there was a mini flash crash of ~7% on ETH due to a BS tweet that got picked up by the Block (at least that what everyone's thinking). What should be the value of X? 🤔

milancermak commented 8 months ago

Probably a good point by Dan Robinson on oracle integration in the aftermath of 500K of bad debt on Compound after +40% candle on UNI:

For loan originations, if you have a backup price oracle, you should use the more conservative of the inputs (lower bound for valuing the collateral, upper bound for valuing the debt)

milancermak commented 7 months ago

The proposed pessimistic oracle design: Gary design

milancermak commented 3 months ago

In our Pragma integration, we take the min of spot and TWAP price, i.e. what's detailed in the diagram above. Closing. Also resolves #139.