add TokenBalanceLog in token_charge_collateral_fees (#894)
* add TokenBalanceLog in token_charge_collateral_fees
* increase cu_per_charge_collateral_fees_token
(cherry picked from commit e7f9af9261
)
This commit is contained in:
parent
d2c55c23e1
commit
6b13841513
|
@ -144,7 +144,7 @@ impl Default for ComputeEstimates {
|
|||
// the base cost is mostly the division
|
||||
cu_per_charge_collateral_fees: 20_000,
|
||||
// per-chargable-token cost
|
||||
cu_per_charge_collateral_fees_token: 12_000,
|
||||
cu_per_charge_collateral_fees_token: 15_000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use anchor_lang::prelude::*;
|
|||
use fixed::types::I80F48;
|
||||
|
||||
use crate::accounts_ix::*;
|
||||
use crate::logs::{emit_stack, TokenCollateralFeeLog};
|
||||
use crate::logs::{emit_stack, TokenBalanceLog, TokenCollateralFeeLog};
|
||||
|
||||
pub fn token_charge_collateral_fees(ctx: Context<TokenChargeCollateralFees>) -> Result<()> {
|
||||
let group = ctx.accounts.group.load()?;
|
||||
|
@ -103,12 +103,25 @@ pub fn token_charge_collateral_fees(ctx: Context<TokenChargeCollateralFees>) ->
|
|||
bank.collected_fees_native += fee;
|
||||
bank.collected_collateral_fees += fee;
|
||||
|
||||
let token_info = health_cache.token_info(bank.token_index)?;
|
||||
let token_position = account.token_position(bank.token_index)?;
|
||||
|
||||
emit_stack(TokenCollateralFeeLog {
|
||||
mango_group: ctx.accounts.group.key(),
|
||||
mango_account: ctx.accounts.account.key(),
|
||||
token_index: bank.token_index,
|
||||
fee: fee.to_bits(),
|
||||
asset_usage_fraction: asset_usage_scaling.to_bits(),
|
||||
price: token_info.prices.oracle.to_bits(),
|
||||
});
|
||||
|
||||
emit_stack(TokenBalanceLog {
|
||||
mango_group: ctx.accounts.group.key(),
|
||||
mango_account: ctx.accounts.account.key(),
|
||||
token_index: bank.token_index,
|
||||
indexed_position: token_position.indexed_position.to_bits(),
|
||||
deposit_index: bank.deposit_index.to_bits(),
|
||||
borrow_index: bank.borrow_index.to_bits(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -803,6 +803,7 @@ pub struct TokenCollateralFeeLog {
|
|||
pub token_index: u16,
|
||||
pub asset_usage_fraction: i128,
|
||||
pub fee: i128,
|
||||
pub price: i128,
|
||||
}
|
||||
|
||||
#[event]
|
||||
|
|
Loading…
Reference in New Issue