Skip to content

Commit a814f7b

Browse files
committed
fix max withdrawals bug
1 parent 9d7a2b6 commit a814f7b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

programs/drift/src/instructions/lp_admin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ pub struct LPTakerSwap<'info> {
12791279
pub state: Box<Account<'info, State>>,
12801280
#[account(
12811281
mut,
1282-
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == lp_pool_swap_wallet::id()
1282+
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == lp_pool_swap_wallet::id() || admin.key() == state.admin
12831283
)]
12841284
pub admin: Signer<'info>,
12851285
/// Signer token accounts

programs/drift/src/state/lp_pool.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,13 +978,12 @@ impl Constituent {
978978

979979
pub fn get_max_transfer(&self, spot_market: &SpotMarket) -> DriftResult<u64> {
980980
let token_amount = self.get_full_token_amount(spot_market)?;
981-
982-
let max_transfer = if self.spot_balance.balance_type == SpotBalanceType::Borrow {
981+
let max_transfer = if token_amount < 0 {
983982
self.max_borrow_token_amount
984-
.saturating_sub(token_amount as u64)
983+
.saturating_sub(token_amount.cast::<u64>()?)
985984
} else {
986985
self.max_borrow_token_amount
987-
.saturating_add(token_amount as u64)
986+
.saturating_add(token_amount.cast::<u64>()?)
988987
};
989988

990989
Ok(max_transfer)

0 commit comments

Comments
 (0)