Skip to content

Commit

Permalink
tests: print added options
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka committed Oct 1, 2024
1 parent ab37067 commit c3ee9a3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions src/traits.cairo
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -87,7 +87,7 @@ pub trait IAMM<TContractState> {
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<Option_>;
fn get_all_options(self: @TContractState, lptoken_address: ContractAddress) -> Array<Option_>;
// fn get_all_non_expired_options_with_premia(
// self: @TContractState, lptoken_address: ContractAddress
// ) -> Array<OptionWithPremia>;
Expand Down
10 changes: 10 additions & 0 deletions src/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
26 changes: 26 additions & 0 deletions tests/add_options_proposal.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Option_> = 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 (); }
}
};
}

0 comments on commit c3ee9a3

Please sign in to comment.