File tree 1 file changed +9
-16
lines changed
1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -226,22 +226,15 @@ pub mod ekubo {
226
226
fn fetch_median_price (ref self : ContractState , yang : ContractAddress ) -> Result <Wad , felt252 > {
227
227
let quotes = self . get_quotes (yang );
228
228
229
- // if we receive what we consider a valid price from the oracle,
230
- // return it back, otherwise emit an event about the update being invalid
231
- let mut quotes_copy = quotes ;
232
- loop {
233
- match quotes_copy . pop_front () {
234
- Option :: Some (quote ) => {
235
- if quote . is_zero () {
236
- self . emit (InvalidPriceUpdate { yang , quotes });
237
- break Result :: Err (' EKB: Invalid price update' );
238
- }
239
- },
240
- Option :: None => {
241
- let price : Wad = median_of_three (quotes );
242
- break Result :: Ok (price );
243
- }
244
- };
229
+ // As long as the median price is non-zero (i.e. at least two prices are non-zero),
230
+ // it is treated as valid because liveness is prioritized for Ekubo's on-chain oracle.
231
+ // Otherwise, emit an event about the update being invalid.
232
+ let price : Wad = median_of_three (quotes );
233
+ if price . is_zero () {
234
+ self . emit (InvalidPriceUpdate { yang , quotes });
235
+ Result :: Err (' EKB: Invalid price update' )
236
+ } else {
237
+ Result :: Ok (price )
245
238
}
246
239
}
247
240
}
You can’t perform that action at this time.
0 commit comments