@@ -80,7 +80,9 @@ use crate::state::spot_market::{
8080 SpotMarket , TokenProgramFlag ,
8181} ;
8282use crate :: state:: spot_market_map:: get_writable_spot_market_set;
83- use crate :: state:: state:: { ExchangeStatus , FeeStructure , OracleGuardRails , State } ;
83+ use crate :: state:: state:: {
84+ ExchangeStatus , FeeStructure , LpPoolFeatureBitFlags , OracleGuardRails , State ,
85+ } ;
8486use crate :: state:: traits:: Size ;
8587use crate :: state:: user:: { User , UserStats } ;
8688use crate :: validate;
@@ -133,7 +135,8 @@ pub fn handle_initialize(ctx: Context<Initialize>) -> Result<()> {
133135 max_number_of_sub_accounts : 0 ,
134136 max_initialize_user_fee : 0 ,
135137 feature_bit_flags : 0 ,
136- padding : [ 0 ; 9 ] ,
138+ lp_pool_feature_bit_flags : 0 ,
139+ padding : [ 0 ; 8 ] ,
137140 } ;
138141
139142 Ok ( ( ) )
@@ -4761,12 +4764,24 @@ pub fn handle_initialize_lp_pool(
47614764 max_settle_quote_amount_per_market : u64 ,
47624765) -> Result < ( ) > {
47634766 let mut lp_pool = ctx. accounts . lp_pool . load_init ( ) ?;
4764- let mint = ctx. accounts . mint . key ( ) ;
4767+ let mint = & ctx. accounts . mint ;
4768+
4769+ validate ! (
4770+ mint. decimals == 6 ,
4771+ ErrorCode :: DefaultError ,
4772+ "lp mint must have 6 decimals"
4773+ ) ?;
4774+
4775+ validate ! (
4776+ mint. mint_authority == Some ( ctx. accounts. drift_signer. key( ) ) . into( ) ,
4777+ ErrorCode :: DefaultError ,
4778+ "lp mint must have drift_signer as mint authority"
4779+ ) ?;
47654780
47664781 * lp_pool = LPPool {
47674782 name,
47684783 pubkey : ctx. accounts . lp_pool . key ( ) ,
4769- mint,
4784+ mint : mint . key ( ) ,
47704785 constituents : 0 ,
47714786 max_aum,
47724787 last_aum : 0 ,
@@ -5190,11 +5205,13 @@ pub fn handle_update_feature_bit_flags_settle_lp_pool(
51905205 "Only state admin can re-enable after kill switch"
51915206 ) ?;
51925207
5193- msg ! ( "Setting third bit to 1, enabling settle LP pool" ) ;
5194- state. feature_bit_flags = state. feature_bit_flags | ( FeatureBitFlags :: SettleLpPool as u8 ) ;
5208+ msg ! ( "Setting first bit to 1, enabling settle LP pool" ) ;
5209+ state. lp_pool_feature_bit_flags =
5210+ state. lp_pool_feature_bit_flags | ( LpPoolFeatureBitFlags :: SettleLpPool as u8 ) ;
51955211 } else {
5196- msg ! ( "Setting third bit to 0, disabling settle LP pool" ) ;
5197- state. feature_bit_flags = state. feature_bit_flags & !( FeatureBitFlags :: SettleLpPool as u8 ) ;
5212+ msg ! ( "Setting first bit to 0, disabling settle LP pool" ) ;
5213+ state. lp_pool_feature_bit_flags =
5214+ state. lp_pool_feature_bit_flags & !( LpPoolFeatureBitFlags :: SettleLpPool as u8 ) ;
51985215 }
51995216 Ok ( ( ) )
52005217}
@@ -5211,11 +5228,36 @@ pub fn handle_update_feature_bit_flags_swap_lp_pool(
52115228 "Only state admin can re-enable after kill switch"
52125229 ) ?;
52135230
5214- msg ! ( "Setting fourth bit to 1, enabling swapping with LP pool" ) ;
5215- state. feature_bit_flags = state. feature_bit_flags | ( FeatureBitFlags :: SwapLpPool as u8 ) ;
5231+ msg ! ( "Setting second bit to 1, enabling swapping with LP pool" ) ;
5232+ state. lp_pool_feature_bit_flags =
5233+ state. lp_pool_feature_bit_flags | ( LpPoolFeatureBitFlags :: SwapLpPool as u8 ) ;
5234+ } else {
5235+ msg ! ( "Setting second bit to 0, disabling swapping with LP pool" ) ;
5236+ state. lp_pool_feature_bit_flags =
5237+ state. lp_pool_feature_bit_flags & !( LpPoolFeatureBitFlags :: SwapLpPool as u8 ) ;
5238+ }
5239+ Ok ( ( ) )
5240+ }
5241+
5242+ pub fn handle_update_feature_bit_flags_mint_redeem_lp_pool (
5243+ ctx : Context < HotAdminUpdateState > ,
5244+ enable : bool ,
5245+ ) -> Result < ( ) > {
5246+ let state = & mut ctx. accounts . state ;
5247+ if enable {
5248+ validate ! (
5249+ ctx. accounts. admin. key( ) . eq( & state. admin) ,
5250+ ErrorCode :: DefaultError ,
5251+ "Only state admin can re-enable after kill switch"
5252+ ) ?;
5253+
5254+ msg ! ( "Setting third bit to 1, enabling minting and redeeming with LP pool" ) ;
5255+ state. lp_pool_feature_bit_flags =
5256+ state. lp_pool_feature_bit_flags | ( LpPoolFeatureBitFlags :: MintRedeemLpPool as u8 ) ;
52165257 } else {
5217- msg ! ( "Setting fourth bit to 0, disabling swapping with LP pool" ) ;
5218- state. feature_bit_flags = state. feature_bit_flags & !( FeatureBitFlags :: SwapLpPool as u8 ) ;
5258+ msg ! ( "Setting third bit to 0, disabling minting and redeeming with LP pool" ) ;
5259+ state. lp_pool_feature_bit_flags =
5260+ state. lp_pool_feature_bit_flags & !( LpPoolFeatureBitFlags :: MintRedeemLpPool as u8 ) ;
52195261 }
52205262 Ok ( ( ) )
52215263}
@@ -6866,7 +6908,6 @@ pub struct InitializeLpPool<'info> {
68666908 payer = admin
68676909 ) ]
68686910 pub lp_pool : AccountLoader < ' info , LPPool > ,
6869-
68706911 pub mint : Account < ' info , anchor_spl:: token:: Mint > ,
68716912
68726913 #[ account(
0 commit comments