Skip to content

Commit 7d4a635

Browse files
committed
address renaming comments
1 parent 77af05c commit 7d4a635

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

programs/drift/src/ids.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ pub mod lighthouse {
9191
declare_id!("L2TExMFKdjpN9kozasaurPirfHy9P8sbXoAN1qA3S95");
9292
}
9393

94-
pub mod usdc_mint {
95-
use solana_program::declare_id;
96-
declare_id!("BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG");
97-
}
98-
9994
pub mod mm_oracle_crank_wallet {
10095
use solana_program::declare_id;
10196
#[cfg(not(feature = "anchor-test"))]
@@ -114,4 +109,4 @@ pub mod amm_spread_adjust_wallet {
114109
declare_id!("w1DrTeayRMutAiwzfJfK9zLcpkF7RzwPy1BLCgQA1aF");
115110
#[cfg(feature = "anchor-test")]
116111
declare_id!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N");
117-
}
112+
}

programs/drift/src/instructions/lp_admin.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::controller::token::{receive, send_from_program_vault_with_signature_s
33
use crate::error::ErrorCode;
44
use crate::ids::admin_hot_wallet;
55
use crate::instructions::optional_accounts::get_token_mint;
6-
use crate::math::constants::PRICE_PRECISION_U64;
6+
use crate::math::constants::{PRICE_PRECISION_U64, QUOTE_SPOT_MARKET_INDEX};
77
use crate::math::safe_math::SafeMath;
88
use crate::state::lp_pool::{
99
AmmConstituentDatum, AmmConstituentMapping, Constituent, ConstituentCorrelations,
@@ -23,7 +23,7 @@ use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
2323

2424
use crate::ids::{
2525
jupiter_mainnet_3, jupiter_mainnet_4, jupiter_mainnet_6, lighthouse, marinade_mainnet,
26-
serum_program, usdc_mint,
26+
serum_program,
2727
};
2828

2929
use crate::state::traits::Size;
@@ -198,7 +198,7 @@ pub fn handle_initialize_constituent<'info>(
198198
constituent.xi = xi;
199199
lp_pool.constituents += 1;
200200

201-
if constituent.mint.eq(&usdc_mint::ID) {
201+
if constituent.spot_market_index == QUOTE_SPOT_MARKET_INDEX {
202202
lp_pool.quote_consituent_index = constituent.constituent_index;
203203
}
204204

@@ -389,7 +389,11 @@ pub fn handle_update_lp_pool_params<'info>(
389389
}
390390

391391
if let Some(whitelist_mint) = lp_pool_params.whitelist_mint {
392-
msg!("whitelist_mint: {:?} -> {:?}", lp_pool.whitelist_mint, whitelist_mint);
392+
msg!(
393+
"whitelist_mint: {:?} -> {:?}",
394+
lp_pool.whitelist_mint,
395+
whitelist_mint
396+
);
393397
lp_pool.whitelist_mint = whitelist_mint;
394398
}
395399

programs/drift/src/instructions/lp_pool.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use std::convert::TryFrom;
4747

4848
use solana_program::sysvar::clock::Clock;
4949

50-
use super::optional_accounts::{load_maps, AccountMaps, get_whitelist_token};
50+
use super::optional_accounts::{get_whitelist_token, load_maps, AccountMaps};
5151
use crate::controller::spot_balance::update_spot_market_cumulative_interest;
5252
use crate::controller::token::{receive, send_from_program_vault_with_signature_seeds};
5353
use crate::instructions::constraints::*;
@@ -1327,7 +1327,7 @@ pub fn handle_deposit_to_program_vault<'c: 'info, 'info>(
13271327
constituent.last_oracle_slot = oracle_data_slot;
13281328
}
13291329
constituent.sync_token_balance(ctx.accounts.constituent_token_account.amount);
1330-
let balance_before = constituent.get_full_balance(&spot_market)?;
1330+
let balance_before = constituent.get_full_token_amount(&spot_market)?;
13311331

13321332
controller::token::send_from_program_vault_with_signature_seeds(
13331333
&ctx.accounts.token_program,
@@ -1367,7 +1367,7 @@ pub fn handle_deposit_to_program_vault<'c: 'info, 'info>(
13671367
"Spot market vault amount mismatch after deposit"
13681368
)?;
13691369

1370-
let balance_after = constituent.get_full_balance(&spot_market)?;
1370+
let balance_after = constituent.get_full_token_amount(&spot_market)?;
13711371
let balance_diff_notional = if spot_market.decimals > 6 {
13721372
balance_after
13731373
.abs_diff(balance_before)
@@ -1431,7 +1431,7 @@ pub fn handle_withdraw_from_program_vault<'c: 'info, 'info>(
14311431
constituent.last_oracle_slot = oracle_data_slot;
14321432
}
14331433
constituent.sync_token_balance(ctx.accounts.constituent_token_account.amount);
1434-
let balance_before = constituent.get_full_balance(&spot_market)?;
1434+
let balance_before = constituent.get_full_token_amount(&spot_market)?;
14351435

14361436
// Can only borrow up to the max
14371437
let bl_token_balance = constituent.spot_balance.get_token_amount(&spot_market)?;
@@ -1487,7 +1487,7 @@ pub fn handle_withdraw_from_program_vault<'c: 'info, 'info>(
14871487
)?;
14881488

