0.7.53
This commit is contained in:
@@ -89,6 +89,16 @@ impl DexEventCoverageService {
|
||||
Ok(sync_counts) => sync_counts,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let cleanup_result =
|
||||
self.cleanup_deprecated_pump_swap_observed_unknown_rows(&decoder_code).await;
|
||||
if let Err(error) = cleanup_result {
|
||||
return Err(error);
|
||||
}
|
||||
let duplicate_cleanup_result =
|
||||
self.cleanup_duplicate_pump_swap_logical_coverage_rows(&decoder_code).await;
|
||||
if let Err(error) = duplicate_cleanup_result {
|
||||
return Err(error);
|
||||
}
|
||||
let refreshed_entry_count = match &decoder_code {
|
||||
Some(decoder_code) => {
|
||||
let refresh_result =
|
||||
@@ -139,6 +149,16 @@ impl DexEventCoverageService {
|
||||
Ok(sync_counts) => sync_counts,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let cleanup_result =
|
||||
self.cleanup_deprecated_pump_swap_observed_unknown_rows(&decoder_code).await;
|
||||
if let Err(error) = cleanup_result {
|
||||
return Err(error);
|
||||
}
|
||||
let duplicate_cleanup_result =
|
||||
self.cleanup_duplicate_pump_swap_logical_coverage_rows(&decoder_code).await;
|
||||
if let Err(error) = duplicate_cleanup_result {
|
||||
return Err(error);
|
||||
}
|
||||
let refreshed_entry_count = match &decoder_code {
|
||||
Some(decoder_code) => {
|
||||
let refresh_result =
|
||||
@@ -178,6 +198,86 @@ impl DexEventCoverageService {
|
||||
summaries,
|
||||
});
|
||||
}
|
||||
|
||||
async fn cleanup_deprecated_pump_swap_observed_unknown_rows(
|
||||
&self,
|
||||
decoder_code: &std::option::Option<std::string::String>,
|
||||
) -> Result<u64, crate::Error> {
|
||||
if let Some(decoder_code) = decoder_code {
|
||||
if decoder_code != "pump_swap" {
|
||||
return Ok(0);
|
||||
}
|
||||
}
|
||||
match self.database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let query_result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM k_sol_dex_event_coverage_entries
|
||||
WHERE decoder_code = 'pump_swap'
|
||||
AND (
|
||||
entry_name LIKE 'observed_unknown_%'
|
||||
OR local_event_kind LIKE 'pump_swap.observed_unknown_%'
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await;
|
||||
match query_result {
|
||||
Ok(query_result) => return Ok(query_result.rows_affected()),
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot delete deprecated PumpSwap observed_unknown coverage rows on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async fn cleanup_duplicate_pump_swap_logical_coverage_rows(
|
||||
&self,
|
||||
decoder_code: &std::option::Option<std::string::String>,
|
||||
) -> Result<u64, crate::Error> {
|
||||
if let Some(decoder_code) = decoder_code {
|
||||
if decoder_code != "pump_swap" {
|
||||
return Ok(0);
|
||||
}
|
||||
}
|
||||
match self.database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let query_result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM k_sol_dex_event_coverage_entries
|
||||
WHERE decoder_code = 'pump_swap'
|
||||
AND id NOT IN (
|
||||
SELECT MIN(id)
|
||||
FROM k_sol_dex_event_coverage_entries
|
||||
WHERE decoder_code = 'pump_swap'
|
||||
GROUP BY
|
||||
decoder_code,
|
||||
COALESCE(program_id, ''),
|
||||
entry_kind,
|
||||
entry_name,
|
||||
COALESCE(discriminator_hex, ''),
|
||||
COALESCE(local_event_kind, '')
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await;
|
||||
match query_result {
|
||||
Ok(query_result) => return Ok(query_result.rows_affected()),
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot delete duplicate PumpSwap logical coverage rows on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_coverage_entry_from_upstream(
|
||||
@@ -215,6 +315,9 @@ fn infer_expected_db_target_for_entry(
|
||||
event_family: std::option::Option<&str>,
|
||||
entry_kind: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
if decoder_code == "pump_swap" {
|
||||
return infer_pump_swap_expected_db_target(entry_name, entry_kind);
|
||||
}
|
||||
if decoder_code == "raydium_cpmm"
|
||||
&& (entry_name == "swap_event" || entry_name == "anchor_idl_instruction")
|
||||
{
|
||||
@@ -421,11 +524,201 @@ fn infer_expected_db_target(
|
||||
return Some(target.to_string());
|
||||
}
|
||||
|
||||
fn infer_pump_swap_expected_db_target(
|
||||
entry_name: &str,
|
||||
entry_kind: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
if entry_kind == crate::ENTRY_KIND_PROGRAM {
|
||||
return None;
|
||||
}
|
||||
if entry_name == "buy" || entry_name == "sell" || entry_name == "buy_exact_quote_in" {
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_TRADE_EVENTS.to_string());
|
||||
}
|
||||
if entry_name.starts_with("observed_unknown_") {
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_DECODED_EVENTS_ONLY.to_string());
|
||||
}
|
||||
if entry_name.ends_with("_event") && entry_name != "claim_token_incentives_event" {
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_DECODED_EVENTS_ONLY.to_string());
|
||||
}
|
||||
if entry_name == "deposit"
|
||||
|| entry_name == "deposit_event"
|
||||
|| entry_name == "withdraw"
|
||||
|| entry_name == "withdraw_event"
|
||||
{
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_LIQUIDITY_EVENTS.to_string());
|
||||
}
|
||||
if entry_name == "create_pool" || entry_name == "create_pool_event" {
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_POOL_LIFECYCLE_EVENTS.to_string());
|
||||
}
|
||||
if entry_name == "collect_coin_creator_fee"
|
||||
|| entry_name == "collect_coin_creator_fee_event"
|
||||
|| entry_name == "transfer_creator_fees_to_pump"
|
||||
|| entry_name == "transfer_creator_fees_to_pump_v2"
|
||||
{
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_FEE_EVENTS.to_string());
|
||||
}
|
||||
if entry_name == "claim_cashback"
|
||||
|| entry_name == "claim_cashback_event"
|
||||
|| entry_name == "claim_token_incentives"
|
||||
|| entry_name == "claim_token_incentives_event"
|
||||
|| entry_name == "admin_update_token_incentives"
|
||||
|| entry_name == "admin_update_token_incentives_event"
|
||||
|| entry_name == "init_user_volume_accumulator"
|
||||
|| entry_name == "init_user_volume_accumulator_event"
|
||||
|| entry_name == "sync_user_volume_accumulator"
|
||||
|| entry_name == "sync_user_volume_accumulator_event"
|
||||
|| entry_name == "close_user_volume_accumulator"
|
||||
|| entry_name == "close_user_volume_accumulator_event"
|
||||
{
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_REWARD_EVENTS.to_string());
|
||||
}
|
||||
if entry_name == "admin_set_coin_creator"
|
||||
|| entry_name == "admin_set_coin_creator_event"
|
||||
|| entry_name == "create_config"
|
||||
|| entry_name == "create_config_event"
|
||||
|| entry_name == "disable"
|
||||
|| entry_name == "disable_event"
|
||||
|| entry_name == "extend_account"
|
||||
|| entry_name == "extend_account_event"
|
||||
|| entry_name == "migrate_pool_coin_creator"
|
||||
|| entry_name == "migrate_pool_coin_creator_event"
|
||||
|| entry_name == "reserved_fee_recipients_event"
|
||||
|| entry_name == "set_bonding_curve_coin_creator_event"
|
||||
|| entry_name == "set_coin_creator"
|
||||
|| entry_name == "set_metaplex_coin_creator_event"
|
||||
|| entry_name == "set_reserved_fee_recipient"
|
||||
|| entry_name == "set_reserved_fee_recipients"
|
||||
|| entry_name == "toggle_cashback_enabled"
|
||||
|| entry_name == "toggle_mayhem_mode"
|
||||
|| entry_name == "update_admin"
|
||||
|| entry_name == "update_buyback_config"
|
||||
|| entry_name == "update_admin_event"
|
||||
|| entry_name == "update_fee_config"
|
||||
|| entry_name == "update_fee_config_event"
|
||||
{
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_POOL_ADMIN_EVENTS.to_string());
|
||||
}
|
||||
return Some(crate::DexEventCoverageEntryDto::DB_TARGET_DECODED_EVENTS_ONLY.to_string());
|
||||
}
|
||||
|
||||
fn infer_pump_swap_event_family(
|
||||
entry_name: &str,
|
||||
entry_kind: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
if entry_kind == crate::ENTRY_KIND_PROGRAM {
|
||||
return None;
|
||||
}
|
||||
if entry_name == "buy" || entry_name == "sell" || entry_name == "buy_exact_quote_in" {
|
||||
return Some("swap".to_string());
|
||||
}
|
||||
if entry_name == "buy_event" || entry_name == "sell_event" {
|
||||
return Some("swap_event_audit".to_string());
|
||||
}
|
||||
if entry_name == "deposit" || entry_name == "deposit_event" {
|
||||
return Some("liquidity_add".to_string());
|
||||
}
|
||||
if entry_name == "withdraw" || entry_name == "withdraw_event" {
|
||||
return Some("liquidity_remove".to_string());
|
||||
}
|
||||
if entry_name == "create_pool" || entry_name == "create_pool_event" {
|
||||
return Some("pool_create".to_string());
|
||||
}
|
||||
if entry_name.starts_with("observed_unknown_") {
|
||||
return Some("observed_unknown_instruction".to_string());
|
||||
}
|
||||
if entry_name == "toggle_cashback_enabled"
|
||||
|| entry_name == "set_reserved_fee_recipient"
|
||||
|| entry_name == "set_reserved_fee_recipients"
|
||||
|| entry_name == "reserved_fee_recipients_event"
|
||||
{
|
||||
return Some("admin_config".to_string());
|
||||
}
|
||||
if entry_name.contains("creator_fee") || entry_name.contains("fee_recipient") {
|
||||
return Some("fee".to_string());
|
||||
}
|
||||
if entry_name.contains("cashback")
|
||||
|| entry_name.contains("incentive")
|
||||
|| entry_name.contains("volume_accumulator")
|
||||
{
|
||||
return Some("reward".to_string());
|
||||
}
|
||||
if entry_name.contains("config")
|
||||
|| entry_name.contains("admin")
|
||||
|| entry_name.contains("disable")
|
||||
|| entry_name.contains("toggle")
|
||||
|| entry_name.contains("coin_creator")
|
||||
|| entry_name.contains("extend_account")
|
||||
{
|
||||
return Some("admin_config".to_string());
|
||||
}
|
||||
return infer_event_family(entry_name, entry_kind);
|
||||
}
|
||||
|
||||
fn pump_swap_local_event_kind(entry_name: &str) -> std::option::Option<std::string::String> {
|
||||
if entry_name.ends_with("_event") {
|
||||
return Some(format!("pump_swap.{}", entry_name));
|
||||
}
|
||||
match entry_name {
|
||||
"admin_set_coin_creator" => return Some("pump_swap.admin_set_coin_creator".to_string()),
|
||||
"admin_update_token_incentives" => {
|
||||
return Some("pump_swap.admin_update_token_incentives".to_string());
|
||||
},
|
||||
"buy" => return Some("pump_swap.buy".to_string()),
|
||||
"buy_exact_quote_in" => return Some("pump_swap.buy_exact_quote_in".to_string()),
|
||||
"claim_cashback" => return Some("pump_swap.claim_cashback".to_string()),
|
||||
"claim_token_incentives" => return Some("pump_swap.claim_token_incentives".to_string()),
|
||||
"close_user_volume_accumulator" => {
|
||||
return Some("pump_swap.close_user_volume_accumulator".to_string());
|
||||
},
|
||||
"collect_coin_creator_fee" => {
|
||||
return Some("pump_swap.collect_coin_creator_fee".to_string());
|
||||
},
|
||||
"create_config" => return Some("pump_swap.create_config".to_string()),
|
||||
"create_pool" => return Some("pump_swap.create_pool".to_string()),
|
||||
"deposit" => return Some("pump_swap.deposit".to_string()),
|
||||
"disable" => return Some("pump_swap.disable".to_string()),
|
||||
"extend_account" => return Some("pump_swap.extend_account".to_string()),
|
||||
"init_user_volume_accumulator" => {
|
||||
return Some("pump_swap.init_user_volume_accumulator".to_string());
|
||||
},
|
||||
"migrate_pool_coin_creator" => {
|
||||
return Some("pump_swap.migrate_pool_coin_creator".to_string());
|
||||
},
|
||||
"sell" => return Some("pump_swap.sell".to_string()),
|
||||
"set_coin_creator" => return Some("pump_swap.set_coin_creator".to_string()),
|
||||
"set_reserved_fee_recipients" => {
|
||||
return Some("pump_swap.set_reserved_fee_recipients".to_string());
|
||||
},
|
||||
"sync_user_volume_accumulator" => {
|
||||
return Some("pump_swap.sync_user_volume_accumulator".to_string());
|
||||
},
|
||||
"toggle_cashback_enabled" => return Some("pump_swap.toggle_cashback_enabled".to_string()),
|
||||
"toggle_mayhem_mode" => return Some("pump_swap.toggle_mayhem_mode".to_string()),
|
||||
"transfer_creator_fees_to_pump" => {
|
||||
return Some("pump_swap.transfer_creator_fees_to_pump".to_string());
|
||||
},
|
||||
"transfer_creator_fees_to_pump_v2" => {
|
||||
return Some("pump_swap.transfer_creator_fees_to_pump_v2".to_string());
|
||||
},
|
||||
"update_admin" => return Some("pump_swap.update_admin".to_string()),
|
||||
"update_buyback_config" => return Some("pump_swap.update_buyback_config".to_string()),
|
||||
"update_fee_config" => return Some("pump_swap.update_fee_config".to_string()),
|
||||
"withdraw" => return Some("pump_swap.withdraw".to_string()),
|
||||
"set_reserved_fee_recipient" => {
|
||||
return Some("pump_swap.set_reserved_fee_recipient".to_string());
|
||||
},
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
|
||||
fn infer_event_family_for_entry(
|
||||
decoder_code: &str,
|
||||
entry_name: &str,
|
||||
entry_kind: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
if decoder_code == "pump_swap" {
|
||||
return infer_pump_swap_event_family(entry_name, entry_kind);
|
||||
}
|
||||
if decoder_code == "raydium_launchpad" {
|
||||
return infer_raydium_launchpad_event_family(entry_name, entry_kind);
|
||||
}
|
||||
@@ -488,7 +781,6 @@ fn infer_raydium_cpmm_event_family(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn infer_raydium_stable_swap_event_family(
|
||||
entry_name: &str,
|
||||
entry_kind: &str,
|
||||
@@ -789,7 +1081,6 @@ fn raydium_amm_v4_local_event_kind(entry_name: &str) -> std::option::Option<std:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn raydium_stable_swap_local_event_kind(
|
||||
entry_name: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
@@ -819,6 +1110,9 @@ pub(crate) fn known_local_event_kind(
|
||||
decoder_code: &str,
|
||||
entry_name: &str,
|
||||
) -> std::option::Option<std::string::String> {
|
||||
if decoder_code == "pump_swap" {
|
||||
return pump_swap_local_event_kind(entry_name);
|
||||
}
|
||||
if decoder_code == "raydium_amm_v4" {
|
||||
return raydium_amm_v4_local_event_kind(entry_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user