liquidator: Improve logging for tcs execution (#648)
This commit is contained in:
parent
5dd5c507f2
commit
cce2620de8
|
@ -269,15 +269,16 @@ impl Rebalancer {
|
|||
if builder.transaction_size_ok()? {
|
||||
return Ok((builder, full.clone()));
|
||||
}
|
||||
log::trace!(
|
||||
"full route from {} to {} does not fit in a tx, market_info.label {}",
|
||||
full.input_mint,
|
||||
full.output_mint,
|
||||
full.route
|
||||
trace!(
|
||||
market_info_label = full
|
||||
.route
|
||||
.market_infos
|
||||
.first()
|
||||
.map(|v| v.label.clone())
|
||||
.unwrap_or_else(|| "no market_info".into())
|
||||
.unwrap_or_else(|| "no market_info".into()),
|
||||
%full.input_mint,
|
||||
%full.output_mint,
|
||||
"full route does not fit in a tx",
|
||||
);
|
||||
|
||||
if alternatives.is_empty() {
|
||||
|
|
|
@ -69,7 +69,7 @@ async fn tcs_is_interesting(
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn maybe_execute_token_conditional_swap_inner(
|
||||
async fn maybe_execute_token_conditional_swap_inner(
|
||||
mango_client: &MangoClient,
|
||||
account_fetcher: &chain_data::AccountFetcher,
|
||||
token_swap_info: &token_swap_info::TokenSwapInfoUpdater,
|
||||
|
@ -100,6 +100,19 @@ pub async fn maybe_execute_token_conditional_swap_inner(
|
|||
return Ok(false);
|
||||
}
|
||||
|
||||
execute_token_conditional_swap(mango_client, account_fetcher, pubkey, config, &liqee, tcs).await
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[instrument(skip_all, fields(%pubkey, tcs_id = tcs.id))]
|
||||
async fn execute_token_conditional_swap(
|
||||
mango_client: &MangoClient,
|
||||
account_fetcher: &chain_data::AccountFetcher,
|
||||
pubkey: &Pubkey,
|
||||
config: &Config,
|
||||
liqee: &MangoAccountValue,
|
||||
tcs: &TokenConditionalSwap,
|
||||
) -> anyhow::Result<bool> {
|
||||
let liqor_min_health_ratio = I80F48::from_num(config.min_health_ratio);
|
||||
|
||||
// Compute the max viable swap (for liqor and liqee) and min it
|
||||
|
@ -183,21 +196,20 @@ pub async fn maybe_execute_token_conditional_swap_inner(
|
|||
|
||||
if swap_price > taker_price.to_num::<f64>() {
|
||||
trace!(
|
||||
"skipping token conditional swap for: {pubkey}, id: {tcs_id}, \
|
||||
max_buy: {max_buy_token_to_liqee}, max_sell: {max_sell_token_to_liqor}, \
|
||||
because counter swap price: {swap_price} while taker price: {taker_price}",
|
||||
max_buy = max_buy_token_to_liqee,
|
||||
max_sell = max_sell_token_to_liqor,
|
||||
jupiter_swap_price = %swap_price,
|
||||
tcs_taker_price = %taker_price,
|
||||
"skipping token conditional swap because of prices",
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
|
||||
trace!(
|
||||
"executing token conditional swap for: {}, with owner: {}, id: {}, max_buy: {}, max_sell: {}",
|
||||
pubkey,
|
||||
liqee.fixed.owner,
|
||||
tcs_id,
|
||||
max_buy_token_to_liqee,
|
||||
max_sell_token_to_liqor,
|
||||
max_buy = max_buy_token_to_liqee,
|
||||
max_sell = max_sell_token_to_liqor,
|
||||
"executing token conditional swap",
|
||||
);
|
||||
|
||||
let txsig = mango_client
|
||||
|
@ -209,8 +221,8 @@ pub async fn maybe_execute_token_conditional_swap_inner(
|
|||
)
|
||||
.await?;
|
||||
info!(
|
||||
"Executed swap account {}, tcs index {}, tx sig {:?}",
|
||||
pubkey, tcs_id, txsig
|
||||
%txsig,
|
||||
"Executed token conditional swap",
|
||||
);
|
||||
|
||||
let slot = account_fetcher.transaction_max_slot(&[txsig]).await?;
|
||||
|
@ -222,13 +234,14 @@ pub async fn maybe_execute_token_conditional_swap_inner(
|
|||
)
|
||||
.await
|
||||
{
|
||||
info!("could not refresh after tcs: {}", e);
|
||||
info!(%txsig, "could not refresh after tcs execution: {}", e);
|
||||
}
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[instrument(skip_all, fields(%pubkey, tcs_id))]
|
||||
pub async fn remove_expired_token_conditional_swap(
|
||||
mango_client: &MangoClient,
|
||||
pubkey: &Pubkey,
|
||||
|
@ -239,8 +252,8 @@ pub async fn remove_expired_token_conditional_swap(
|
|||
.token_conditional_swap_trigger((pubkey, &liqee), tcs_id, 0, 0)
|
||||
.await?;
|
||||
info!(
|
||||
"Removed expired token conditional swap account {}, tcs index {}, tx sig {:?}",
|
||||
pubkey, tcs_id, txsig
|
||||
%txsig,
|
||||
"Removed expired token conditional swap",
|
||||
);
|
||||
|
||||
Ok(true)
|
||||
|
|
Loading…
Reference in New Issue