Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor bank structs into seperate files #299

Open
wants to merge 3 commits into
base: 0.1.2-refactors
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 7 additions & 13 deletions clients/rust/marginfi-cli/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use marginfi::state::marginfi_account::TRANSFER_AUTHORITY_ALLOWED_FLAG;
use marginfi::{
prelude::*,
state::{
bank::Bank,
bank_configuration::{BankConfig, BankConfigOpt, BankOperationalState, RiskTier},
bank_interest::{InterestRateConfig, InterestRateConfigOpt},
marginfi_account::{Balance, LendingAccount, MarginfiAccount, FLASHLOAN_ENABLED_FLAG},
marginfi_group::{
Bank, BankConfig, BankConfigOpt, BankOperationalState, InterestRateConfig,
InterestRateConfigOpt, RiskTier, WrappedI80F48,
},
marginfi_group::WrappedI80F48,
},
};
use pyth_solana_receiver_sdk::price_update::get_feed_id_from_hex;
Expand Down Expand Up @@ -725,7 +725,7 @@ fn bank(subcmd: BankCommand, global_options: &GlobalOptions) -> Result<()> {
} => {
let bank = config
.mfi_program
.account::<marginfi::state::marginfi_group::Bank>(bank_pk)
.account::<marginfi::state::bank::Bank>(bank_pk)
.unwrap();
processor::bank_configure(
config,
Expand Down Expand Up @@ -824,10 +824,7 @@ fn inspect_padding() -> Result<()> {
println!("MarginfiGroup: {}", MarginfiGroup::type_layout());
println!("GroupConfig: {}", GroupConfig::type_layout());
println!("InterestRateConfig: {}", InterestRateConfig::type_layout());
println!(
"Bank: {}",
marginfi::state::marginfi_group::Bank::type_layout()
);
println!("Bank: {}", marginfi::state::bank::Bank::type_layout());
println!("BankConfig: {}", BankConfig::type_layout());
println!("BankConfigOpt: {}", BankConfigOpt::type_layout());
println!("WrappedI80F48: {}", WrappedI80F48::type_layout());
Expand All @@ -845,10 +842,7 @@ fn inspect_size() -> Result<()> {
println!("MarginfiGroup: {}", size_of::<MarginfiGroup>());
println!("GroupConfig: {}", size_of::<GroupConfig>());
println!("InterestRateConfig: {}", size_of::<InterestRateConfig>());
println!(
"Bank: {}",
size_of::<marginfi::state::marginfi_group::Bank>()
);
println!("Bank: {}", size_of::<marginfi::state::bank::Bank>());
println!("BankConfig: {}", size_of::<BankConfig>());
println!("BankConfigOpt: {}", size_of::<BankConfigOpt>());
println!("WrappedI80F48: {}", size_of::<WrappedI80F48>());
Expand Down
2 changes: 1 addition & 1 deletion clients/rust/marginfi-cli/src/processor/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anchor_spl::associated_token;
use anyhow::Result;
use marginfi::{
bank_authority_seed,
state::marginfi_group::{Bank, BankVaultType},
state::{bank::Bank, bank_configuration::BankVaultType},
};
use solana_sdk::{
instruction::Instruction, message::Message, pubkey::Pubkey, transaction::Transaction,
Expand Down
6 changes: 3 additions & 3 deletions clients/rust/marginfi-cli/src/processor/group.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{config::Config, profile::Profile, utils};
use anyhow::Result;
use log::{debug, info, warn};
use marginfi::state::marginfi_group::Bank;
use marginfi::state::bank::Bank;
use solana_address_lookup_table_program::{
instruction::{create_lookup_table, extend_lookup_table},
state::AddressLookupTable,
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn process_check_lookup_tables(
keys.push(bank.liquidity_vault);
let (vault_auth, _) = utils::find_bank_vault_authority_pda(
bank_pk,
marginfi::state::marginfi_group::BankVaultType::Liquidity,
marginfi::state::bank_configuration::BankVaultType::Liquidity,
&marginfi::ID,
);

Expand Down Expand Up @@ -221,7 +221,7 @@ pub fn process_update_lookup_tables(
keys.push(bank.liquidity_vault);
let (vault_auth, _) = utils::find_bank_vault_authority_pda(
bank_pk,
marginfi::state::marginfi_group::BankVaultType::Liquidity,
marginfi::state::bank_configuration::BankVaultType::Liquidity,
&marginfi::ID,
);

Expand Down
10 changes: 6 additions & 4 deletions clients/rust/marginfi-cli/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ use {
},
prelude::*,
state::{
marginfi_account::{BankAccountWrapper, MarginfiAccount},
marginfi_group::{
Bank, BankConfigCompact, BankConfigOpt, BankOperationalState, BankVaultType,
InterestRateConfig, WrappedI80F48,
bank::Bank,
bank_configuration::{
BankConfigCompact, BankConfigOpt, BankOperationalState, BankVaultType,
},
bank_interest::InterestRateConfig,
marginfi_account::{BankAccountWrapper, MarginfiAccount},
marginfi_group::WrappedI80F48,
price::{OraclePriceFeedAdapter, OracleSetup, PriceAdapter, PythPushOraclePriceFeed},
},
utils::NumTraitsWithTolerance,
Expand Down
3 changes: 2 additions & 1 deletion clients/rust/marginfi-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use {
PYTH_PUSH_PYTH_SPONSORED_SHARD_ID,
},
state::{
bank::Bank,
bank_configuration::{BankConfig, BankVaultType},
marginfi_account::MarginfiAccount,
marginfi_group::{Bank, BankConfig, BankVaultType},
price::PythPushOraclePriceFeed,
},
},
Expand Down
Loading
Loading