This commit is contained in:
2026-05-12 18:53:42 +02:00
parent 4f6a4806e2
commit 75c2b6983d
22 changed files with 1452 additions and 368 deletions

View File

@@ -192,52 +192,11 @@ fn build_instruction_evidence_json(
}
fn known_dex_protocol_name(program_id: &str) -> std::option::Option<&'static str> {
if program_id == crate::RAYDIUM_AMM_V4_PROGRAM_ID {
return Some("raydium_amm_v4");
}
if program_id == crate::RAYDIUM_CPMM_PROGRAM_ID {
return Some("raydium_cpmm");
}
if program_id == crate::RAYDIUM_CLMM_PROGRAM_ID {
return Some("raydium_clmm");
}
if program_id == crate::RAYDIUM_LAUNCHLAB_PROGRAM_ID {
return Some("raydium_launchlab");
}
if program_id == crate::RAYDIUM_AMM_ROUTING_PROGRAM_ID {
return Some("raydium_router");
}
if program_id == crate::RAYDIUM_STABLE_SWAP_AMM_PROGRAM_ID {
return Some("raydium_stable_swap");
}
if program_id == crate::PUMP_FUN_PROGRAM_ID {
return Some("pump_fun");
}
if program_id == crate::PUMP_SWAP_PROGRAM_ID {
return Some("pump_swap");
}
if program_id == crate::METEORA_DBC_PROGRAM_ID {
return Some("meteora_dbc");
}
if program_id == crate::METEORA_DLMM_PROGRAM_ID {
return Some("meteora_dlmm");
}
if program_id == crate::METEORA_DAMM_V1_PROGRAM_ID {
return Some("meteora_damm_v1");
}
if program_id == crate::METEORA_DAMM_V2_PROGRAM_ID {
return Some("meteora_damm_v2");
}
if program_id == crate::ORCA_WHIRLPOOLS_PROGRAM_ID {
return Some("orca_whirlpools");
}
if program_id == crate::FLUXBEAM_PROGRAM_ID {
return Some("fluxbeam");
}
if program_id == crate::DEXLAB_PROGRAM_ID {
return Some("dexlab");
}
return None;
let matrix_entry = match crate::dex_support_matrix_entry_by_program_id(program_id) {
Some(matrix_entry) => matrix_entry,
None => return None,
};
return Some(matrix_entry.code);
}
fn should_ignore_program_id(program_id: &str) -> bool {
@@ -385,6 +344,24 @@ fn is_known_launch_surface_program_id(_program_id: &str) -> bool {
#[cfg(test)]
mod tests {
#[test]
fn known_dex_candidate_uses_support_matrix_for_priority_dexes() {
let samples = [
(crate::PUMP_SWAP_PROGRAM_ID, "pump_swap"),
(crate::RAYDIUM_CPMM_PROGRAM_ID, "raydium_cpmm"),
(crate::RAYDIUM_CLMM_PROGRAM_ID, "raydium_clmm"),
(crate::METEORA_DLMM_PROGRAM_ID, "meteora_dlmm"),
(crate::METEORA_DAMM_V1_PROGRAM_ID, "meteora_damm_v1"),
];
for (program_id, expected_protocol) in samples {
let protocol = match super::known_dex_protocol_name(program_id) {
Some(protocol) => protocol,
None => panic!("expected known protocol for {}", program_id),
};
assert_eq!(protocol, expected_protocol);
}
}
#[test]
fn associated_token_program_is_ignored() {
let transaction = test_transaction();