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

fix: decimals returned by the volatility function #51

Merged
merged 2 commits into from
Nov 1, 2023
Merged
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
7 changes: 4 additions & 3 deletions src/compute_engines/summary_stats/summary_stats.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mod SummaryStats {
stop: u64,
aggregation_mode: AggregationMode
) -> (u128, u32) {
assert(start < stop, 'start must be < stop');
let oracle_address = self.oracle_address.read();
let oracle_dispatcher = IOracleABIDispatcher { contract_address: oracle_address };

Expand Down Expand Up @@ -130,6 +131,7 @@ mod SummaryStats {
num_samples: u64,
aggregation_mode: AggregationMode,
) -> (u128, u32) {
assert(start_tick < end_tick, 'start_tick must be < end_tick');
let oracle_address = self.oracle_address.read();

assert(num_samples > 0, 'num_samples must be > 0');
Expand All @@ -140,7 +142,6 @@ mod SummaryStats {
.get_latest_checkpoint_index(data_type, aggregation_mode);
let (_start_cp, start_index) = oracle_dispatcher
.get_last_checkpoint_before(data_type, start_tick, aggregation_mode);
let decimals = oracle_dispatcher.get_decimals(data_type);

let mut end_index = 0;
if (end_tick == 0) {
Expand Down Expand Up @@ -168,8 +169,8 @@ mod SummaryStats {
tick_arr.append(TickElem { tick: cp.timestamp, value: fixed_val });
idx += 1;
};

(volatility(tick_arr.span()), decimals)
//the number of decimals is hardcoded to 8 by the volatilty computation in metrics.cairo
(volatility(tick_arr.span()), 8)
}


Expand Down
Loading