Skip to content

Commit 3303443

Browse files
committed
fix: compilation errors
1 parent 4748e45 commit 3303443

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/contracts/contract_cairo1.cairo

+21-4
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,23 @@ mod HackTemplate {
6060
let output: PragmaPricesResponse = oracle_dispatcher
6161
.get_data_median(DataType::SpotEntry(ETH_USD));
6262

63+
let future_data: PragmaPricesResponse = oracle_dispatcher
64+
.get_data_median(DataType::FutureEntry((ETH_USD, 0)));
65+
66+
let current_timestamp = get_block_timestamp();
67+
assert(
68+
future_data.last_updated_timestamp >= current_timestamp - 500, 'Data is too old'
69+
);
70+
71+
let min_num_sources = 3;
72+
assert(output.num_sources_aggregated >= min_num_sources, 'Not enough sources');
73+
6374
// We only care about DEFILLAMA and COINBASE
64-
let defillama: felt252 = 'DEFILLAMA';
65-
let coinbase: felt252 = 'COINBASE';
75+
// let defillama: felt252 = 'DEFILLAMA';
76+
// let coinbase: felt252 = 'COINBASE';
77+
let skynet: felt252 = 'SKYNET_TRADING';
6678

67-
let mut sources = array![defillama, coinbase];
79+
let mut sources = array![skynet];
6880
let output: PragmaPricesResponse = oracle_dispatcher
6981
.get_data_for_sources(
7082
DataType::SpotEntry(BTC_USD), AggregationMode::Median(()), sources.span()
@@ -111,14 +123,19 @@ mod HackTemplate {
111123
start.into(),
112124
end.into(),
113125
num_samples,
114-
AggregationMode::Median(())
126+
AggregationMode::Mean(())
115127
);
116128

117129
let (mean, mean_decimals) = oracle_dispatcher
118130
.calculate_mean(
119131
DataType::SpotEntry(key), start.into(), end.into(), AggregationMode::Median(())
120132
);
121133

134+
let (twap, twap_decimals) = oracle_dispatcher
135+
.calculate_twap(
136+
DataType::SpotEntry(key), AggregationMode::Mean(()), end.into(), start.into()
137+
);
138+
122139
(volatility, decimals)
123140
}
124141
}

0 commit comments

Comments
 (0)