@@ -3,7 +3,7 @@ use starknet::ContractAddress;
3
3
#[starknet:: interface]
4
4
trait HackTemplateABI <TContractState > {
5
5
fn initializer (
6
- ref self : TContractState , pragma_contract : ContractAddress , summary_stats : ContractAddress
6
+ ref self : TContractState , pragma_contract : ContractAddress , summary_stats : ContractAddress ,
7
7
);
8
8
fn check_eth_threshold (self : @ TContractState , threshold : u32 ) -> bool ;
9
9
fn get_asset_price (self : @ TContractState , asset_id : felt252 ) -> u128 ;
@@ -19,7 +19,7 @@ mod HackTemplate {
19
19
use pragma_lib :: types :: {DataType , AggregationMode , PragmaPricesResponse };
20
20
use pragma_lib :: abi :: {
21
21
IPragmaABIDispatcher , IPragmaABIDispatcherTrait , ISummaryStatsABIDispatcher ,
22
- ISummaryStatsABIDispatcherTrait
22
+ ISummaryStatsABIDispatcherTrait ,
23
23
};
24
24
25
25
use alexandria_math :: pow;
@@ -40,7 +40,7 @@ mod HackTemplate {
40
40
fn initializer (
41
41
ref self : ContractState ,
42
42
pragma_contract : ContractAddress ,
43
- summary_stats : ContractAddress
43
+ summary_stats : ContractAddress ,
44
44
) {
45
45
if self . pragma_contract. read (). into () == 0 {
46
46
self . pragma_contract. write (pragma_contract );
@@ -53,7 +53,7 @@ mod HackTemplate {
53
53
fn check_eth_threshold (self : @ ContractState , threshold : u32 ) -> bool {
54
54
// Retrieve the oracle dispatcher
55
55
let oracle_dispatcher = IPragmaABIDispatcher {
56
- contract_address : self . pragma_contract. read ()
56
+ contract_address : self . pragma_contract. read (),
57
57
};
58
58
59
59
// Call the Oracle contract
@@ -65,7 +65,7 @@ mod HackTemplate {
65
65
66
66
let current_timestamp = get_block_timestamp ();
67
67
assert (
68
- future_data . last_updated_timestamp >= current_timestamp - 500 , ' Data is too old'
68
+ future_data . last_updated_timestamp >= current_timestamp - 500 , ' Data is too old' ,
69
69
);
70
70
71
71
let min_num_sources = 3 ;
@@ -79,7 +79,7 @@ mod HackTemplate {
79
79
let mut sources = array! [skynet ];
80
80
let output : PragmaPricesResponse = oracle_dispatcher
81
81
. get_data_for_sources (
82
- DataType :: SpotEntry (BTC_USD ), AggregationMode :: Median (()), sources . span ()
82
+ DataType :: SpotEntry (BTC_USD ), AggregationMode :: Median (()), sources . span (),
83
83
);
84
84
85
85
// Normalize based on number of decimals
@@ -94,7 +94,7 @@ mod HackTemplate {
94
94
fn get_asset_price (self : @ ContractState , asset_id : felt252 ) -> u128 {
95
95
// Retrieve the oracle dispatcher
96
96
let oracle_dispatcher = IPragmaABIDispatcher {
97
- contract_address : self . pragma_contract. read ()
97
+ contract_address : self . pragma_contract. read (),
98
98
};
99
99
100
100
// Call the Oracle contract, for a spot entry
@@ -106,7 +106,7 @@ mod HackTemplate {
106
106
107
107
fn realized_volatility (self : @ ContractState ) -> (u128 , u32 ) {
108
108
let oracle_dispatcher = ISummaryStatsABIDispatcher {
109
- contract_address : self . summary_stats. read ()
109
+ contract_address : self . summary_stats. read (),
110
110
};
111
111
112
112
let key = ' ETH/USD' ;
@@ -123,17 +123,17 @@ mod HackTemplate {
123
123
start . into (),
124
124
end . into (),
125
125
num_samples ,
126
- AggregationMode :: Mean (())
126
+ AggregationMode :: Mean (()),
127
127
);
128
128
129
129
let (mean , mean_decimals ) = oracle_dispatcher
130
130
. calculate_mean (
131
- DataType :: SpotEntry (key ), start . into (), end . into (), AggregationMode :: Median (())
131
+ DataType :: SpotEntry (key ), start . into (), end . into (), AggregationMode :: Median (()),
132
132
);
133
133
134
134
let (twap , twap_decimals ) = oracle_dispatcher
135
135
. calculate_twap (
136
- DataType :: SpotEntry (key ), AggregationMode :: Mean (()), end . into (), start . into ()
136
+ DataType :: SpotEntry (key ), AggregationMode :: Mean (()), end . into (), start . into (),
137
137
);
138
138
139
139
(volatility , decimals )
0 commit comments