Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions program/rust/src/c_oracle_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub const PERMISSIONS_SEED: &str = "permissions";

/// If ci > price / PC_MAX_CI_DIVISOR, set publisher status to unknown.
/// (e.g., 20 means ci must be < 5% of price)
pub const MAX_CI_DIVISOR: i64 = 20;

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;
Expand Down
8 changes: 4 additions & 4 deletions program/rust/src/tests/test_upd_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn test_upd_price() {
assert_eq!(price_data.agg_.status_, PC_STATUS_TRADING);
}

populate_instruction(&mut instruction_data, 50, 6, 5);
populate_instruction(&mut instruction_data, 50, 20, 5);
update_clock_slot(&mut clock_account, 6);

// Publishing a wide CI results in a status of unknown.
Expand All @@ -239,7 +239,7 @@ fn test_upd_price() {
{
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
assert_eq!(price_data.comp_[0].latest_.price_, 50);
assert_eq!(price_data.comp_[0].latest_.conf_, 6);
assert_eq!(price_data.comp_[0].latest_.conf_, 20);
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 5);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
assert_eq!(price_data.valid_slot_, 5);
Expand All @@ -249,7 +249,7 @@ fn test_upd_price() {
}

// Crank one more time and aggregate should be unknown
populate_instruction(&mut instruction_data, 50, 6, 6);
populate_instruction(&mut instruction_data, 50, 20, 6);
update_clock_slot(&mut clock_account, 7);

assert!(process_instruction(
Expand All @@ -266,7 +266,7 @@ fn test_upd_price() {
{
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
assert_eq!(price_data.comp_[0].latest_.price_, 50);
assert_eq!(price_data.comp_[0].latest_.conf_, 6);
assert_eq!(price_data.comp_[0].latest_.conf_, 20);
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 6);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
assert_eq!(price_data.valid_slot_, 6);
Expand Down
4 changes: 2 additions & 2 deletions program/rust/src/tests/test_upd_price_no_fail_on_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() {
assert_eq!(price_data.comp_[0].latest_.price_, 42);
assert_eq!(price_data.comp_[0].latest_.conf_, 9);
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING);
assert_eq!(price_data.valid_slot_, 0);
assert_eq!(price_data.agg_.pub_slot_, 1);
assert_eq!(price_data.agg_.price_, 0);
Expand Down Expand Up @@ -158,7 +158,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() {
assert_eq!(price_data.comp_[0].latest_.price_, 42);
assert_eq!(price_data.comp_[0].latest_.conf_, 9);
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING);
assert_eq!(price_data.valid_slot_, 0);
assert_eq!(price_data.agg_.pub_slot_, 1);
assert_eq!(price_data.agg_.price_, 0);
Expand Down
8 changes: 4 additions & 4 deletions program/rust/src/tests/test_upd_sma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn test_upd_sma() {
assert_eq!(price_data.time_machine.current_epoch_denominator, 3 + 1 + 1);
}

populate_instruction(&mut instruction_data, 50, 6, 5);
populate_instruction(&mut instruction_data, 50, 20, 5);
update_clock_slot(&mut clock_account, 6);

// Publishing a wide CI results in a status of unknown.
Expand Down Expand Up @@ -305,7 +305,7 @@ fn test_upd_sma() {
{
let price_data = load_checked::<PriceAccountWrapper>(&price_account, PC_VERSION).unwrap();
assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50);
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6);
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20);
assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 5);
assert_eq!(
price_data.price_data.comp_[0].latest_.status_,
Expand All @@ -328,7 +328,7 @@ fn test_upd_sma() {
}

// Crank one more time and aggregate should be unknown
populate_instruction(&mut instruction_data, 50, 6, 6);
populate_instruction(&mut instruction_data, 50, 20, 6);
update_clock_slot(&mut clock_account, 7);

assert!(process_instruction(
Expand All @@ -345,7 +345,7 @@ fn test_upd_sma() {
{
let price_data = load_checked::<PriceAccountWrapper>(&price_account, PC_VERSION).unwrap();
assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50);
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6);
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20);
assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 6);
assert_eq!(
price_data.price_data.comp_[0].latest_.status_,
Expand Down
2 changes: 1 addition & 1 deletion pyth/tests/test_update_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ def get_publisher_acc(product_acc):
assert publisher_acc['price'] == new_values[product]['price']
assert publisher_acc['conf'] == new_values[product]['conf']

conf_threshold = new_values[product]['price'] / 20
conf_threshold = new_values[product]['price'] // 3
expected_status = 'unknown' if new_values[product]['conf'] > conf_threshold else 'trading'
assert publisher_acc['status'] == expected_status