14891489
// Verify withdraw fully accounted for in BLPosition
1490-
let balance_after = constituent.get_full_balance(&spot_market)?;
1490+
let balance_after = constituent.get_full_token_amount(&spot_market)?;
14911491

14921492
let balance_diff_notional = if spot_market.decimals > 6 {
14931493
balance_after

programs/drift/src/state/lp_pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,13 @@ impl LPPool {
697697
let spot_market = spot_market_map.get_ref(&constituent.spot_market_index)?;
698698

699699
let constituent_aum = constituent
700-
.get_full_balance(&spot_market)?
700+
.get_full_token_amount(&spot_market)?
701701
.safe_mul(constituent.last_oracle_price as i128)?
702702
.safe_div(10_i128.pow(spot_market.decimals))?;
703703
msg!(
704704
"constituent: {}, balance: {}, aum: {}, deriv index: {}, bl token balance {}, bl balance type {}, vault balance: {}",
705705
constituent.constituent_index,
706-
constituent.get_full_balance(&spot_market)?,
706+
constituent.get_full_token_amount(&spot_market)?,
707707
constituent_aum,
708708
constituent.constituent_derivative_index,
709709
constituent.spot_balance.get_token_amount(&spot_market)?,
@@ -880,7 +880,7 @@ impl Size for Constituent {
880880
impl Constituent {
881881
/// Returns the full balance of the Constituent, the total of the amount in Constituent's token
882882
/// account and in Drift Borrow-Lend.
883-
pub fn get_full_balance(&self, spot_market: &SpotMarket) -> DriftResult<i128> {
883+
pub fn get_full_token_amount(&self, spot_market: &SpotMarket) -> DriftResult<i128> {
884884
let token_amount = self.spot_balance.get_signed_token_amount(spot_market)?;
885885
let vault_balance = self.vault_token_balance.cast::<i128>()?;
886886
token_amount.safe_add(vault_balance)
@@ -924,7 +924,7 @@ impl Constituent {
924924
token_amount: i128,
925925
) -> DriftResult<i128> {
926926
let token_precision = 10_i128.pow(self.decimals as u32);
927-
let balance = self.get_full_balance(spot_market)?.cast::<i128>()?;
927+
let balance = self.get_full_token_amount(spot_market)?.cast::<i128>()?;
928928
let amount = balance.safe_add(token_amount)?;
929929
let value_usd = amount.safe_mul(price.cast::<i128>()?)?;
930930
value_usd.safe_div(token_precision)

programs/drift/src/state/lp_pool/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ mod swap_tests {
623623
..SpotMarket::default()
624624
};
625625

626-
let full_balance = c.get_full_balance(&spot_market).unwrap();
626+
let full_balance = c.get_full_token_amount(&spot_market).unwrap();
627627
assert_eq!(full_balance, 1_000_000);
628628

629629
// 1/10 = 10%

0 commit comments

Comments
 (0)