lindy-labs / opus_contracts

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

feat: receptor #600

Closed tserg closed 2 months ago

tserg commented 2 months ago

This PR adds the Receptor (open to suggestions for names) module that submits yin's price to Shrine for the Controller to actuate on.

The yin price is taken as the median of CASH-{DAI, USDC, USDT} pairs from Ekubo's oracle extension, based on a TWAP duration that can be adjusted by admin. The quote tokens can also be adjusted if desired in the future e.g. swapping one of them out for LUSD. I considered taking the median of an arbitrary number of quotes, but that would make the contract unnecessary complex e.g. implementing a heap to sort any number of quotes.

Additionally, the Receptor module also implements the ITask interface to streamline its interaction by keepers. Therefore, the primary method of updating yin's price is via ITask.execute_task(). Nevertheless, there is also a update_yin_price that is restricted by access control that allows the update frequency of the task to be bypassed, similar to seer.update_prices() and seer.execute_task(). At the moment, this is not necessary, but it gives some flexibility for the future in case the yin's price needs to be updated in some user flow.

Initially, I wanted to include the Sepolia and mainnet scripts in this PR, but I think they can be taken up separately while UX design is ongoing.

tserg commented 2 months ago

I'm not a huge fan of the name, but also don't have a better suggestion 😬 No point on dwelling on it 🚢

A few other (already filtered) suggestions from Claude: