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

audit specification: backward condition #47

Merged
merged 1 commit into from
Nov 1, 2023
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
1 change: 0 additions & 1 deletion src/compute_engines/yield_curve/yield_curve.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ mod YieldCurve {
}
let output: PragmaPricesResponse = oracle_dispatcher
.get_data(DataType::GenericEntry(on_key), AggregationMode::Median(()));

if (output.last_updated_timestamp == 0) {
//No data, skip to the next one
cur_idx = cur_idx + 1;
Expand Down
29 changes: 15 additions & 14 deletions src/oracle/oracle.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod Oracle {
use cmp::{max, min};
use option::OptionTrait;
use debug::PrintTrait;
const BACKWARD_TIMESTAMP_BUFFER: u64 = 7800; // 2 hours and 10 minutes
const BACKWARD_TIMESTAMP_BUFFER: u64 = 600; // 10 minutes
const FORWARD_TIMESTAMP_BUFFER: u64 = 10; // 10 seconds

// Store Packing constants
Expand Down Expand Up @@ -1746,29 +1746,30 @@ mod Oracle {
let g_entry: PossibleEntries = IOracleABI::get_data_entry(self, data_type, source);
match g_entry {
PossibleEntries::Spot(spot_entry) => {
let is_entry_not_initialized: bool = spot_entry.get_base_timestamp() == 0;
let condition: bool = is_entry_not_initialized
&& (spot_entry
.get_base_timestamp() < (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if !condition {
let is_entry_initialized: bool = spot_entry.get_base_timestamp() != 0;
let condition: bool = is_entry_initialized
& (spot_entry
EvolveArt marked this conversation as resolved.
Show resolved Hide resolved
.get_base_timestamp() > (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if condition {
entries.append(PossibleEntries::Spot(spot_entry));
}
},
PossibleEntries::Future(future_entry) => {
let is_entry_not_initialized: bool = future_entry.get_base_timestamp() == 0;
let condition: bool = is_entry_not_initialized
let is_entry_initialized: bool = future_entry.get_base_timestamp() != 0;
let condition: bool = is_entry_initialized
& (future_entry
.get_base_timestamp() < (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if !condition {
.get_base_timestamp() > (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if condition {
entries.append(PossibleEntries::Future(future_entry));
}
},
PossibleEntries::Generic(generic_entry) => {
let is_entry_not_initialized: bool = generic_entry.get_base_timestamp() == 0;
let condition: bool = is_entry_not_initialized
let is_entry_initialized: bool = generic_entry.get_base_timestamp() != 0;

let condition: bool = is_entry_initialized
& (generic_entry
.get_base_timestamp() < (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if !condition {
.get_base_timestamp() > (latest_timestamp - BACKWARD_TIMESTAMP_BUFFER));
if condition {
entries.append(PossibleEntries::Generic(generic_entry));
}
}
Expand Down
Loading