Skip to content

Commit c263c61

Browse files
authored
Default value of 20 for min pub (#327)
* Update contract and tests * Add constant
1 parent 265b262 commit c263c61

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

program/rust/src/c_oracle_header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pub const MAX_CI_DIVISOR: i64 = 3;
1212
/// Bound on the range of the exponent in price accounts. This number is set such that the
1313
/// PD-based EMA computation does not lose too much precision.
1414
pub const MAX_NUM_DECIMALS: i32 = 8;
15+
pub const PRICE_ACCOUNT_DEFAULT_MIN_PUB: u8 = 20;

program/rust/src/processor/add_price.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use {
55
ProductAccount,
66
PythAccount,
77
},
8-
c_oracle_header::PC_PTYPE_UNKNOWN,
8+
c_oracle_header::{
9+
PC_PTYPE_UNKNOWN,
10+
PRICE_ACCOUNT_DEFAULT_MIN_PUB,
11+
},
912
deserialize::{
1013
load,
1114
load_checked,
@@ -76,6 +79,7 @@ pub fn add_price(
7679
price_data.price_type = cmd_args.price_type;
7780
price_data.product_account = *product_account.key;
7881
price_data.next_price_account = product_data.first_price_account;
82+
price_data.min_pub_ = PRICE_ACCOUNT_DEFAULT_MIN_PUB;
7983
product_data.first_price_account = *price_account.key;
8084

8185
Ok(())

program/rust/src/tests/test_add_price.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use {
77
ProductAccount,
88
PythAccount,
99
},
10-
c_oracle_header::PC_VERSION,
10+
c_oracle_header::{
11+
PC_VERSION,
12+
PRICE_ACCOUNT_DEFAULT_MIN_PUB,
13+
},
1114
deserialize::load_checked,
1215
error::OracleError,
1316
instruction::{
@@ -82,6 +85,7 @@ fn test_add_price() {
8285
let product_data = load_checked::<ProductAccount>(&product_account, PC_VERSION).unwrap();
8386
assert_eq!(price_data.exponent, 1);
8487
assert_eq!(price_data.price_type, 1);
88+
assert_eq!(price_data.min_pub_, PRICE_ACCOUNT_DEFAULT_MIN_PUB);
8589
assert!(price_data.product_account == *product_account.key);
8690
assert!(price_data.next_price_account == Pubkey::default());
8791
assert!(product_data.first_price_account == *price_account.key);
@@ -103,6 +107,7 @@ fn test_add_price() {
103107
let product_data = load_checked::<ProductAccount>(&product_account, PC_VERSION).unwrap();
104108
assert_eq!(price_data_2.exponent, 1);
105109
assert_eq!(price_data_2.price_type, 1);
110+
assert_eq!(price_data_2.min_pub_, PRICE_ACCOUNT_DEFAULT_MIN_PUB);
106111
assert!(price_data_2.product_account == *product_account.key);
107112
assert!(price_data_2.next_price_account == *price_account.key);
108113
assert!(product_data.first_price_account == *price_account_2.key);

0 commit comments

Comments
 (0)