diff --git a/programs/amm/src/instructions/swap.rs b/programs/amm/src/instructions/swap.rs index 21e24873..aa08dc84 100644 --- a/programs/amm/src/instructions/swap.rs +++ b/programs/amm/src/instructions/swap.rs @@ -174,7 +174,6 @@ pub fn swap_internal<'b, 'info>( }; // check observation account is owned by the pool - require_keys_eq!(observation_state.pool_id, pool_state.key()); let (state, amount_0, amount_1) = swap_on_swap_state( &amm_config, @@ -286,39 +285,40 @@ pub fn swap_on_swap_state( .pop_front() .ok_or(ErrorCode::InsufficientTickArrayStates)?; // check tick_array account is owned by the pool - require_keys_eq!(tick_array_current.pool_id, pool_state.key()); + // require_keys_eq!(tick_array_current.pool_id, pool_state.key()); let (mut is_match_pool_current_tick_array, first_vaild_tick_array_start_index) = pool_state.get_first_initialized_tick_array(zero_for_one)?; let mut current_vaild_tick_array_start_index = first_vaild_tick_array_start_index; - let expected_first_tick_array_address = Pubkey::find_program_address( - &[ - TICK_ARRAY_SEED.as_bytes(), - pool_state.key().as_ref(), - ¤t_vaild_tick_array_start_index.to_be_bytes(), - ], - &crate::id(), - ) - .0; - - let mut tick_array_current = tick_array_states.pop_front().unwrap(); - for _ in 0..tick_array_states.len() { - // check tick_array account is owned by the pool - require_keys_eq!(tick_array_current.pool_id, pool_state.key()); - if tick_array_current.key() == expected_first_tick_array_address { - break; - } - tick_array_current = tick_array_states - .pop_front() - .ok_or(ErrorCode::NotEnoughTickArrayAccount)?; - } - // check first tick array account is correct - require_keys_eq!( - tick_array_current.key(), - expected_first_tick_array_address, - ErrorCode::InvalidFirstTickArrayAccount - ); + // Unecessary validation for quote estimation + // let expected_first_tick_array_address = Pubkey::find_program_address( + // &[ + // TICK_ARRAY_SEED.as_bytes(), + // pool_state.key().as_ref(), + // ¤t_vaild_tick_array_start_index.to_be_bytes(), + // ], + // &crate::id(), + // ) + // .0; + + // let mut tick_array_current = tick_array_states.pop_front().unwrap(); + // for _ in 0..tick_array_states.len() { + // // check tick_array account is owned by the pool + // require_keys_eq!(tick_array_current.pool_id, pool_state.key()); + // if tick_array_current.key() == expected_first_tick_array_address { + // break; + // } + // tick_array_current = tick_array_states + // .pop_front() + // .ok_or(ErrorCode::NotEnoughTickArrayAccount)?; + // } + // // check first tick array account is correct + // require_keys_eq!( + // tick_array_current.key(), + // expected_first_tick_array_address, + // ErrorCode::InvalidFirstTickArrayAccount + // ); // continue swapping as long as we haven't used the entire input/output and haven't // reached the price limit @@ -375,19 +375,6 @@ pub fn swap_on_swap_state( .pop_front() .ok_or(ErrorCode::InsufficientTickArrayStates)?; - require_keys_eq!(tick_array_current.pool_id, pool_state.key()); - require_keys_eq!( - tick_array_current.key(), - Pubkey::find_program_address( - &[ - TICK_ARRAY_SEED.as_bytes(), - pool_state.key().as_ref(), - ¤t_vaild_tick_array_start_index.to_be_bytes(), - ], - &crate::id() - ) - .0 - ); let first_initialized_tick = tick_array_current.first_initialized_tick(zero_for_one)?; next_initialized_tick = Box::new(*first_initialized_tick); }