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

feat!: Integrate EMA oracle with Omnipool Hooks #534

Merged
merged 44 commits into from
Mar 17, 2023
Merged

Conversation

apopiak
Copy link
Contributor

@apopiak apopiak commented Mar 10, 2023

Add the EMA oracle pallet to the runtime and ingest data by using the OmnipoolHooksAdapter.

Motivation and Context

We want to have on-chain data that aggregates over timespans. E.g. aggregate trading volume over some time to change fees based on it.

How Has This Been Tested?

Includes an integration test.
Most of the tests are in the pallet and its corresponding math package.

Checklist:

  • I have updated the documentation if necessary.
  • I have added tests to cover my changes, regression test if fixing an issue.
  • This is a breaking change.
  • Run benchmarks
  • Decide on SupportedPeriods
  • Add hook weights to omnipool weights

@github-actions
Copy link

github-actions bot commented Mar 10, 2023

Crate versions that have been updated:

  • runtime-integration-tests: v1.2.0 -> v1.3.0
  • hydradx: v8.5.1 -> v8.5.2
  • pallet-claims: v3.4.3 -> v3.4.4
  • pallet-omnipool: v1.6.2 -> v1.6.3
  • pallet-omnipool-liquidity-mining: v1.0.3 -> v1.0.4
  • common-runtime: v100.4.1 -> v100.5.0
  • hydradx-runtime: v134.0.0 -> v135.0.0
  • testing-hydradx-runtime: v134.0.0 -> v135.0.0
  • scraper: v1.0.0 -> v1.0.1

Runtime version has been increased.

runtime/hydradx/src/lib.rs Outdated Show resolved Hide resolved
}

fn on_hub_asset_trade(_: Origin, _: AssetInfo<AssetId, Balance>) -> Result<(), Self::Error> {
Ok(())
fn on_hub_asset_trade(_: Origin, _: AssetInfo<AssetId, Balance>) -> Result<Weight, Self::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this triggered on every swap? Even on Asset <> Asset?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on LRNA trade only.

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch coverage: 37.68% and project coverage change: -0.19 ⚠️

Comparison is base (2004088) 38.84% compared to head (b6230d8) 38.65%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #534      +/-   ##
==========================================
- Coverage   38.84%   38.65%   -0.19%     
==========================================
  Files          62       66       +4     
  Lines        4240     4421     +181     
==========================================
+ Hits         1647     1709      +62     
- Misses       2593     2712     +119     
Impacted Files Coverage Δ
node/src/chain_spec/mod.rs 0.00% <0.00%> (ø)
node/src/testing_chain_spec.rs 0.00% <0.00%> (ø)
runtime/common/src/lib.rs 38.70% <ø> (ø)
runtime/testing-hydradx/src/lib.rs 8.95% <0.00%> (-0.14%) ⬇️
scraper/src/lib.rs 0.00% <0.00%> (ø)
scraper/src/main.rs 0.00% <0.00%> (ø)
runtime/hydradx/src/lib.rs 21.86% <50.00%> (+0.53%) ⬆️
pallets/omnipool/src/lib.rs 78.65% <64.51%> (-0.27%) ⬇️
runtime/common/src/adapters.rs 70.00% <70.00%> (ø)
runtime/common/src/weights/ema_oracle.rs 90.47% <90.47%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@apopiak
Copy link
Contributor Author

apopiak commented Mar 17, 2023

Note: We might want to optimize the weights in terms of the HDX liquidity change possible on trade (e.g. only doing it once per block).

Copy link
Contributor

@jak-pan jak-pan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks but we can fix later just push the periods we need

@mrq1911 mrq1911 merged commit dbedffd into master Mar 17, 2023
@jak-pan jak-pan deleted the feat/oracle-hooks branch February 22, 2024 10:46
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

Successfully merging this pull request may close these issues.

None yet

4 participants