Skip to content

Commit 71dd9c1

Browse files
committed
create separate hot wallet for lp pool
1 parent 4b5735a commit 71dd9c1

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

programs/drift/src/ids.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ pub mod titan_mainnet_argos_v1 {
123123
declare_id!("T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT");
124124
}
125125

126+
pub mod lp_pool_hot_wallet {
127+
use solana_program::declare_id;
128+
declare_id!("GP9qHLX8rx4BgRULGPV1poWQPdGuzbxGbvTB12DfmwFk");
129+
}
130+
126131
pub const WHITELISTED_SWAP_PROGRAMS: &[solana_program::pubkey::Pubkey] = &[
127132
serum_program::id(),
128133
jupiter_mainnet_3::id(),

programs/drift/src/instructions/lp_admin.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::controller::token::{receive, send_from_program_vault_with_signature_seeds};
22
use crate::error::ErrorCode;
3-
use crate::ids::{admin_hot_wallet, lp_pool_swap_wallet, WHITELISTED_SWAP_PROGRAMS};
3+
use crate::ids::{lp_pool_hot_wallet, lp_pool_swap_wallet, WHITELISTED_SWAP_PROGRAMS};
44
use crate::instructions::optional_accounts::{get_token_mint, load_maps, AccountMaps};
55
use crate::math::constants::{PRICE_PRECISION_U64, QUOTE_SPOT_MARKET_INDEX};
66
use crate::math::safe_math::SafeMath;
@@ -597,7 +597,7 @@ pub fn handle_begin_lp_swap<'c: 'info, 'info>(
597597
{
598598
let state = &ctx.accounts.state;
599599
validate!(
600-
admin.key() == admin_hot_wallet::id() || admin.key() == state.admin,
600+
admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin,
601601
ErrorCode::Unauthorized,
602602
"Wrong signer for lp taker swap"
603603
)?;
@@ -1001,7 +1001,10 @@ pub fn handle_override_amm_cache_info<'c: 'info, 'info>(
10011001
id: u8,
10021002
)]
10031003
pub struct InitializeLpPool<'info> {
1004-
#[account(mut)]
1004+
#[account(
1005+
mut,
1006+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
1007+
)]
10051008
pub admin: Signer<'info>,
10061009
#[account(
10071010
init,
@@ -1050,9 +1053,6 @@ pub struct InitializeLpPool<'info> {
10501053
)]
10511054
pub constituent_correlations: Box<Account<'info, ConstituentCorrelations>>,
10521055

1053-
#[account(
1054-
has_one = admin
1055-
)]
10561056
pub state: Box<Account<'info, State>>,
10571057
pub token_program: Program<'info, Token>,
10581058

@@ -1068,7 +1068,7 @@ pub struct InitializeConstituent<'info> {
10681068
pub state: Box<Account<'info, State>>,
10691069
#[account(
10701070
mut,
1071-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1071+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
10721072
)]
10731073
pub admin: Signer<'info>,
10741074

@@ -1138,7 +1138,7 @@ pub struct UpdateConstituentParams<'info> {
11381138
pub constituent_target_base: Box<Account<'info, ConstituentTargetBase>>,
11391139
#[account(
11401140
mut,
1141-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1141+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
11421142
)]
11431143
pub admin: Signer<'info>,
11441144
pub state: Box<Account<'info, State>>,
@@ -1162,7 +1162,7 @@ pub struct UpdateConstituentStatus<'info> {
11621162
pub struct UpdateConstituentPausedOperations<'info> {
11631163
#[account(
11641164
mut,
1165-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1165+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
11661166
)]
11671167
pub admin: Signer<'info>,
11681168
pub state: Box<Account<'info, State>>,
@@ -1176,7 +1176,7 @@ pub struct UpdateLpPoolParams<'info> {
11761176
pub lp_pool: AccountLoader<'info, LPPool>,
11771177
#[account(
11781178
mut,
1179-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1179+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
11801180
)]
11811181
pub admin: Signer<'info>,
11821182
pub state: Box<Account<'info, State>>,
@@ -1196,7 +1196,7 @@ pub struct AddAmmConstituentMappingDatum {
11961196
pub struct AddAmmConstituentMappingData<'info> {
11971197
#[account(
11981198
mut,
1199-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1199+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
12001200
)]
12011201
pub admin: Signer<'info>,
12021202
pub lp_pool: AccountLoader<'info, LPPool>,
@@ -1230,7 +1230,7 @@ pub struct AddAmmConstituentMappingData<'info> {
12301230
pub struct UpdateAmmConstituentMappingData<'info> {
12311231
#[account(
12321232
mut,
1233-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1233+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
12341234
)]
12351235
pub admin: Signer<'info>,
12361236
pub lp_pool: AccountLoader<'info, LPPool>,
@@ -1249,7 +1249,7 @@ pub struct UpdateAmmConstituentMappingData<'info> {
12491249
pub struct RemoveAmmConstituentMappingData<'info> {
12501250
#[account(
12511251
mut,
1252-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1252+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
12531253
)]
12541254
pub admin: Signer<'info>,
12551255
pub lp_pool: AccountLoader<'info, LPPool>,
@@ -1271,7 +1271,7 @@ pub struct RemoveAmmConstituentMappingData<'info> {
12711271
pub struct UpdateConstituentCorrelation<'info> {
12721272
#[account(
12731273
mut,
1274-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1274+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
12751275
)]
12761276
pub admin: Signer<'info>,
12771277
pub lp_pool: AccountLoader<'info, LPPool>,
@@ -1294,7 +1294,7 @@ pub struct LPTakerSwap<'info> {
12941294
pub state: Box<Account<'info, State>>,
12951295
#[account(
12961296
mut,
1297-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == lp_pool_swap_wallet::id() || admin.key() == state.admin
1297+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == lp_pool_swap_wallet::id() || admin.key() == state.admin
12981298
)]
12991299
pub admin: Signer<'info>,
13001300
/// Signer token accounts
@@ -1363,7 +1363,7 @@ pub struct UpdatePerpMarketLpPoolStatus<'info> {
13631363
pub struct UpdateInitialAmmCacheInfo<'info> {
13641364
#[account(
13651365
mut,
1366-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1366+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
13671367
)]
13681368
pub state: Box<Account<'info, State>>,
13691369
pub admin: Signer<'info>,
@@ -1379,7 +1379,7 @@ pub struct UpdateInitialAmmCacheInfo<'info> {
13791379
pub struct ResetAmmCache<'info> {
13801380
#[account(
13811381
mut,
1382-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
1382+
constraint = admin.key() == lp_pool_hot_wallet::id() || admin.key() == state.admin
13831383
)]
13841384
pub admin: Signer<'info>,
13851385
pub state: Box<Account<'info, State>>,

0 commit comments

Comments
 (0)