@@ -4455,6 +4455,7 @@ pub fn handle_initialize_constituent<'info>(
44554455 max_weight_deviation : i64 ,
44564456 swap_fee_min : i64 ,
44574457 swap_fee_max : i64 ,
4458+ oracle_staleness_threshold : u64 ,
44584459) -> Result < ( ) > {
44594460 let mut constituent = ctx. accounts . constituent . load_init ( ) ?;
44604461 let mut lp_pool = ctx. accounts . lp_pool . load_mut ( ) ?;
@@ -4472,12 +4473,67 @@ pub fn handle_initialize_constituent<'info>(
44724473 constituent. max_weight_deviation = max_weight_deviation;
44734474 constituent. swap_fee_min = swap_fee_min;
44744475 constituent. swap_fee_max = swap_fee_max;
4476+ constituent. oracle_staleness_threshold = oracle_staleness_threshold;
44754477 constituent. pubkey = ctx. accounts . constituent . key ( ) ;
4478+ constituent. constituent_index = ( constituent_target_weights. weights . len ( ) - 1 ) as u16 ;
44764479 lp_pool. constituents += 1 ;
44774480
44784481 Ok ( ( ) )
44794482}
44804483
4484+ #[ derive( AnchorSerialize , AnchorDeserialize , Clone , Default ) ]
4485+ pub struct ConstituentParams {
4486+ pub max_weight_deviation : Option < i64 > ,
4487+ pub swap_fee_min : Option < i64 > ,
4488+ pub swap_fee_max : Option < i64 > ,
4489+ pub oracle_staleness_threshold : Option < u64 > ,
4490+ }
4491+
4492+ pub fn handle_update_constituent_params < ' info > (
4493+ ctx : Context < UpdateConstituentParams > ,
4494+ constituent_params : ConstituentParams ,
4495+ ) -> Result < ( ) > {
4496+ let mut constituent = ctx. accounts . constituent . load_mut ( ) ?;
4497+ if constituent_params. max_weight_deviation . is_some ( ) {
4498+ msg ! (
4499+ "max_weight_deviation: {:?} -> {:?}" ,
4500+ constituent. max_weight_deviation,
4501+ constituent_params. max_weight_deviation
4502+ ) ;
4503+ constituent. max_weight_deviation = constituent_params. max_weight_deviation . unwrap ( ) ;
4504+ }
4505+
4506+ if constituent_params. swap_fee_min . is_some ( ) {
4507+ msg ! (
4508+ "swap_fee_min: {:?} -> {:?}" ,
4509+ constituent. swap_fee_min,
4510+ constituent_params. swap_fee_min
4511+ ) ;
4512+ constituent. swap_fee_min = constituent_params. swap_fee_min . unwrap ( ) ;
4513+ }
4514+
4515+ if constituent_params. swap_fee_max . is_some ( ) {
4516+ msg ! (
4517+ "swap_fee_max: {:?} -> {:?}" ,
4518+ constituent. swap_fee_max,
4519+ constituent_params. swap_fee_max
4520+ ) ;
4521+ constituent. swap_fee_max = constituent_params. swap_fee_max . unwrap ( ) ;
4522+ }
4523+
4524+ if constituent_params. oracle_staleness_threshold . is_some ( ) {
4525+ msg ! (
4526+ "oracle_staleness_threshold: {:?} -> {:?}" ,
4527+ constituent. oracle_staleness_threshold,
4528+ constituent_params. oracle_staleness_threshold
4529+ ) ;
4530+ constituent. oracle_staleness_threshold =
4531+ constituent_params. oracle_staleness_threshold . unwrap ( ) ;
4532+ }
4533+
4534+ Ok ( ( ) )
4535+ }
4536+
44814537pub fn handle_update_amm_constituent_mapping_data < ' info > (
44824538 ctx : Context < UpdateAmmConstituentMappingData > ,
44834539 amm_constituent_mapping_data : Vec < AddAmmConstituentMappingDatum > ,
@@ -5433,6 +5489,18 @@ pub struct InitializeConstituent<'info> {
54335489 pub token_program : Interface < ' info , TokenInterface > ,
54345490}
54355491
5492+ #[ derive( Accounts ) ]
5493+ pub struct UpdateConstituentParams < ' info > {
5494+ #[ account(
5495+ mut ,
5496+ constraint = admin. key( ) == admin_hot_wallet:: id( ) || admin. key( ) == state. admin
5497+ ) ]
5498+ pub admin : Signer < ' info > ,
5499+ pub state : Box < Account < ' info , State > > ,
5500+ #[ account( mut ) ]
5501+ pub constituent : AccountLoader < ' info , Constituent > ,
5502+ }
5503+
54365504#[ derive( AnchorSerialize , AnchorDeserialize , Clone , Default ) ]
54375505pub struct AddAmmConstituentMappingDatum {
54385506 pub constituent_index : u16 ,
0 commit comments