Skip to content

Commit

Permalink
feat: conversion rate for checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyRo1 committed Dec 17, 2024
1 parent 44f2ff8 commit adac57a
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 77 deletions.
14 changes: 9 additions & 5 deletions pragma-oracle/src/oracle/oracle.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ mod Oracle {
// Get quote currency and pool
let quote_asset: felt252 = self.get_pair(asset).quote_currency_id;
assert(quote_asset != 0, 'Asset not registered');
let pool_address: ContractAddress = self.tokenized_vault.read((quote_asset, 'STRK'));
let pool_address: ContractAddress = self
.tokenized_vault
.read((quote_asset, 'STRK'));
assert(
pool_address != starknet::contract_address_const::<0>(),
'No pool address for given token'
Expand Down Expand Up @@ -1842,10 +1844,12 @@ mod Oracle {
fn set_checkpoint(
ref self: ContractState, data_type: DataType, aggregation_mode: AggregationMode
) {
let mut sources = ArrayTrait::<felt252>::new().span();
let priceResponse = IOracleABI::get_data_for_sources(
@self, data_type, aggregation_mode, sources
);
let priceResponse = if (aggregation_mode == AggregationMode::ConversionRate) {
self.get_data(data_type, aggregation_mode)
} else {
let mut sources = ArrayTrait::<felt252>::new().span();
IOracleABI::get_data_for_sources(@self, data_type, aggregation_mode, sources)
};
assert(!priceResponse.last_updated_timestamp.is_zero(), 'No checkpoint available');

let sources_threshold = self.oracle_sources_threshold_storage.read();
Expand Down
Loading

0 comments on commit adac57a

Please sign in to comment.