Skip to content

Commit

Permalink
feat: add options feed
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt committed Sep 9, 2024
1 parent c4cdeaa commit 8e05116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/abi.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet::{ContractAddress, ClassHash};
use pragma_lib::types::{
DataType, AggregationMode, Currency, Pair, PossibleEntries, Checkpoint, SimpleDataType,
PragmaPricesResponse, YieldPoint, FutureKeyStatus, RequestStatus
PragmaPricesResponse, YieldPoint, FutureKeyStatus, RequestStatus, OptionsFeedData,
};

#[starknet::interface]
Expand Down Expand Up @@ -109,6 +109,9 @@ trait ISummaryStatsABI<TContractState> {


fn get_oracle_address(self: @TContractState) -> ContractAddress;

fn get_options_data(self: @TContractState, instrument_name: felt252) -> OptionsFeedData;
fn get_options_data_hash(self: @TContractState, update_data: OptionsFeedData) -> felt252;
}

#[starknet::interface]
Expand Down
20 changes: 14 additions & 6 deletions src/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct YieldPoint {
rate: u128, // The calculated yield rate: either overnight rate
// or max(0, ((future/spot) - 1) * (365/days to future expiry))
source: felt252, // An indicator for the source (str_to_felt encode uppercase one of:
// "ON" (overnight rate),
// "ON" (overnight rate),
// "FUTURE/SPOT" (future/spot rate),
// "OTHER" (for future additional data sources))
}
Expand Down Expand Up @@ -72,6 +72,14 @@ struct EntryStorage {
price: u128,
}

#[derive(Drop, Serde, starknet::Store, Copy, Hash, PartialEq, Debug)]
struct OptionsFeedData {
instrument_name: felt252,
base_currency_id: felt252,
current_timestamp: u64,
mark_price: u128,
}


/// Data Types
/// The value is the `pair_id` of the data
Expand All @@ -85,37 +93,37 @@ enum DataType {
SpotEntry: felt252,
FutureEntry: (felt252, u64),
GenericEntry: felt252,
// OptionEntry: (felt252, felt252),
// OptionEntry: (felt252, felt252),
}

#[derive(Drop, Copy)]
enum PossibleEntryStorage {
Spot: u256, //structure SpotEntryStorage
Future: u256, //structure FutureEntryStorage
// Option: OptionEntryStorage, //structure OptionEntryStorage
// Option: OptionEntryStorage, //structure OptionEntryStorage
}

#[derive(Drop, Copy, Serde)]
enum SimpleDataType {
SpotEntry: (),
FutureEntry: (),
// OptionEntry: (),
// OptionEntry: (),
}

#[derive(Drop, Copy, Serde)]
enum PossibleEntries {
Spot: SpotEntry,
Future: FutureEntry,
Generic: GenericEntry,
// Option: OptionEntry,
// Option: OptionEntry,
}


enum ArrayEntry {
SpotEntry: Array<SpotEntry>,
FutureEntry: Array<FutureEntry>,
GenericEntry: Array<GenericEntry>,
// OptionEntry: Array<OptionEntry>,
// OptionEntry: Array<OptionEntry>,
}


Expand Down

0 comments on commit 8e05116

Please sign in to comment.