0.7.24-pre.3
This commit is contained in:
@@ -183,7 +183,7 @@ impl KbTradeAggregationService {
|
||||
|| quote_amount_raw.is_none()
|
||||
|| price_quote_per_base.is_none())
|
||||
{
|
||||
let inferred_result = kb_extract_pump_swap_amounts_from_transaction(
|
||||
let inferred_result = kb_extract_trade_amounts_from_vault_balance_deltas(
|
||||
transaction.transaction_json.as_str(),
|
||||
transaction.meta_json.as_deref(),
|
||||
base_vault_address.as_deref(),
|
||||
@@ -228,6 +228,31 @@ impl KbTradeAggregationService {
|
||||
price_quote_per_base = inferred.2;
|
||||
}
|
||||
}
|
||||
if decoded_event.event_kind.starts_with("raydium_cpmm.")
|
||||
&& (base_amount_raw.is_none()
|
||||
|| quote_amount_raw.is_none()
|
||||
|| price_quote_per_base.is_none())
|
||||
{
|
||||
let inferred_result = kb_extract_trade_amounts_from_vault_balance_deltas(
|
||||
transaction.transaction_json.as_str(),
|
||||
transaction.meta_json.as_deref(),
|
||||
base_vault_address.as_deref(),
|
||||
quote_vault_address.as_deref(),
|
||||
);
|
||||
let inferred = match inferred_result {
|
||||
Ok(inferred) => inferred,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
if base_amount_raw.is_none() {
|
||||
base_amount_raw = inferred.0;
|
||||
}
|
||||
if quote_amount_raw.is_none() {
|
||||
quote_amount_raw = inferred.1;
|
||||
}
|
||||
if price_quote_per_base.is_none() {
|
||||
price_quote_per_base = inferred.2;
|
||||
}
|
||||
}
|
||||
if price_quote_per_base.is_none() {
|
||||
price_quote_per_base = kb_compute_price_quote_per_base_with_decimals(
|
||||
transaction.meta_json.as_deref(),
|
||||
@@ -389,6 +414,12 @@ fn kb_is_trade_event_kind(event_kind: &str) -> bool {
|
||||
if event_kind.ends_with(".sell") {
|
||||
return true;
|
||||
}
|
||||
if event_kind == "raydium_cpmm.swap_base_input" {
|
||||
return true;
|
||||
}
|
||||
if event_kind == "raydium_cpmm.swap_base_output" {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
@@ -403,10 +434,15 @@ fn kb_convert_slot_to_i64(slot: std::option::Option<u64>) -> std::option::Option
|
||||
}
|
||||
|
||||
fn kb_extract_trade_side(event_kind: &str, payload: &serde_json::Value) -> crate::KbSwapTradeSide {
|
||||
let trade_side_option = kb_extract_string_by_candidate_keys(payload, &["tradeSide"]);
|
||||
let trade_side_option =
|
||||
kb_extract_string_by_candidate_keys(payload, &["tradeSide", "trade_side"]);
|
||||
match trade_side_option.as_deref() {
|
||||
Some("BuyBase") => return crate::KbSwapTradeSide::BuyBase,
|
||||
Some("buy") => return crate::KbSwapTradeSide::BuyBase,
|
||||
Some("BUY") => return crate::KbSwapTradeSide::BuyBase,
|
||||
Some("SellBase") => return crate::KbSwapTradeSide::SellBase,
|
||||
Some("sell") => return crate::KbSwapTradeSide::SellBase,
|
||||
Some("SELL") => return crate::KbSwapTradeSide::SellBase,
|
||||
_ => {}
|
||||
}
|
||||
if event_kind.ends_with(".buy") {
|
||||
@@ -580,7 +616,7 @@ fn kb_find_pool_token_vault_address_by_token_id(
|
||||
None
|
||||
}
|
||||
|
||||
fn kb_extract_pump_swap_amounts_from_transaction(
|
||||
fn kb_extract_trade_amounts_from_vault_balance_deltas(
|
||||
transaction_json: &str,
|
||||
meta_json: std::option::Option<&str>,
|
||||
base_vault_address: std::option::Option<&str>,
|
||||
@@ -1000,7 +1036,7 @@ fn kb_compute_price_quote_per_base_with_decimals(
|
||||
base_vault_address: std::option::Option<&str>,
|
||||
quote_vault_address: std::option::Option<&str>,
|
||||
) -> std::option::Option<f64> {
|
||||
let inferred_result = kb_extract_pump_swap_amounts_from_transaction(
|
||||
let inferred_result = kb_extract_trade_amounts_from_vault_balance_deltas(
|
||||
transaction_json,
|
||||
meta_json,
|
||||
base_vault_address,
|
||||
|
||||
Reference in New Issue
Block a user