-
Notifications
You must be signed in to change notification settings - Fork 125
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
Nour/pyth pull #1067
Conversation
merge in anchor upgrade
merge in master
@@ -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 => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
programs/drift/src/state/oracle.rs
Outdated
let publisher_count = price_data.num_qt; | ||
|
||
has_sufficient_number_of_data_points = { | ||
if cfg!(feature = "mainnet-beta") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems wrong
There was a problem hiding this comment.
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;
```
} from '@pythnetwork/pyth-solana-receiver'; | ||
import { PriceUpdateAccount } from '@pythnetwork/pyth-solana-receiver/lib/PythSolanaReceiver'; | ||
|
||
export class PythPullClient implements OracleClient { |
There was a problem hiding this comment.
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?
There was a problem hiding this 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?
programs/drift/src/state/oracle.rs
Outdated
@@ -110,12 +110,16 @@ impl HistoricalIndexData { | |||
pub enum OracleSource { | |||
#[default] | |||
Pyth, | |||
Switchboard, | |||
QuoteAsset, |
There was a problem hiding this comment.
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
No description provided.