log old and new in edit ixs (#418)
* log old and new in edit ixs Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fix Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fixes from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
8f8f87727d
commit
dae02885c2
|
@ -60,14 +60,23 @@ pub fn perp_edit_market(
|
|||
let mut require_group_admin = false;
|
||||
|
||||
if let Some(oracle_config) = oracle_config_opt {
|
||||
msg!(
|
||||
"Oracle config: old - conf_filter {:?}, max_staleness_slots {:?}, new - conf_filter {:?}, max_staleness_slots {:?}",
|
||||
perp_market.oracle_config.conf_filter,
|
||||
perp_market.oracle_config.max_staleness_slots,
|
||||
oracle_config.conf_filter,
|
||||
oracle_config.max_staleness_slots
|
||||
);
|
||||
perp_market.oracle_config = oracle_config.to_oracle_config();
|
||||
require_group_admin = true;
|
||||
};
|
||||
if let Some(oracle) = oracle_opt {
|
||||
msg!("Oracle: old - {:?}, new - {:?}", perp_market.oracle, oracle);
|
||||
perp_market.oracle = oracle;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if reset_stable_price {
|
||||
msg!("Stable price reset");
|
||||
require_keys_eq!(perp_market.oracle, ctx.accounts.oracle.key());
|
||||
let oracle_price = perp_market
|
||||
.oracle_price(&AccountInfoRef::borrow(ctx.accounts.oracle.as_ref())?, None)?;
|
||||
|
@ -79,10 +88,20 @@ pub fn perp_edit_market(
|
|||
}
|
||||
|
||||
if let Some(maint_base_asset_weight) = maint_base_asset_weight_opt {
|
||||
msg!(
|
||||
"Maint base asset weight: old - {:?}, new - {:?}",
|
||||
perp_market.maint_base_asset_weight,
|
||||
maint_base_asset_weight
|
||||
);
|
||||
perp_market.maint_base_asset_weight = I80F48::from_num(maint_base_asset_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(init_base_asset_weight) = init_base_asset_weight_opt {
|
||||
msg!(
|
||||
"Init base asset weight: old - {:?}, new - {:?}",
|
||||
perp_market.init_base_asset_weight,
|
||||
init_base_asset_weight
|
||||
);
|
||||
require_gte!(
|
||||
init_base_asset_weight,
|
||||
0.0,
|
||||
|
@ -98,99 +117,209 @@ pub fn perp_edit_market(
|
|||
}
|
||||
}
|
||||
if let Some(maint_base_liab_weight) = maint_base_liab_weight_opt {
|
||||
msg!(
|
||||
"Maint base liab weight: old - {:?}, new - {:?}",
|
||||
perp_market.maint_base_liab_weight,
|
||||
maint_base_liab_weight
|
||||
);
|
||||
perp_market.maint_base_liab_weight = I80F48::from_num(maint_base_liab_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(init_base_liab_weight) = init_base_liab_weight_opt {
|
||||
msg!(
|
||||
"Init base liab weight: old - {:?}, new - {:?}",
|
||||
perp_market.init_base_liab_weight,
|
||||
init_base_liab_weight
|
||||
);
|
||||
perp_market.init_base_liab_weight = I80F48::from_num(init_base_liab_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(maint_pnl_asset_weight) = maint_pnl_asset_weight_opt {
|
||||
msg!(
|
||||
"Maint pnl asset weight: old - {:?}, new - {:?}",
|
||||
perp_market.maint_pnl_asset_weight,
|
||||
maint_pnl_asset_weight
|
||||
);
|
||||
perp_market.maint_pnl_asset_weight = I80F48::from_num(maint_pnl_asset_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(init_pnl_asset_weight) = init_pnl_asset_weight_opt {
|
||||
msg!(
|
||||
"Init pnl asset weight: old - {:?}, new - {:?}",
|
||||
perp_market.init_pnl_asset_weight,
|
||||
init_pnl_asset_weight
|
||||
);
|
||||
perp_market.init_pnl_asset_weight = I80F48::from_num(init_pnl_asset_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(liquidation_fee) = liquidation_fee_opt {
|
||||
msg!(
|
||||
"Liquidation fee: old - {:?}, new - {:?}",
|
||||
perp_market.liquidation_fee,
|
||||
liquidation_fee
|
||||
);
|
||||
perp_market.liquidation_fee = I80F48::from_num(liquidation_fee);
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(maker_fee) = maker_fee_opt {
|
||||
msg!(
|
||||
"Maker fee: old - {:?}, new - {:?}",
|
||||
perp_market.maker_fee,
|
||||
maker_fee
|
||||
);
|
||||
perp_market.maker_fee = I80F48::from_num(maker_fee);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(taker_fee) = taker_fee_opt {
|
||||
msg!(
|
||||
"Taker fee: old - {:?}, new - {:?}",
|
||||
perp_market.taker_fee,
|
||||
taker_fee
|
||||
);
|
||||
perp_market.taker_fee = I80F48::from_num(taker_fee);
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(min_funding) = min_funding_opt {
|
||||
msg!(
|
||||
"Min funding: old - {:?}, new - {:?}",
|
||||
perp_market.min_funding,
|
||||
min_funding
|
||||
);
|
||||
perp_market.min_funding = I80F48::from_num(min_funding);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(max_funding) = max_funding_opt {
|
||||
msg!(
|
||||
"Max funding: old - {:?}, new - {:?}",
|
||||
perp_market.max_funding,
|
||||
max_funding
|
||||
);
|
||||
perp_market.max_funding = I80F48::from_num(max_funding);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(impact_quantity) = impact_quantity_opt {
|
||||
msg!(
|
||||
"Impact quantity: old - {:?}, new - {:?}",
|
||||
perp_market.impact_quantity,
|
||||
impact_quantity
|
||||
);
|
||||
perp_market.impact_quantity = impact_quantity;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(fee_penalty) = fee_penalty_opt {
|
||||
msg!(
|
||||
"Fee penalty: old - {:?}, new - {:?}",
|
||||
perp_market.fee_penalty,
|
||||
fee_penalty
|
||||
);
|
||||
perp_market.fee_penalty = fee_penalty;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(base_decimals) = base_decimals_opt {
|
||||
msg!(
|
||||
"Base decimals: old - {:?}, new - {:?}",
|
||||
perp_market.base_decimals,
|
||||
base_decimals
|
||||
);
|
||||
perp_market.base_decimals = base_decimals;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(group_insurance_fund) = group_insurance_fund_opt {
|
||||
msg!(
|
||||
"Group insurance fund: old - {:?}, new - {:?}",
|
||||
perp_market.group_insurance_fund,
|
||||
group_insurance_fund
|
||||
);
|
||||
perp_market.set_elligible_for_group_insurance_fund(group_insurance_fund);
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(settle_fee_flat) = settle_fee_flat_opt {
|
||||
msg!(
|
||||
"Settle fee flat: old - {:?}, new - {:?}",
|
||||
perp_market.settle_fee_flat,
|
||||
settle_fee_flat
|
||||
);
|
||||
perp_market.settle_fee_flat = settle_fee_flat;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(settle_fee_amount_threshold) = settle_fee_amount_threshold_opt {
|
||||
msg!(
|
||||
"Settle fee amount threshold: old - {:?}, new - {:?}",
|
||||
perp_market.settle_fee_amount_threshold,
|
||||
settle_fee_amount_threshold
|
||||
);
|
||||
perp_market.settle_fee_amount_threshold = settle_fee_amount_threshold;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(settle_fee_fraction_low_health) = settle_fee_fraction_low_health_opt {
|
||||
msg!(
|
||||
"Settle fee fraction low health: old - {:?}, new - {:?}",
|
||||
perp_market.settle_fee_fraction_low_health,
|
||||
settle_fee_fraction_low_health
|
||||
);
|
||||
perp_market.settle_fee_fraction_low_health = settle_fee_fraction_low_health;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(stable_price_delay_interval_seconds) = stable_price_delay_interval_seconds_opt {
|
||||
// Updating this makes the old delay values slightly inconsistent
|
||||
msg!(
|
||||
"Stable price delay interval seconds: old - {:?}, new - {:?}",
|
||||
perp_market.stable_price_model.delay_interval_seconds,
|
||||
stable_price_delay_interval_seconds
|
||||
);
|
||||
perp_market.stable_price_model.delay_interval_seconds = stable_price_delay_interval_seconds;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(stable_price_delay_growth_limit) = stable_price_delay_growth_limit_opt {
|
||||
msg!(
|
||||
"Stable price delay growth limit: old - {:?}, new - {:?}",
|
||||
perp_market.stable_price_model.delay_growth_limit,
|
||||
stable_price_delay_growth_limit
|
||||
);
|
||||
perp_market.stable_price_model.delay_growth_limit = stable_price_delay_growth_limit;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(stable_price_growth_limit) = stable_price_growth_limit_opt {
|
||||
msg!(
|
||||
"Stable price growth limit: old - {:?}, new - {:?}",
|
||||
perp_market.stable_price_model.stable_growth_limit,
|
||||
stable_price_growth_limit
|
||||
);
|
||||
perp_market.stable_price_model.stable_growth_limit = stable_price_growth_limit;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(settle_pnl_limit_factor_opt) = settle_pnl_limit_factor_opt {
|
||||
perp_market.settle_pnl_limit_factor = settle_pnl_limit_factor_opt;
|
||||
if let Some(settle_pnl_limit_factor) = settle_pnl_limit_factor_opt {
|
||||
msg!(
|
||||
"Settle pnl limit factor: old - {:?}, new - {:?}",
|
||||
perp_market.settle_pnl_limit_factor,
|
||||
settle_pnl_limit_factor
|
||||
);
|
||||
perp_market.settle_pnl_limit_factor = settle_pnl_limit_factor;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(settle_pnl_limit_window_size_ts) = settle_pnl_limit_window_size_ts_opt {
|
||||
msg!(
|
||||
"Settle pnl limit window size ts: old - {:?}, new - {:?}",
|
||||
perp_market.settle_pnl_limit_window_size_ts,
|
||||
settle_pnl_limit_window_size_ts
|
||||
);
|
||||
perp_market.settle_pnl_limit_window_size_ts = settle_pnl_limit_window_size_ts;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(reduce_only) = reduce_only_opt {
|
||||
msg!(
|
||||
"Reduce only: old - {:?}, new - {:?}",
|
||||
perp_market.reduce_only,
|
||||
u8::from(reduce_only)
|
||||
);
|
||||
perp_market.reduce_only = u8::from(reduce_only);
|
||||
|
||||
// security admin can only enable reduce_only
|
||||
|
|
|
@ -23,8 +23,15 @@ pub fn serum3_edit_market(
|
|||
ctx: Context<Serum3EditMarket>,
|
||||
reduce_only_opt: Option<bool>,
|
||||
) -> Result<()> {
|
||||
let mut serum3_market = ctx.accounts.market.load_mut()?;
|
||||
|
||||
if let Some(reduce_only) = reduce_only_opt {
|
||||
ctx.accounts.market.load_mut()?.reduce_only = u8::from(reduce_only);
|
||||
msg!(
|
||||
"Reduce only: old - {:?}, new - {:?}",
|
||||
serum3_market.reduce_only,
|
||||
u8::from(reduce_only)
|
||||
);
|
||||
serum3_market.reduce_only = u8::from(reduce_only);
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -69,15 +69,24 @@ pub fn token_edit(
|
|||
let mut bank = ai.load_mut::<Bank>()?;
|
||||
|
||||
if let Some(oracle_config) = oracle_config_opt.as_ref() {
|
||||
msg!(
|
||||
"Oracle config: old - conf_filter {:?}, max_staleness_slots {:?}, new - conf_filter {:?}, max_staleness_slots {:?}",
|
||||
bank.oracle_config.conf_filter,
|
||||
bank.oracle_config.max_staleness_slots,
|
||||
oracle_config.conf_filter,
|
||||
oracle_config.max_staleness_slots
|
||||
);
|
||||
bank.oracle_config = oracle_config.to_oracle_config();
|
||||
require_group_admin = true;
|
||||
};
|
||||
if let Some(oracle) = oracle_opt {
|
||||
msg!("Oracle: old - {:?}, new - {:?}", bank.oracle, oracle,);
|
||||
bank.oracle = oracle;
|
||||
mint_info.oracle = oracle;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if reset_stable_price {
|
||||
msg!("Stable price reset");
|
||||
require_keys_eq!(bank.oracle, ctx.accounts.oracle.key());
|
||||
let oracle_price =
|
||||
bank.oracle_price(&AccountInfoRef::borrow(ctx.accounts.oracle.as_ref())?, None)?;
|
||||
|
@ -89,12 +98,31 @@ pub fn token_edit(
|
|||
}
|
||||
|
||||
if let Some(group_insurance_fund) = group_insurance_fund_opt {
|
||||
msg!(
|
||||
"Group insurance fund: old - {:?}, new - {:?}",
|
||||
mint_info.group_insurance_fund,
|
||||
group_insurance_fund
|
||||
);
|
||||
mint_info.group_insurance_fund = u8::from(group_insurance_fund);
|
||||
require_group_admin = true;
|
||||
};
|
||||
|
||||
if let Some(ref interest_rate_params) = interest_rate_params_opt {
|
||||
// TODO: add a require! verifying relation between the parameters
|
||||
msg!("Interest rate params: old - adjustment_factor {:?}, util0 {:?}, rate0 {:?}, util1 {:?}, rate1 {:?}, max_rate {:?}, new - adjustment_factor {:?}, util0 {:?}, rate0 {:?}, util1 {:?}, rate1 {:?}, max_rate {:?}",
|
||||
bank.adjustment_factor,
|
||||
bank.util0,
|
||||
bank.rate0,
|
||||
bank.util1,
|
||||
bank.rate1,
|
||||
bank.max_rate,
|
||||
interest_rate_params.adjustment_factor,
|
||||
interest_rate_params.util0,
|
||||
interest_rate_params.rate0,
|
||||
interest_rate_params.util1,
|
||||
interest_rate_params.rate1,
|
||||
interest_rate_params.max_rate,
|
||||
);
|
||||
bank.adjustment_factor = I80F48::from_num(interest_rate_params.adjustment_factor);
|
||||
bank.util0 = I80F48::from_num(interest_rate_params.util0);
|
||||
bank.rate0 = I80F48::from_num(interest_rate_params.rate0);
|
||||
|
@ -105,19 +133,39 @@ pub fn token_edit(
|
|||
}
|
||||
|
||||
if let Some(loan_origination_fee_rate) = loan_origination_fee_rate_opt {
|
||||
msg!(
|
||||
"Loan origination fee rate: old - {:?}, new - {:?}",
|
||||
bank.loan_origination_fee_rate,
|
||||
loan_origination_fee_rate
|
||||
);
|
||||
bank.loan_origination_fee_rate = I80F48::from_num(loan_origination_fee_rate);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(loan_fee_rate) = loan_fee_rate_opt {
|
||||
msg!(
|
||||
"Loan fee fee rate: old - {:?}, new - {:?}",
|
||||
bank.loan_fee_rate,
|
||||
loan_fee_rate
|
||||
);
|
||||
bank.loan_fee_rate = I80F48::from_num(loan_fee_rate);
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(maint_asset_weight) = maint_asset_weight_opt {
|
||||
msg!(
|
||||
"Maint asset weight: old - {:?}, new - {:?}",
|
||||
bank.maint_asset_weight,
|
||||
maint_asset_weight
|
||||
);
|
||||
bank.maint_asset_weight = I80F48::from_num(maint_asset_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(init_asset_weight) = init_asset_weight_opt {
|
||||
msg!(
|
||||
"Init asset weight: old - {:?}, new - {:?}",
|
||||
bank.init_asset_weight,
|
||||
init_asset_weight
|
||||
);
|
||||
require_gte!(
|
||||
init_asset_weight,
|
||||
0.0,
|
||||
|
@ -133,60 +181,121 @@ pub fn token_edit(
|
|||
}
|
||||
}
|
||||
if let Some(maint_liab_weight) = maint_liab_weight_opt {
|
||||
msg!(
|
||||
"Maint liab weight: old - {:?}, new - {:?}",
|
||||
bank.maint_liab_weight,
|
||||
maint_liab_weight
|
||||
);
|
||||
bank.maint_liab_weight = I80F48::from_num(maint_liab_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(init_liab_weight) = init_liab_weight_opt {
|
||||
msg!(
|
||||
"Init liab weight: old - {:?}, new - {:?}",
|
||||
bank.init_liab_weight,
|
||||
init_liab_weight
|
||||
);
|
||||
bank.init_liab_weight = I80F48::from_num(init_liab_weight);
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(liquidation_fee) = liquidation_fee_opt {
|
||||
msg!(
|
||||
"Liquidation fee: old - {:?}, new - {:?}",
|
||||
bank.liquidation_fee,
|
||||
liquidation_fee
|
||||
);
|
||||
bank.liquidation_fee = I80F48::from_num(liquidation_fee);
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(stable_price_delay_interval_seconds) = stable_price_delay_interval_seconds_opt {
|
||||
msg!(
|
||||
"Stable price delay interval seconds: old - {:?}, new - {:?}",
|
||||
bank.stable_price_model.delay_interval_seconds,
|
||||
stable_price_delay_interval_seconds
|
||||
);
|
||||
// Updating this makes the old delay values slightly inconsistent
|
||||
bank.stable_price_model.delay_interval_seconds = stable_price_delay_interval_seconds;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(stable_price_delay_growth_limit) = stable_price_delay_growth_limit_opt {
|
||||
msg!(
|
||||
"Stable price delay growth limit: old - {:?}, new - {:?}",
|
||||
bank.stable_price_model.delay_growth_limit,
|
||||
stable_price_delay_growth_limit
|
||||
);
|
||||
bank.stable_price_model.delay_growth_limit = stable_price_delay_growth_limit;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(stable_price_growth_limit) = stable_price_growth_limit_opt {
|
||||
msg!(
|
||||
"Stable price growth limit: old - {:?}, new - {:?}",
|
||||
bank.stable_price_model.stable_growth_limit,
|
||||
stable_price_growth_limit
|
||||
);
|
||||
bank.stable_price_model.stable_growth_limit = stable_price_growth_limit;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(min_vault_to_deposits_ratio) = min_vault_to_deposits_ratio_opt {
|
||||
msg!(
|
||||
"Min vault to deposits ratio: old - {:?}, new - {:?}",
|
||||
bank.min_vault_to_deposits_ratio,
|
||||
min_vault_to_deposits_ratio
|
||||
);
|
||||
bank.min_vault_to_deposits_ratio = min_vault_to_deposits_ratio;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(net_borrow_limit_per_window_quote) = net_borrow_limit_per_window_quote_opt {
|
||||
msg!(
|
||||
"Net borrow limit per window quote: old - {:?}, new - {:?}",
|
||||
bank.net_borrow_limit_per_window_quote,
|
||||
net_borrow_limit_per_window_quote
|
||||
);
|
||||
bank.net_borrow_limit_per_window_quote = net_borrow_limit_per_window_quote;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(net_borrow_limit_window_size_ts) = net_borrow_limit_window_size_ts_opt {
|
||||
msg!(
|
||||
"Net borrow limit window size ts: old - {:?}, new - {:?}",
|
||||
bank.net_borrow_limit_window_size_ts,
|
||||
net_borrow_limit_window_size_ts
|
||||
);
|
||||
bank.net_borrow_limit_window_size_ts = net_borrow_limit_window_size_ts;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if reset_net_borrow_limit {
|
||||
msg!("Net borrow limit reset");
|
||||
bank.net_borrows_in_window = 0;
|
||||
bank.last_net_borrows_window_start_ts = 0;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(borrow_weight_scale_start_quote) = borrow_weight_scale_start_quote_opt {
|
||||
msg!(
|
||||
"Borrow weight scale start quote: old - {:?}, new - {:?}",
|
||||
bank.borrow_weight_scale_start_quote,
|
||||
borrow_weight_scale_start_quote
|
||||
);
|
||||
bank.borrow_weight_scale_start_quote = borrow_weight_scale_start_quote;
|
||||
require_group_admin = true;
|
||||
}
|
||||
if let Some(deposit_weight_scale_start_quote) = deposit_weight_scale_start_quote_opt {
|
||||
msg!(
|
||||
"Deposit weight scale start quote: old - {:?}, new - {:?}",
|
||||
bank.deposit_weight_scale_start_quote,
|
||||
deposit_weight_scale_start_quote
|
||||
);
|
||||
bank.deposit_weight_scale_start_quote = deposit_weight_scale_start_quote;
|
||||
require_group_admin = true;
|
||||
}
|
||||
|
||||
if let Some(reduce_only) = reduce_only_opt {
|
||||
msg!(
|
||||
"Reduce only: old - {:?}, new - {:?}",
|
||||
bank.reduce_only,
|
||||
u8::from(reduce_only)
|
||||
);
|
||||
bank.reduce_only = u8::from(reduce_only);
|
||||
|
||||
// security admin can only enable reduce_only
|
||||
|
|
Loading…
Reference in New Issue