diff --git a/program/rust/src/c_oracle_header.rs b/program/rust/src/c_oracle_header.rs index c1dae4ec0..e48955a07 100644 --- a/program/rust/src/c_oracle_header.rs +++ b/program/rust/src/c_oracle_header.rs @@ -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; diff --git a/program/rust/src/processor/add_price.rs b/program/rust/src/processor/add_price.rs index ae07164b6..6797a4a00 100644 --- a/program/rust/src/processor/add_price.rs +++ b/program/rust/src/processor/add_price.rs @@ -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, @@ -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(()) diff --git a/program/rust/src/tests/test_add_price.rs b/program/rust/src/tests/test_add_price.rs index f5e7bbbc9..573129356 100644 --- a/program/rust/src/tests/test_add_price.rs +++ b/program/rust/src/tests/test_add_price.rs @@ -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::{ @@ -82,6 +85,7 @@ fn test_add_price() { let product_data = load_checked::(&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); @@ -103,6 +107,7 @@ fn test_add_price() { let product_data = load_checked::(&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);