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(
971
971
protected_maker_limit_price_divisor : 0 ,
972
972
protected_maker_dynamic_divisor : 0 ,
973
973
lp_fee_transfer_scalar : 1 ,
974
- padding : [ 0 ; 35 ] ,
974
+ lp_status : 0 ,
975
+ padding : [ 0 ; 34 ] ,
975
976
amm : AMM {
976
977
oracle : * ctx. accounts . oracle . key ,
977
978
oracle_source,
@@ -4217,6 +4218,16 @@ pub fn handle_update_perp_market_protected_maker_params(
4217
4218
Ok ( ( ) )
4218
4219
}
4219
4220
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
+
4220
4231
#[ access_control(
4221
4232
perp_market_valid( & ctx. accounts. perp_market)
4222
4233
) ]
Original file line number Diff line number Diff line change @@ -3281,7 +3281,9 @@ pub fn handle_update_amm_cache<'c: 'info, 'info>(
3281
3281
cached_info. max_confidence_interval_multiplier =
3282
3282
perp_market. get_max_confidence_interval_multiplier ( ) ?;
3283
3283
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
+ }
3285
3287
}
3286
3288
3287
3289
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -1058,6 +1058,13 @@ pub mod drift {
1058
1058
handle_update_perp_market_expiry ( ctx, expiry_ts)
1059
1059
}
1060
1060
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
+
1061
1068
pub fn settle_expired_market_pools_to_revenue_pool (
1062
1069
ctx : Context < SettleExpiredMarketPoolsToRevenuePool > ,
1063
1070
) -> Result < ( ) > {
Original file line number Diff line number Diff line change @@ -257,7 +257,8 @@ pub struct PerpMarket {
257
257
pub protected_maker_limit_price_divisor : u8 ,
258
258
pub protected_maker_dynamic_divisor : u8 ,
259
259
pub lp_fee_transfer_scalar : u8 ,
260
- pub padding : [ u8 ; 35 ] ,
260
+ pub lp_status : u8 ,
261
+ pub padding : [ u8 ; 34 ] ,
261
262
}
262
263
263
264
impl Default for PerpMarket {
@@ -300,7 +301,8 @@ impl Default for PerpMarket {
300
301
protected_maker_limit_price_divisor : 0 ,
301
302
protected_maker_dynamic_divisor : 0 ,
302
303
lp_fee_transfer_scalar : 1 ,
303
- padding : [ 0 ; 35 ] ,
304
+ lp_status : 0 ,
305
+ padding : [ 0 ; 34 ] ,
304
306
}
305
307
}
306
308
}
@@ -1740,8 +1742,7 @@ pub struct CacheInfo {
1740
1742
pub oracle_delay : i64 ,
1741
1743
pub oracle_slot : u64 ,
1742
1744
pub oracle_source : u8 ,
1743
- pub lp_status : u8 ,
1744
- _padding : [ u8 ; 6 ] ,
1745
+ _padding : [ u8 ; 7 ] ,
1745
1746
pub oracle : Pubkey ,
1746
1747
}
1747
1748
@@ -1760,15 +1761,14 @@ impl Default for CacheInfo {
1760
1761
oracle_confidence : 0u64 ,
1761
1762
oracle_delay : 0i64 ,
1762
1763
oracle_slot : 0u64 ,
1763
- _padding : [ 0u8 ; 6 ] ,
1764
+ _padding : [ 0u8 ; 7 ] ,
1764
1765
oracle : Pubkey :: default ( ) ,
1765
1766
last_fee_pool_token_amount : 0u128 ,
1766
1767
last_net_pnl_pool_token_amount : 0i128 ,
1767
1768
last_settle_amount : 0u64 ,
1768
1769
last_settle_ts : 0i64 ,
1769
1770
oracle_source : 0u8 ,
1770
1771
quote_owed_from_lp : 0i64 ,
1771
- lp_status : 0u8 ,
1772
1772
}
1773
1773
}
1774
1774
}
Original file line number Diff line number Diff line change @@ -968,6 +968,40 @@ export class AdminClient extends DriftClient {
968
968
) ;
969
969
}
970
970
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
+
971
1005
public async moveAmmToPrice (
972
1006
perpMarketIndex : number ,
973
1007
targetPrice : BN
Original file line number Diff line number Diff line change 4805
4805
}
4806
4806
]
4807
4807
},
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
+ },
4808
4834
{
4809
4835
"name" : " settleExpiredMarketPoolsToRevenuePool" ,
4810
4836
"accounts" : [
9913
9939
"name" : " lpFeeTransferScalar" ,
9914
9940
"type" : " u8"
9915
9941
},
9942
+ {
9943
+ "name" : " lpStatus" ,
9944
+ "type" : " u8"
9945
+ },
9916
9946
{
9917
9947
"name" : " padding" ,
9918
9948
"type" : {
9919
9949
"array" : [
9920
9950
" u8" ,
9921
- 35
9951
+ 34
9922
9952
]
9923
9953
}
9924
9954
}
@@ -13072,16 +13102,12 @@
13072
13102
"name" : " oracleSource" ,
13073
13103
"type" : " u8"
13074
13104
},
13075
- {
13076
- "name" : " lpStatus" ,
13077
- "type" : " u8"
13078
- },
13079
13105
{
13080
13106
"name" : " padding" ,
13081
13107
"type" : {
13082
13108
"array" : [
13083
13109
" u8" ,
13084
- 6
13110
+ 7
13085
13111
]
13086
13112
}
13087
13113
},
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ describe('LP Pool', () => {
195
195
periodicity ,
196
196
new BN ( 200 * PEG_PRECISION . toNumber ( ) )
197
197
) ;
198
+ await adminClient . updatePerpMarketLpPoolStatus ( 0 , 1 ) ;
198
199
199
200
await adminClient . initializePerpMarket (
200
201
1 ,
@@ -204,6 +205,7 @@ describe('LP Pool', () => {
204
205
periodicity ,
205
206
new BN ( 200 * PEG_PRECISION . toNumber ( ) )
206
207
) ;
208
+ await adminClient . updatePerpMarketLpPoolStatus ( 1 , 1 ) ;
207
209
208
210
await adminClient . initializePerpMarket (
209
211
2 ,
@@ -213,6 +215,7 @@ describe('LP Pool', () => {
213
215
periodicity ,
214
216
new BN ( 200 * PEG_PRECISION . toNumber ( ) )
215
217
) ;
218
+ await adminClient . updatePerpMarketLpPoolStatus ( 2 , 1 ) ;
216
219
217
220
await adminClient . updatePerpAuctionDuration ( new BN ( 0 ) ) ;
218
221
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ describe('LP Pool', () => {
175
175
periodicity ,
176
176
new BN ( 224 * PEG_PRECISION . toNumber ( ) )
177
177
) ;
178
+ await adminClient . updatePerpMarketLpPoolStatus ( 0 , 1 ) ;
178
179
179
180
await adminClient . initializePerpMarket (
180
181
1 ,
@@ -184,6 +185,7 @@ describe('LP Pool', () => {
184
185
periodicity ,
185
186
new BN ( 224 * PEG_PRECISION . toNumber ( ) )
186
187
) ;
188
+ await adminClient . updatePerpMarketLpPoolStatus ( 1 , 1 ) ;
187
189
188
190
const optimalUtilization = SPOT_MARKET_RATE_PRECISION . div (
189
191
new BN ( 2 )
You can’t perform that action at this time.
0 commit comments