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

Nour/pyth pull #1067

Merged
merged 35 commits into from
Jun 18, 2024
Merged

Nour/pyth pull #1067

merged 35 commits into from
Jun 18, 2024

Conversation

NourAlharithi
Copy link
Member

No description provided.

@@ -625,6 +631,50 @@ pub fn handle_initialize_perp_market(
} = get_prelaunch_price(&ctx.accounts.oracle, clock_slot)?;
(oracle_price, oracle_delay, oracle_price)
}
OracleSource::PythPull => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: can maybe merge the Pyth and PythPull branches and just add a method is_pull to oracle source (if we think less lines of code is more readable

Copy link
Member Author

@NourAlharithi NourAlharithi May 31, 2024

Choose a reason for hiding this comment

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

i initially did this, but was thinking it would be nice to explicitly define the oracle source like this so we dont have to worry about making sure we correctly set the is_pull switch when we call get_oracle_price -- it's already inferred whether to use push or pull from the explicitly stated OracleSource

let publisher_count = price_data.num_qt;

has_sufficient_number_of_data_points = {
if cfg!(feature = "mainnet-beta") {
Copy link
Member

Choose a reason for hiding this comment

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

this seems wrong

Copy link
Member

Choose a reason for hiding this comment

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

should be more like:

    #[cfg(feature = "mainnet-beta")]
    let has_sufficient_number_of_data_points = publisher_count >= min_publishers;
    #[cfg(not(feature = "mainnet-beta"))]
    let has_sufficient_number_of_data_points = true;
    ```

programs/drift/src/state/oracle_map.rs Show resolved Hide resolved
} from '@pythnetwork/pyth-solana-receiver';
import { PriceUpdateAccount } from '@pythnetwork/pyth-solana-receiver/lib/PythSolanaReceiver';

export class PythPullClient implements OracleClient {
Copy link
Member

Choose a reason for hiding this comment

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

dont you need to add to oracle client factory too?

@crispheaney crispheaney changed the base branch from crispheaney/anchor-29 to master June 17, 2024 17:26
Copy link
Member

@wphan wphan left a comment

Choose a reason for hiding this comment

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

i think needa run anchor build or something and generate IDLs?

@@ -110,12 +110,16 @@ impl HistoricalIndexData {
pub enum OracleSource {
#[default]
Pyth,
Switchboard,
QuoteAsset,
Copy link
Member

Choose a reason for hiding this comment

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

i wouldn't change the order of these enums since i think it changes how the program interprets the values (i.e. anyone who doesnt update IDL will start interpreting OracleSource::Switchboard as OracleSource::Pyth1K

@NourAlharithi NourAlharithi merged commit 2fecc4d into master Jun 18, 2024
7 of 10 checks passed
@NourAlharithi NourAlharithi deleted the nour/pyth-pull branch June 18, 2024 16:13
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