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

Oracle Adapter #545

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Conversation

Kayanski
Copy link
Contributor

@Kayanski Kayanski commented Nov 25, 2024

Adding the Oracle Adapter to abstract supported adapters

Added Pyth implementation and tests

Based on https://www.notion.so/abstract-money/Price-Oracle-24cb3a64c535427d9a38b0312235f889

Checklist

  • CI is green.
  • Changelog updated.

Copy link

cloudflare-workers-and-pages bot commented Nov 25, 2024

Deploying abstract-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5b2e031
Status: ✅  Deploy successful!
Preview URL: https://3d393b26.abstract-docs.pages.dev
Branch Preview URL: https://nicolas-abs-589-oracle-adapt.abstract-docs.pages.dev

View logs

@Kayanski Kayanski marked this pull request as ready for review November 26, 2024 10:51
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 213 lines in your changes missing coverage. Please review.

Project coverage is 65.2%. Comparing base (bf989a9) to head (7ab80c9).
Report is 73 commits behind head on main.

Files with missing lines Patch % Lines
integrations/oracles/pyth/src/lib.rs 0.0% 54 Missing ⚠️
modules/contracts/adapters/oracle/src/lib.rs 0.0% 48 Missing ⚠️
...les/contracts/adapters/oracle/src/oracle_tester.rs 0.0% 42 Missing ⚠️
modules/contracts/adapters/oracle/src/api.rs 0.0% 26 Missing ⚠️
...es/contracts/adapters/oracle/src/handlers/query.rs 0.0% 16 Missing ⚠️
...tracts/adapters/oracle/src/handlers/instantiate.rs 0.0% 9 Missing ⚠️
.../contracts/adapters/oracle/src/handlers/execute.rs 0.0% 8 Missing ⚠️
...dules/contracts/adapters/oracle/src/oracles/mod.rs 0.0% 6 Missing ⚠️
framework/packages/standards/oracle/src/msg.rs 0.0% 4 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
framework/packages/standards/oracle/src/msg.rs 0.0% <0.0%> (ø)
...dules/contracts/adapters/oracle/src/oracles/mod.rs 0.0% <0.0%> (ø)
.../contracts/adapters/oracle/src/handlers/execute.rs 0.0% <0.0%> (ø)
...tracts/adapters/oracle/src/handlers/instantiate.rs 0.0% <0.0%> (ø)
...es/contracts/adapters/oracle/src/handlers/query.rs 0.0% <0.0%> (ø)
modules/contracts/adapters/oracle/src/api.rs 0.0% <0.0%> (ø)
...les/contracts/adapters/oracle/src/oracle_tester.rs 0.0% <0.0%> (ø)
modules/contracts/adapters/oracle/src/lib.rs 0.0% <0.0%> (ø)
integrations/oracles/pyth/src/lib.rs 0.0% <0.0%> (ø)

... and 169 files with indirect coverage changes

Copy link
Contributor

@adairrr adairrr left a comment

Choose a reason for hiding this comment

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

The PR specifies that the implementation was performed with the API specified in the Oracle adapter design.

However, it seems that asset registration and value queries were not implemented. Are those supposed to be implemented on this adapter or elsewhere?

framework/packages/standards/oracle/README.md Outdated Show resolved Hide resolved
framework/packages/standards/oracle/src/command.rs Outdated Show resolved Hide resolved
framework/packages/standards/oracle/src/error.rs Outdated Show resolved Hide resolved
integrations/oracles/pyth/README.md Outdated Show resolved Hide resolved

let current_price = price_feed
.get_price_no_older_than(env.block.time.seconds() as i64, no_older_than)
.ok_or_else(|| StdError::not_found("Current price is not available"))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that the price must be available within the current block as of querying?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The price must be not older than no_older_than from the current block time.

modules/contracts/adapters/oracle/STATUS.md Show resolved Hide resolved
modules/contracts/adapters/oracle/tests/osmosis.rs Outdated Show resolved Hide resolved
scripts/wasm-all.sh Outdated Show resolved Hide resolved
Kayanski and others added 6 commits November 27, 2024 07:53
@Kayanski
Copy link
Contributor Author

The PR specifies that the implementation was performed with the API specified in the Oracle adapter design.

However, it seems that asset registration and value queries were not implemented. Are those supposed to be implemented on this adapter or elsewhere?

To me, asset registration and value queries should not be placed inside the oracle adapter which is there to query prices from price sources using keys (for the moment).
It belongs in a value computation app for instance, because it contains account specific storage that is best handled within an App

Copy link
Collaborator

@Buckram123 Buckram123 left a comment

Choose a reason for hiding this comment

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

Amazing implementation! Great decision to keep it without state and execute methods, it would be make more sense to keep at module that adapts this adapter. Left few small nits.

Another point that oracle part of the account previously was able to return value of the account(list of assets) in "base asset" - it was evaluating assets/lp tokens, we don't need it anymore? I think it should be possible to get price of list assets/lp-tokens if every asset involved would be tagged by "price_source_key". Not sure that we need to calculate value in "base asset", IMO oracle price is enough, I imagine it would be quite challenging to create and use API that includes both "base asset" and oracle prices

integrations/oracles/pyth/README.md Outdated Show resolved Hide resolved
modules/contracts/adapters/oracle/examples/register_ans.rs Outdated Show resolved Hide resolved
modules/contracts/adapters/oracle/src/handlers/execute.rs Outdated Show resolved Hide resolved
modules/contracts/adapters/oracle/src/lib.rs Outdated Show resolved Hide resolved
modules/contracts/adapters/oracle/src/lib.rs Show resolved Hide resolved
modules/contracts/adapters/oracle/src/state.rs Outdated Show resolved Hide resolved
Buckram123 and others added 11 commits January 8, 2025 13:30
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.

3 participants