From c3ee9a3c133ce5859cd51051cf796925711db542 Mon Sep 17 00:00:00 2001 From: DaveVodrazka Date: Tue, 1 Oct 2024 13:12:46 +0200 Subject: [PATCH] tests: print added options --- src/lib.cairo | 2 +- src/traits.cairo | 4 ++-- src/types.cairo | 10 ++++++++++ tests/add_options_proposal.cairo | 26 ++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/lib.cairo b/src/lib.cairo index f5aa700..ede816e 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -5,7 +5,7 @@ mod options; pub mod proposals; pub mod staking; pub mod traits; -mod types; +pub mod types; mod upgrades; pub mod vecarm; mod arbitrary_proposal_add_options; diff --git a/src/traits.cairo b/src/traits.cairo index ce144ac..844e727 100644 --- a/src/traits.cairo +++ b/src/traits.cairo @@ -1,4 +1,4 @@ -use amm_governance::types::{OptionType, OptionSide}; +use amm_governance::types::{OptionType, OptionSide, Option_}; use cubit::f128::types::{Fixed, FixedTrait}; use starknet::{ContractAddress, ClassHash}; @@ -87,7 +87,7 @@ pub trait IAMM { self: @TContractState, lptoken_addr: ContractAddress, lpt_amt: u256 ) -> u256; fn get_available_lptoken_addresses(self: @TContractState, order_i: felt252) -> ContractAddress; - // fn get_all_options(self: @TContractState, lptoken_address: ContractAddress) -> Array; + fn get_all_options(self: @TContractState, lptoken_address: ContractAddress) -> Array; // fn get_all_non_expired_options_with_premia( // self: @TContractState, lptoken_address: ContractAddress // ) -> Array; diff --git a/src/types.cairo b/src/types.cairo index 33e06d0..ed197f7 100644 --- a/src/types.cairo +++ b/src/types.cairo @@ -17,3 +17,13 @@ pub struct FutureOption { pub base_token_address: ContractAddress, pub initial_volatility: Fixed } + +#[derive(Copy, Drop, Serde)] +pub struct Option_ { + pub option_side: OptionSide, + pub maturity: u64, + pub strike_price: Fixed, + pub quote_token_address: ContractAddress, + pub base_token_address: ContractAddress, + pub option_type: OptionType +} diff --git a/tests/add_options_proposal.cairo b/tests/add_options_proposal.cairo index 67bef57..cb988a7 100644 --- a/tests/add_options_proposal.cairo +++ b/tests/add_options_proposal.cairo @@ -6,6 +6,7 @@ use starknet::{ContractAddress, get_block_timestamp}; use amm_governance::proposals::{IProposalsDispatcherTrait, IProposalsDispatcher}; use amm_governance::traits::{IAMMDispatcher, IAMMDispatcherTrait}; +use amm_governance::types::Option_; use konoha::upgrades::IUpgradesDispatcher; use konoha::upgrades::IUpgradesDispatcherTrait; @@ -150,4 +151,29 @@ fn test_add_custom_proposal() { upgrades.apply_passed_proposal(prop_id2); println!("options added"); + + // # VALIDATED THAT CORRECT OPTIONS WERE ADDED + + let strk_usdc_call_lp_address: ContractAddress = 0x2b629088a1d30019ef18b893cebab236f84a365402fa0df2f51ec6a01506b1d.try_into().unwrap(); + let mut all_strk_usdc_call_options: Array = amm.get_all_options(strk_usdc_call_lp_address); + + // TODO: validate that the options that were added are there + loop { + match all_strk_usdc_call_options.pop_front() { + Option::Some(option) => { + // only print the new options + if option.maturity == 1734047999 { + // TODO: right now just read it from the console + println!("OPTION"); + println!("strike: {:?}", option.strike_price.mag); + println!("quote: {:?}", option.quote_token_address); + println!("base: {:?}", option.base_token_address); + println!("type: {:?}", option.option_type); + println!("side: {:?}", option.option_side); + println!("maturity: {:?}", option.maturity); + } + }, + Option::None(()) => { break (); } + } + }; }