Skip to content

Commit 6ce16da

Browse files
committed
program: subaccount-stake-for-users-stats
1 parent e67e532 commit 6ce16da

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

programs/drift/src/instructions/user.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::instructions::optional_accounts::{
3232
};
3333
use crate::instructions::SpotFulfillmentType;
3434
use crate::math::casting::Cast;
35+
use crate::math::constants::GOV_SPOT_MARKET_INDEX;
3536
use crate::math::liquidation::is_user_being_liquidated;
3637
use crate::math::margin::calculate_margin_requirement_and_total_collateral_and_liability_info;
3738
use crate::math::margin::meets_initial_margin_requirement;
@@ -852,6 +853,10 @@ pub fn handle_withdraw<'c: 'info, 'info>(
852853

853854
spot_market.validate_max_token_deposits_and_borrows(is_borrow)?;
854855

856+
if spot_market.market_index == GOV_SPOT_MARKET_INDEX && user_stats.gov_stake_sub_account_active()? {
857+
user_stats.update_gov_stake()?;
858+
}
859+
855860
Ok(())
856861
}
857862

programs/drift/src/state/user.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,8 @@ pub struct UserStats {
16541654
/// Second bit: 1 if user was referred, 0 otherwise
16551655
pub referrer_status: u8,
16561656
pub disable_update_perp_bid_ask_twap: bool,
1657-
pub padding1: [u8; 1],
1657+
// use user subaccount for if_staked_gov_token_amount value (-1 is sub_account 0)
1658+
pub gov_stake_sub_account: i8,
16581659
/// whether the user has a FuelOverflow account
16591660
pub fuel_overflow_status: u8,
16601661
/// accumulated fuel for token amounts of insurance

0 commit comments

Comments
 (0)