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!: allow loading network-specific PriceAccount #113

Merged
merged 1 commit into from
Feb 9, 2024
Merged

Conversation

Reisen
Copy link
Contributor

@Reisen Reisen commented Feb 7, 2024

The PriceAccount structure has diverged between Solana and Pythnet, and the SDK currently only supports loading the format stored on Solana. To support loading different kinds of price account, this PR introduces a base type GenericPriceAccount that can be instantiated to the two different shapes as well as being extensible to future changes to price accounts.

The following steps were taken:

  • Introduce GenericPriceAccount that can represent any underlying representation.
  • Replace PriceAccount with an alias to GenericPriceAccount<32, ()> for backwards compatibility.
  • Implements Deref on GenericPriceAccount so the underlying extended fields are ergonomic.
  • Introduce SolanaPriceAccount and PythnetPriceAccount aliases.
  • Introduce ::account_to_feed and ::account_info_to_feed over these types. These functions strictly speaking are PriceFeed constructors but are implemented as conversion functions namespaced under the types.
  • Deprecate the solana specific load_* methods and re-implement the body with these new methods.
  • Adds a small test to make sure the generic implementation and the old implementation are byte-equivalant.

CI also seems to be having trouble building with nightly so I've added toolchain files with the minimum required versions to all examples.

@Reisen Reisen requested review from ali-bahjati and jayantk February 7, 2024 13:23
@Reisen Reisen force-pushed the push-nvlzuznkvoon branch 4 times, most recently from b51c507 to 0354e52 Compare February 7, 2024 14:19
@Reisen Reisen force-pushed the push-nvlzuznkvoon branch 3 times, most recently from c902b7a to 0dc9e31 Compare February 8, 2024 15:28
@Reisen Reisen force-pushed the push-nvlzuznkvoon branch from 0dc9e31 to 3a8c8e8 Compare February 9, 2024 14:56
@Reisen Reisen merged commit 096432f into main Feb 9, 2024
5 checks passed
@Reisen Reisen deleted the push-nvlzuznkvoon branch February 9, 2024 15:02
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