From 33034432968ebb65524a026e1823496fcb683ec1 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Fri, 10 Jan 2025 12:40:23 +0400 Subject: [PATCH] fix: compilation errors --- src/contracts/contract_cairo1.cairo | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/contracts/contract_cairo1.cairo b/src/contracts/contract_cairo1.cairo index 59800d3..98b83dc 100644 --- a/src/contracts/contract_cairo1.cairo +++ b/src/contracts/contract_cairo1.cairo @@ -60,11 +60,23 @@ mod HackTemplate { let output: PragmaPricesResponse = oracle_dispatcher .get_data_median(DataType::SpotEntry(ETH_USD)); + let future_data: PragmaPricesResponse = oracle_dispatcher + .get_data_median(DataType::FutureEntry((ETH_USD, 0))); + + let current_timestamp = get_block_timestamp(); + assert( + future_data.last_updated_timestamp >= current_timestamp - 500, 'Data is too old' + ); + + let min_num_sources = 3; + assert(output.num_sources_aggregated >= min_num_sources, 'Not enough sources'); + // We only care about DEFILLAMA and COINBASE - let defillama: felt252 = 'DEFILLAMA'; - let coinbase: felt252 = 'COINBASE'; + // let defillama: felt252 = 'DEFILLAMA'; + // let coinbase: felt252 = 'COINBASE'; + let skynet: felt252 = 'SKYNET_TRADING'; - let mut sources = array![defillama, coinbase]; + let mut sources = array![skynet]; let output: PragmaPricesResponse = oracle_dispatcher .get_data_for_sources( DataType::SpotEntry(BTC_USD), AggregationMode::Median(()), sources.span() @@ -111,7 +123,7 @@ mod HackTemplate { start.into(), end.into(), num_samples, - AggregationMode::Median(()) + AggregationMode::Mean(()) ); let (mean, mean_decimals) = oracle_dispatcher @@ -119,6 +131,11 @@ mod HackTemplate { DataType::SpotEntry(key), start.into(), end.into(), AggregationMode::Median(()) ); + let (twap, twap_decimals) = oracle_dispatcher + .calculate_twap( + DataType::SpotEntry(key), AggregationMode::Mean(()), end.into(), start.into() + ); + (volatility, decimals) } }