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

Default value of 20 for min pub #327

Merged
merged 2 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions program/rust/src/c_oracle_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pub const MAX_CI_DIVISOR: i64 = 3;
/// Bound on the range of the exponent in price accounts. This number is set such that the
/// PD-based EMA computation does not lose too much precision.
pub const MAX_NUM_DECIMALS: i32 = 8;
pub const PRICE_ACCOUNT_DEFAULT_MIN_PUB: u8 = 20;
6 changes: 5 additions & 1 deletion program/rust/src/processor/add_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use {
ProductAccount,
PythAccount,
},
c_oracle_header::PC_PTYPE_UNKNOWN,
c_oracle_header::{
PC_PTYPE_UNKNOWN,
PRICE_ACCOUNT_DEFAULT_MIN_PUB,
},
deserialize::{
load,
load_checked,
Expand Down Expand Up @@ -76,6 +79,7 @@ pub fn add_price(
price_data.price_type = cmd_args.price_type;
price_data.product_account = *product_account.key;
price_data.next_price_account = product_data.first_price_account;
price_data.min_pub_ = PRICE_ACCOUNT_DEFAULT_MIN_PUB;
product_data.first_price_account = *price_account.key;

Ok(())
Expand Down
7 changes: 6 additions & 1 deletion program/rust/src/tests/test_add_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use {
ProductAccount,
PythAccount,
},
c_oracle_header::PC_VERSION,
c_oracle_header::{
PC_VERSION,
PRICE_ACCOUNT_DEFAULT_MIN_PUB,
},
deserialize::load_checked,
error::OracleError,
instruction::{
Expand Down Expand Up @@ -82,6 +85,7 @@ fn test_add_price() {
let product_data = load_checked::<ProductAccount>(&product_account, PC_VERSION).unwrap();
assert_eq!(price_data.exponent, 1);
assert_eq!(price_data.price_type, 1);
assert_eq!(price_data.min_pub_, PRICE_ACCOUNT_DEFAULT_MIN_PUB);
assert!(price_data.product_account == *product_account.key);
assert!(price_data.next_price_account == Pubkey::default());
assert!(product_data.first_price_account == *price_account.key);
Expand All @@ -103,6 +107,7 @@ fn test_add_price() {
let product_data = load_checked::<ProductAccount>(&product_account, PC_VERSION).unwrap();
assert_eq!(price_data_2.exponent, 1);
assert_eq!(price_data_2.price_type, 1);
assert_eq!(price_data_2.min_pub_, PRICE_ACCOUNT_DEFAULT_MIN_PUB);
assert!(price_data_2.product_account == *product_account.key);
assert!(price_data_2.next_price_account == *price_account.key);
assert!(product_data.first_price_account == *price_account_2.key);
Expand Down