Skip to content

Commit d14dc14

Browse files
committed
clippy and whitelist changes
1 parent e6dd77a commit d14dc14

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

programs/drift/src/instructions/admin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5488,7 +5488,7 @@ pub struct InitializePerpMarket<'info> {
54885488
mut,
54895489
seeds = [AMM_POSITIONS_CACHE.as_ref()],
54905490
bump = amm_cache.bump,
5491-
realloc = AmmCache::space(amm_cache.cache.len() + 1 as usize),
5491+
realloc = AmmCache::space(amm_cache.cache.len() + 1_usize),
54925492
realloc::payer = admin,
54935493
realloc::zero = false,
54945494
)]

programs/drift/src/instructions/lp_admin.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::validate;
1919
use crate::{controller, load_mut};
2020
use anchor_lang::prelude::*;
2121
use anchor_lang::Discriminator;
22+
use anchor_spl::associated_token::AssociatedToken;
2223
use anchor_spl::token::Token;
2324
use anchor_spl::token_2022::Token2022;
2425
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
@@ -639,12 +640,6 @@ pub fn handle_begin_lp_swap<'c: 'info, 'info>(
639640

640641
// Make sure we have enough balance to do the swap
641642
let constituent_in_token_account = &ctx.accounts.constituent_in_token_account;
642-
643-
msg!("amount_in: {}", amount_in);
644-
msg!(
645-
"constituent_in_token_account.amount: {}",
646-
constituent_in_token_account.amount
647-
);
648643
validate!(
649644
amount_in <= constituent_in_token_account.amount,
650645
ErrorCode::InvalidSwap,
@@ -761,6 +756,7 @@ pub fn handle_begin_lp_swap<'c: 'info, 'info>(
761756
}
762757
} else {
763758
let mut whitelisted_programs = WHITELISTED_SWAP_PROGRAMS.to_vec();
759+
whitelisted_programs.push(AssociatedToken::id());
764760
whitelisted_programs.push(Token::id());
765761
whitelisted_programs.push(Token2022::id());
766762
whitelisted_programs.push(marinade_mainnet::ID);
@@ -1079,7 +1075,7 @@ pub struct InitializeConstituent<'info> {
10791075
mut,
10801076
seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()],
10811077
bump = constituent_target_base.bump,
1082-
realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1 as usize),
1078+
realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1_usize),
10831079
realloc::payer = admin,
10841080
realloc::zero = false,
10851081
)]
@@ -1089,7 +1085,7 @@ pub struct InitializeConstituent<'info> {
10891085
mut,
10901086
seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_ref(), lp_pool.key().as_ref()],
10911087
bump = constituent_correlations.bump,
1092-
realloc = ConstituentCorrelations::space(constituent_target_base.targets.len() + 1 as usize),
1088+
realloc = ConstituentCorrelations::space(constituent_target_base.targets.len() + 1_usize),
10931089
realloc::payer = admin,
10941090
realloc::zero = false,
10951091
)]
@@ -1214,7 +1210,7 @@ pub struct AddAmmConstituentMappingData<'info> {
12141210
mut,
12151211
seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()],
12161212
bump,
1217-
realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1 as usize),
1213+
realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1_usize),
12181214
realloc::payer = admin,
12191215
realloc::zero = false,
12201216
)]

programs/drift/src/state/lp_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ impl<'a> AccountZeroCopyMut<'a, TargetsDatum, ConstituentTargetBaseFixed> {
14541454
);
14551455
cell.target_base = target_base.cast::<i64>()?;
14561456

1457-
if slot.saturating_sub(oldest_position_slot) <= MAX_STALENESS_FOR_TARGET_CALC {
1457+
if slot.saturating_sub(oldest_position_slot) == MAX_STALENESS_FOR_TARGET_CALC {
14581458
cell.last_position_slot = slot;
14591459
} else {
14601460
msg!(

tests/lpPool.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
QUOTE_PRECISION,
2929
getLpPoolPublicKey,
3030
getAmmConstituentMappingPublicKey,
31-
encodeName,
3231
getConstituentTargetBasePublicKey,
3332
PERCENTAGE_PRECISION,
3433
PRICE_PRECISION,
@@ -1688,7 +1687,6 @@ describe('LP Pool', () => {
16881687

16891688
it('can initialize multiple lp pools', async () => {
16901689
const newLpPoolId = 1;
1691-
const newLpPoolKey = getLpPoolPublicKey(program.programId, newLpPoolId);
16921690

16931691
await adminClient.initializeLpPool(
16941692
newLpPoolId,

tests/lpPoolCUs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
QUOTE_PRECISION,
2929
getLpPoolPublicKey,
3030
getAmmConstituentMappingPublicKey,
31-
encodeName,
3231
getConstituentTargetBasePublicKey,
3332
PERCENTAGE_PRECISION,
3433
PRICE_PRECISION,

tests/lpPoolSwap.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
TestClient,
1414
QUOTE_PRECISION,
1515
getLpPoolPublicKey,
16-
encodeName,
1716
getConstituentTargetBasePublicKey,
1817
PERCENTAGE_PRECISION,
1918
PRICE_PRECISION,
@@ -503,13 +502,11 @@ describe('LP Pool', () => {
503502
expect(Number(diffOutToken)).to.be.approximately(1001298, 1);
504503

505504
console.log(
506-
`in Token: ${inTokenBalanceBefore.amount} -> ${
507-
inTokenBalanceAfter.amount
505+
`in Token: ${inTokenBalanceBefore.amount} -> ${inTokenBalanceAfter.amount
508506
} (${Number(diffInToken) / 1e6})`
509507
);
510508
console.log(
511-
`out Token: ${outTokenBalanceBefore.amount} -> ${
512-
outTokenBalanceAfter.amount
509+
`out Token: ${outTokenBalanceBefore.amount} -> ${outTokenBalanceAfter.amount
513510
} (${Number(diffOutToken) / 1e6})`
514511
);
515512
});

0 commit comments

Comments
 (0)