10
10
utils:: {
11
11
bank_to_oracle_key, calc_emissions_rate, create_oracle_key_array,
12
12
find_bank_emssions_auth_pda, find_bank_emssions_token_account_pda,
13
- find_bank_vault_authority_pda, find_bank_vault_pda, load_observation_account_metas ,
14
- process_transaction, EXP_10_I80F48 ,
13
+ find_bank_vault_authority_pda, find_bank_vault_pda, find_fee_state_pda ,
14
+ load_observation_account_metas , process_transaction, EXP_10_I80F48 ,
15
15
} ,
16
16
} ,
17
17
anchor_client:: {
@@ -180,10 +180,10 @@ Last Update: {:?}h ago ({})
180
180
bank. config. interest_rate_config. optimal_utilization_rate,
181
181
bank. config. interest_rate_config. plateau_interest_rate,
182
182
bank. config. interest_rate_config. max_interest_rate,
183
- bank. config. interest_rate_config. insurance_ir_fee,
184
183
bank. config. interest_rate_config. insurance_fee_fixed_apr,
185
- bank. config. interest_rate_config. protocol_ir_fee ,
184
+ bank. config. interest_rate_config. insurance_ir_fee ,
186
185
bank. config. interest_rate_config. protocol_fixed_fee_apr,
186
+ bank. config. interest_rate_config. protocol_ir_fee,
187
187
bank. config. oracle_setup,
188
188
bank. config. oracle_keys,
189
189
bank. config. get_oracle_max_age( ) ,
@@ -231,6 +231,7 @@ pub fn group_create(
231
231
. accounts ( marginfi:: accounts:: MarginfiGroupInitialize {
232
232
marginfi_group : marginfi_group_keypair. pubkey ( ) ,
233
233
admin,
234
+ fee_state : find_fee_state_pda ( & marginfi:: id ( ) ) . 0 ,
234
235
system_program : system_program:: id ( ) ,
235
236
} )
236
237
. args ( marginfi:: instruction:: MarginfiGroupInitialize { } )
@@ -312,11 +313,12 @@ pub fn group_add_bank(
312
313
max_interest_rate : f64 ,
313
314
insurance_fee_fixed_apr : f64 ,
314
315
insurance_ir_fee : f64 ,
315
- protocol_fixed_fee_apr : f64 ,
316
- protocol_ir_fee : f64 ,
316
+ group_fixed_fee_apr : f64 ,
317
+ group_ir_fee : f64 ,
317
318
risk_tier : crate :: RiskTierArg ,
318
319
oracle_max_age : u16 ,
319
320
compute_unit_price : Option < u64 > ,
321
+ global_fee_wallet : Pubkey ,
320
322
) -> Result < ( ) > {
321
323
let rpc_client = config. mfi_program . rpc ( ) ;
322
324
@@ -334,8 +336,9 @@ pub fn group_add_bank(
334
336
let max_interest_rate: WrappedI80F48 = I80F48 :: from_num ( max_interest_rate) . into ( ) ;
335
337
let insurance_fee_fixed_apr: WrappedI80F48 = I80F48 :: from_num ( insurance_fee_fixed_apr) . into ( ) ;
336
338
let insurance_ir_fee: WrappedI80F48 = I80F48 :: from_num ( insurance_ir_fee) . into ( ) ;
337
- let protocol_fixed_fee_apr: WrappedI80F48 = I80F48 :: from_num ( protocol_fixed_fee_apr) . into ( ) ;
338
- let protocol_ir_fee: WrappedI80F48 = I80F48 :: from_num ( protocol_ir_fee) . into ( ) ;
339
+ let group_fixed_fee_apr: WrappedI80F48 = I80F48 :: from_num ( group_fixed_fee_apr) . into ( ) ;
340
+ let group_ir_fee: WrappedI80F48 = I80F48 :: from_num ( group_ir_fee) . into ( ) ;
341
+
339
342
let mint_account = rpc_client. get_account ( & bank_mint) ?;
340
343
let token_program = mint_account. owner ;
341
344
let mint = spl_token_2022:: state:: Mint :: unpack (
@@ -350,8 +353,8 @@ pub fn group_add_bank(
350
353
max_interest_rate,
351
354
insurance_fee_fixed_apr,
352
355
insurance_ir_fee,
353
- protocol_fixed_fee_apr,
354
- protocol_ir_fee,
356
+ protocol_fixed_fee_apr : group_fixed_fee_apr ,
357
+ protocol_ir_fee : group_ir_fee ,
355
358
..InterestRateConfig :: default ( )
356
359
} ;
357
360
@@ -384,6 +387,7 @@ pub fn group_add_bank(
384
387
oracle_setup,
385
388
risk_tier,
386
389
oracle_max_age,
390
+ global_fee_wallet,
387
391
) ?
388
392
} else {
389
393
create_bank_ix (
@@ -404,6 +408,7 @@ pub fn group_add_bank(
404
408
oracle_setup,
405
409
risk_tier,
406
410
oracle_max_age,
411
+ global_fee_wallet,
407
412
) ?
408
413
} ;
409
414
@@ -445,6 +450,7 @@ fn create_bank_ix_with_seed(
445
450
oracle_setup : crate :: OracleTypeArg ,
446
451
risk_tier : crate :: RiskTierArg ,
447
452
oracle_max_age : u16 ,
453
+ global_fee_wallet : Pubkey ,
448
454
) -> Result < Vec < Instruction > > {
449
455
use solana_sdk:: commitment_config:: CommitmentConfig ;
450
456
@@ -514,6 +520,8 @@ fn create_bank_ix_with_seed(
514
520
token_program,
515
521
system_program : system_program:: id ( ) ,
516
522
fee_payer : config. authority ( ) ,
523
+ fee_state : find_fee_state_pda ( & config. program_id ) . 0 ,
524
+ global_fee_wallet,
517
525
} )
518
526
. accounts ( AccountMeta :: new_readonly ( oracle_key, false ) )
519
527
. args ( marginfi:: instruction:: LendingPoolAddBankWithSeed {
@@ -562,6 +570,7 @@ fn create_bank_ix(
562
570
oracle_setup : crate :: OracleTypeArg ,
563
571
risk_tier : crate :: RiskTierArg ,
564
572
oracle_max_age : u16 ,
573
+ global_fee_wallet : Pubkey ,
565
574
) -> Result < Vec < Instruction > > {
566
575
let add_bank_ixs_builder = config. mfi_program . request ( ) ;
567
576
let add_bank_ixs = add_bank_ixs_builder
@@ -610,6 +619,8 @@ fn create_bank_ix(
610
619
token_program,
611
620
system_program : system_program:: id ( ) ,
612
621
fee_payer : config. explicit_fee_payer ( ) ,
622
+ fee_state : find_fee_state_pda ( & config. program_id ) . 0 ,
623
+ global_fee_wallet,
613
624
} )
614
625
. accounts ( AccountMeta :: new_readonly ( oracle_key, false ) )
615
626
. args ( marginfi:: instruction:: LendingPoolAddBank {
@@ -988,7 +999,11 @@ pub fn bank_get(config: Config, bank_pk: Option<Pubkey>) -> Result<()> {
988
999
let rpc_client = config. mfi_program . rpc ( ) ;
989
1000
990
1001
if let Some ( address) = bank_pk {
991
- let bank: Bank = config. mfi_program . account ( address) ?;
1002
+ let mut bank: Bank = config. mfi_program . account ( address) ?;
1003
+ let group: MarginfiGroup = config. mfi_program . account ( bank. group ) ?;
1004
+
1005
+ bank. accrue_interest ( Clock :: get ( ) ?. unix_timestamp , & group) ?;
1006
+
992
1007
print_bank ( & address, & bank) ;
993
1008
994
1009
let liquidity_vault_balance =
@@ -1046,14 +1061,7 @@ fn load_all_banks(config: &Config, marginfi_group: Option<Pubkey>) -> Result<Vec
1046
1061
None => vec ! [ ] ,
1047
1062
} ;
1048
1063
1049
- let mut clock = config. mfi_program . rpc ( ) . get_account ( & sysvar:: clock:: ID ) ?;
1050
- let clock = Clock :: from_account_info ( & ( & sysvar:: clock:: ID , & mut clock) . into_account_info ( ) ) ?;
1051
-
1052
- let mut banks_with_addresses = config. mfi_program . accounts :: < Bank > ( filters) ?;
1053
-
1054
- banks_with_addresses. iter_mut ( ) . for_each ( |( _, bank) | {
1055
- bank. accrue_interest ( clock. unix_timestamp ) . unwrap ( ) ;
1056
- } ) ;
1064
+ let banks_with_addresses = config. mfi_program . accounts :: < Bank > ( filters) ?;
1057
1065
1058
1066
Ok ( banks_with_addresses)
1059
1067
}
@@ -2323,6 +2331,8 @@ pub fn marginfi_account_create(profile: &Profile, config: &Config) -> Result<()>
2323
2331
2324
2332
#[ cfg( feature = "lip" ) ]
2325
2333
pub fn process_list_lip_campaigns ( config : & Config ) {
2334
+ use liquidity_incentive_program:: state:: Campaign ;
2335
+
2326
2336
let campaings = config. lip_program . accounts :: < Campaign > ( vec ! [ ] ) . unwrap ( ) ;
2327
2337
2328
2338
print ! ( "Found {} campaigns" , campaings. len( ) ) ;
@@ -2356,6 +2366,7 @@ Max Rewards: {}
2356
2366
2357
2367
#[ cfg( feature = "lip" ) ]
2358
2368
pub fn process_list_deposits ( config : & Config ) {
2369
+ use liquidity_incentive_program:: state:: { Campaign , Deposit } ;
2359
2370
use solana_sdk:: clock:: SECONDS_PER_DAY ;
2360
2371
2361
2372
let mut deposits = config. lip_program . accounts :: < Deposit > ( vec ! [ ] ) . unwrap ( ) ;
@@ -2409,8 +2420,10 @@ Deposit start {}, end {} ({})
2409
2420
2410
2421
#[ cfg( feature = "lip" ) ]
2411
2422
fn timestamp_to_string ( timestamp : i64 ) -> String {
2423
+ use chrono:: { DateTime , Utc } ;
2424
+
2412
2425
DateTime :: < Utc > :: from_naive_utc_and_offset (
2413
- NaiveDateTime :: from_timestamp_opt ( timestamp, 0 ) . unwrap ( ) ,
2426
+ DateTime :: from_timestamp ( timestamp, 0 ) . unwrap ( ) . naive_utc ( ) ,
2414
2427
Utc ,
2415
2428
)
2416
2429
. format ( "%Y-%m-%d %H:%M:%S" )
0 commit comments