@@ -60,11 +60,23 @@ mod HackTemplate {
60
60
let output : PragmaPricesResponse = oracle_dispatcher
61
61
. get_data_median (DataType :: SpotEntry (ETH_USD ));
62
62
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
+
63
74
// 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' ;
66
78
67
- let mut sources = array! [defillama , coinbase ];
79
+ let mut sources = array! [skynet ];
68
80
let output : PragmaPricesResponse = oracle_dispatcher
69
81
. get_data_for_sources (
70
82
DataType :: SpotEntry (BTC_USD ), AggregationMode :: Median (()), sources . span ()
@@ -111,14 +123,19 @@ mod HackTemplate {
111
123
start . into (),
112
124
end . into (),
113
125
num_samples ,
114
- AggregationMode :: Median (())
126
+ AggregationMode :: Mean (())
115
127
);
116
128
117
129
let (mean , mean_decimals ) = oracle_dispatcher
118
130
. calculate_mean (
119
131
DataType :: SpotEntry (key ), start . into (), end . into (), AggregationMode :: Median (())
120
132
);
121
133
134
+ let (twap , twap_decimals ) = oracle_dispatcher
135
+ . calculate_twap (
136
+ DataType :: SpotEntry (key ), AggregationMode :: Mean (()), end . into (), start . into ()
137
+ );
138
+
122
139
(volatility , decimals )
123
140
}
124
141
}
0 commit comments