File tree Expand file tree Collapse file tree 8 files changed +99
-14
lines changed
Expand file tree Collapse file tree 8 files changed +99
-14
lines changed Original file line number Diff line number Diff line change @@ -971,7 +971,8 @@ pub fn handle_initialize_perp_market(
971971 protected_maker_limit_price_divisor : 0 ,
972972 protected_maker_dynamic_divisor : 0 ,
973973 lp_fee_transfer_scalar : 1 ,
974- padding : [ 0 ; 35 ] ,
974+ lp_status : 0 ,
975+ padding : [ 0 ; 34 ] ,
975976 amm : AMM {
976977 oracle : * ctx. accounts . oracle . key ,
977978 oracle_source,
@@ -4217,6 +4218,16 @@ pub fn handle_update_perp_market_protected_maker_params(
42174218 Ok ( ( ) )
42184219}
42194220
4221+ pub fn handle_update_perp_market_lp_pool_status (
4222+ ctx : Context < AdminUpdatePerpMarket > ,
4223+ lp_status : u8 ,
4224+ ) -> Result < ( ) > {
4225+ let perp_market = & mut load_mut ! ( ctx. accounts. perp_market) ?;
4226+ msg ! ( "perp market {}" , perp_market. market_index) ;
4227+ perp_market. lp_status = lp_status;
4228+ Ok ( ( ) )
4229+ }
4230+
42204231#[ access_control(
42214232 perp_market_valid( & ctx. accounts. perp_market)
42224233) ]
Original file line number Diff line number Diff line change @@ -3281,7 +3281,9 @@ pub fn handle_update_amm_cache<'c: 'info, 'info>(
32813281 cached_info. max_confidence_interval_multiplier =
32823282 perp_market. get_max_confidence_interval_multiplier ( ) ?;
32833283
3284- amm_cache. update_amount_owed_from_lp_pool ( & perp_market, & quote_market) ?;
3284+ if perp_market. lp_status != 0 {
3285+ amm_cache. update_amount_owed_from_lp_pool ( & perp_market, & quote_market) ?;
3286+ }
32853287 }
32863288
32873289 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -1058,6 +1058,13 @@ pub mod drift {
10581058 handle_update_perp_market_expiry ( ctx, expiry_ts)
10591059 }
10601060
1061+ pub fn update_perp_market_lp_pool_status (
1062+ ctx : Context < AdminUpdatePerpMarket > ,
1063+ lp_status : u8 ,
1064+ ) -> Result < ( ) > {
1065+ handle_update_perp_market_lp_pool_status ( ctx, lp_status)
1066+ }
1067+
10611068 pub fn settle_expired_market_pools_to_revenue_pool (
10621069 ctx : Context < SettleExpiredMarketPoolsToRevenuePool > ,
10631070 ) -> Result < ( ) > {
Original file line number Diff line number Diff line change @@ -257,7 +257,8 @@ pub struct PerpMarket {
257257 pub protected_maker_limit_price_divisor : u8 ,
258258 pub protected_maker_dynamic_divisor : u8 ,
259259 pub lp_fee_transfer_scalar : u8 ,
260- pub padding : [ u8 ; 35 ] ,
260+ pub lp_status : u8 ,
261+ pub padding : [ u8 ; 34 ] ,
261262}
262263
263264impl Default for PerpMarket {
@@ -300,7 +301,8 @@ impl Default for PerpMarket {
300301 protected_maker_limit_price_divisor : 0 ,
301302 protected_maker_dynamic_divisor : 0 ,
302303 lp_fee_transfer_scalar : 1 ,
303- padding : [ 0 ; 35 ] ,
304+ lp_status : 0 ,
305+ padding : [ 0 ; 34 ] ,
304306 }
305307 }
306308}
@@ -1740,8 +1742,7 @@ pub struct CacheInfo {
17401742 pub oracle_delay : i64 ,
17411743 pub oracle_slot : u64 ,
17421744 pub oracle_source : u8 ,
1743- pub lp_status : u8 ,
1744- _padding : [ u8 ; 6 ] ,
1745+ _padding : [ u8 ; 7 ] ,
17451746 pub oracle : Pubkey ,
17461747}
17471748
@@ -1760,15 +1761,14 @@ impl Default for CacheInfo {
17601761 oracle_confidence : 0u64 ,
17611762 oracle_delay : 0i64 ,
17621763 oracle_slot : 0u64 ,
1763- _padding : [ 0u8 ; 6 ] ,
1764+ _padding : [ 0u8 ; 7 ] ,
17641765 oracle : Pubkey :: default ( ) ,
17651766 last_fee_pool_token_amount : 0u128 ,
17661767 last_net_pnl_pool_token_amount : 0i128 ,
17671768 last_settle_amount : 0u64 ,
17681769 last_settle_ts : 0i64 ,
17691770 oracle_source : 0u8 ,
17701771 quote_owed_from_lp : 0i64 ,
1771- lp_status : 0u8 ,
17721772 }
17731773 }
17741774}
Original file line number Diff line number Diff line change @@ -968,6 +968,40 @@ export class AdminClient extends DriftClient {
968968 ) ;
969969 }
970970
971+ public async updatePerpMarketLpPoolStatus (
972+ perpMarketIndex : number ,
973+ lpStatus : number ,
974+ ) {
975+ const updatePerpMarketLpPoolStatusIx = await this . getUpdatePerpMarketLpPoolStatusIx (
976+ perpMarketIndex ,
977+ lpStatus
978+ ) ;
979+
980+ const tx = await this . buildTransaction ( updatePerpMarketLpPoolStatusIx ) ;
981+
982+ const { txSig } = await this . sendTransaction ( tx , [ ] , this . opts ) ;
983+
984+ return txSig ;
985+ }
986+
987+ public async getUpdatePerpMarketLpPoolStatusIx (
988+ perpMarketIndex : number ,
989+ lpStatus : number
990+ ) : Promise < TransactionInstruction > {
991+ return await this . program . instruction . updatePerpMarketLpPoolStatus ( lpStatus , {
992+ accounts : {
993+ state : await this . getStatePublicKey ( ) ,
994+ admin : this . isSubscribed
995+ ? this . getStateAccount ( ) . admin
996+ : this . wallet . publicKey ,
997+ perpMarket : await getPerpMarketPublicKey (
998+ this . program . programId ,
999+ perpMarketIndex
1000+ ) ,
1001+ } ,
1002+ } ) ;
1003+ }
1004+
9711005 public async moveAmmToPrice (
9721006 perpMarketIndex : number ,
9731007 targetPrice : BN
Original file line number Diff line number Diff line change 48054805 }
48064806 ]
48074807 },
4808+ {
4809+ "name" : " updatePerpMarketLpPoolStatus" ,
4810+ "accounts" : [
4811+ {
4812+ "name" : " admin" ,
4813+ "isMut" : false ,
4814+ "isSigner" : true
4815+ },
4816+ {
4817+ "name" : " state" ,
4818+ "isMut" : false ,
4819+ "isSigner" : false
4820+ },
4821+ {
4822+ "name" : " perpMarket" ,
4823+ "isMut" : true ,
4824+ "isSigner" : false
4825+ }
4826+ ],
4827+ "args" : [
4828+ {
4829+ "name" : " lpStatus" ,
4830+ "type" : " u8"
4831+ }
4832+ ]
4833+ },
48084834 {
48094835 "name" : " settleExpiredMarketPoolsToRevenuePool" ,
48104836 "accounts" : [
99139939 "name" : " lpFeeTransferScalar" ,
99149940 "type" : " u8"
99159941 },
9942+ {
9943+ "name" : " lpStatus" ,
9944+ "type" : " u8"
9945+ },
99169946 {
99179947 "name" : " padding" ,
99189948 "type" : {
99199949 "array" : [
99209950 " u8" ,
9921- 35
9951+ 34
99229952 ]
99239953 }
99249954 }
@@ -13072,16 +13102,12 @@
1307213102 "name" : " oracleSource" ,
1307313103 "type" : " u8"
1307413104 },
13075- {
13076- "name" : " lpStatus" ,
13077- "type" : " u8"
13078- },
1307913105 {
1308013106 "name" : " padding" ,
1308113107 "type" : {
1308213108 "array" : [
1308313109 " u8" ,
13084- 6
13110+ 7
1308513111 ]
1308613112 }
1308713113 },
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ describe('LP Pool', () => {
195195 periodicity ,
196196 new BN ( 200 * PEG_PRECISION . toNumber ( ) )
197197 ) ;
198+ await adminClient . updatePerpMarketLpPoolStatus ( 0 , 1 ) ;
198199
199200 await adminClient . initializePerpMarket (
200201 1 ,
@@ -204,6 +205,7 @@ describe('LP Pool', () => {
204205 periodicity ,
205206 new BN ( 200 * PEG_PRECISION . toNumber ( ) )
206207 ) ;
208+ await adminClient . updatePerpMarketLpPoolStatus ( 1 , 1 ) ;
207209
208210 await adminClient . initializePerpMarket (
209211 2 ,
@@ -213,6 +215,7 @@ describe('LP Pool', () => {
213215 periodicity ,
214216 new BN ( 200 * PEG_PRECISION . toNumber ( ) )
215217 ) ;
218+ await adminClient . updatePerpMarketLpPoolStatus ( 2 , 1 ) ;
216219
217220 await adminClient . updatePerpAuctionDuration ( new BN ( 0 ) ) ;
218221
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ describe('LP Pool', () => {
175175 periodicity ,
176176 new BN ( 224 * PEG_PRECISION . toNumber ( ) )
177177 ) ;
178+ await adminClient . updatePerpMarketLpPoolStatus ( 0 , 1 ) ;
178179
179180 await adminClient . initializePerpMarket (
180181 1 ,
@@ -184,6 +185,7 @@ describe('LP Pool', () => {
184185 periodicity ,
185186 new BN ( 224 * PEG_PRECISION . toNumber ( ) )
186187 ) ;
188+ await adminClient . updatePerpMarketLpPoolStatus ( 1 , 1 ) ;
187189
188190 const optimalUtilization = SPOT_MARKET_RATE_PRECISION . div (
189191 new BN ( 2 )
You can’t perform that action at this time.
0 commit comments