osmosis-labs / isotonic

Smart Contracts for the Lendex Protocol
MIT License
1 stars 0 forks source link

Optimisation: Cache price oracle responses #22

Open ethanfrey opened 2 years ago

ethanfrey commented 2 years ago

We don't need to update every query. At most once per block, maybe once every minute or two.

The Market should have a wrapper around price oracle queries, that will cache a result and the last time queried. The "cache_lifetime" should be set in Market instantiation, and if the last data is younger than this time, we just use the local cached value. If it is missing or older, we query the price oracle and store the new result.

ethanfrey commented 2 years ago

I'm actually not sure if this is a good idea. We could cache this for the same block safely, but do we want to cache this longer than one block? What do we achieve by that?

uint commented 2 years ago

Blocked by #98

ethanfrey commented 2 years ago

Happy to move to a post-1.0 milestone. This just reduces gas and could be rolled out any time.

I responded to #98. Let's only cache one block if we do this at all.