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

Support for combined values in OnNewData trait #903

Open
lemunozm opened this issue Apr 19, 2023 · 3 comments
Open

Support for combined values in OnNewData trait #903

lemunozm opened this issue Apr 19, 2023 · 3 comments

Comments

@lemunozm
Copy link
Contributor

Hi!

As a user of orml_oracle, I miss the possibility of receiving callbacks when a combined value is updated. Currently, orml_oracle only calls OnNewData::on_new_data() with no combined values. It would be great to have an OnNewData::on_updated_combined_data() or similar to that trait to be called when the value is combined.

If you agree, I can open a PR. Seems simple, and it does not require any migration.

Thanks for your work!

@xlc
Copy link
Member

xlc commented Apr 19, 2023

The reason is that most of the time, the combined value will update when there is new data. If you put the logic of updated combined data into the new data hook, what you will end up is getting some false update hook call (hook called when value did not change), but that should be handled by normal business logic anyway. Oracle can feed the same price, and expected to do so when the market price actually did not move for a significant period of time.

Let me know what do you think. I don't against this feature as long as it is actually useful.

@lemunozm
Copy link
Contributor Author

Mmm... I see 🤔

Currently, my pallet implements OnNewData and uses by config a DataProvider (which will return the combined value). I need both, because sometimes I need to ask for some data I was not collecting by the OnNewData implementation. In this scenario, is where I find that the value coming from on_new_data() differs from a value asked to the DataProvider. In my case, I do not care if it is combined or not. I only care about data consistency between both methods of getting the value.

I have a workaround for this, which is using on_new_data() only as a trigger, without reading the value and calling to DataProvider inside of it to get the correct combined value. So the proposed change is not mandatory, although I think It can help to reason about which value is handled.

@xlc
Copy link
Member

xlc commented Apr 19, 2023

Your workaround is indeed the intended usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants