Skip to content

Commit

Permalink
Boilerplate for global fees
Browse files Browse the repository at this point in the history
  • Loading branch information
jgur-psyops committed Aug 27, 2024
1 parent 24dfeb1 commit 33eae0f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions programs/marginfi/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub const LIQUIDITY_VAULT_SEED: &str = "liquidity_vault";
pub const INSURANCE_VAULT_SEED: &str = "insurance_vault";
pub const FEE_VAULT_SEED: &str = "fee_vault";

pub const FEE_STATE_SEED: &str = "feestate";

pub const EMISSIONS_AUTH_SEED: &str = "emissions_auth_seed";
pub const EMISSIONS_TOKEN_ACCOUNT_SEED: &str = "emissions_token_account_seed";

Expand Down
35 changes: 35 additions & 0 deletions programs/marginfi/src/state/fee_state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use anchor_lang::prelude::*;

use crate::{assert_struct_align, assert_struct_size};

assert_struct_size!(FeeState, 256);
assert_struct_align!(FeeState, 8);

/// Unique per-program. The Program Owner uses this account to administrate fees collected by the protocol
#[account(zero_copy)]
#[repr(C)]
pub struct FeeState {
/// The fee state's own key. A PDA derived from just `b"feestate"`
pub key: Pubkey,
/// Can modify fees
pub global_fee_admin: Pubkey,
/// The base wallet for all protocol fees. All SOL fees go to this wallet. All non-SOL fees go
/// to the cannonical ATA of this wallet for that asset.
pub global_fee_wallet: Pubkey,
// Reserved for future use, forces 8-byte alignment
pub placeholder0: u64,
/// Flat fee assessed when a new bank is initialized, in lamports.
/// * In SOL, in native decimals.
pub bank_init_flat_sol_fee: u32,
pub bump_seed: u8,
// Pad to next 8-byte multiple
_padding0: [u8; 4],
// Pad to 128 bytes
_padding1: [u8; 15],
// Reserved for future use
_reserved0: [u8; 128],
}

impl FeeState {
pub const LEN: usize = std::mem::size_of::<FeeState>();
}
1 change: 1 addition & 0 deletions programs/marginfi/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod fee_state;
pub mod marginfi_account;
pub mod marginfi_group;
pub mod price;

0 comments on commit 33eae0f

Please sign in to comment.