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

@@ -352,41 +352,12 @@ fn known_dex_program_match(
Some(program_id) => program_id,
None => return None,
};
let protocol_name = if program_id == crate::RAYDIUM_AMM_V4_PROGRAM_ID {
"raydium_amm_v4"
} else if program_id == crate::RAYDIUM_CPMM_PROGRAM_ID {
"raydium_cpmm"
} else if program_id == crate::RAYDIUM_CLMM_PROGRAM_ID {
"raydium_clmm"
} else if program_id == crate::RAYDIUM_LAUNCHLAB_PROGRAM_ID {
"raydium_launchlab"
} else if program_id == crate::RAYDIUM_AMM_ROUTING_PROGRAM_ID {
"raydium_router"
} else if program_id == crate::RAYDIUM_STABLE_SWAP_AMM_PROGRAM_ID {
"raydium_stable_swap"
} else if program_id == crate::PUMP_FUN_PROGRAM_ID {
"pump_fun"
} else if program_id == crate::PUMP_SWAP_PROGRAM_ID {
"pump_swap"
} else if program_id == crate::METEORA_DBC_PROGRAM_ID {
"meteora_dbc"
} else if program_id == crate::METEORA_DLMM_PROGRAM_ID {
"meteora_dlmm"
} else if program_id == crate::METEORA_DAMM_V1_PROGRAM_ID {
"meteora_damm_v1"
} else if program_id == crate::METEORA_DAMM_V2_PROGRAM_ID {
"meteora_damm_v2"
} else if program_id == crate::ORCA_WHIRLPOOLS_PROGRAM_ID {
"orca_whirlpools"
} else if program_id == crate::FLUXBEAM_PROGRAM_ID {
"fluxbeam"
} else if program_id == crate::DEXLAB_PROGRAM_ID {
"dexlab"
} else {
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(KnownDexProgramMatch {
protocol_name,
protocol_name: matrix_entry.code,
program_id: program_id.to_string(),
instruction_id: instruction.id,
instruction_index: instruction.instruction_index,
@@ -442,6 +413,26 @@ mod tests {
assert_eq!(program_match.instruction_index, 0);
}
#[test]
fn known_program_match_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 instruction = test_instruction(Some(program_id.to_string()));
let program_match = match super::known_dex_program_match(&instruction) {
Some(program_match) => program_match,
None => panic!("expected program match for {}", expected_protocol),
};
assert_eq!(program_match.protocol_name, expected_protocol);
assert_eq!(program_match.program_id, program_id);
}
}
#[test]
fn unknown_program_id_is_not_matched() {
let instruction =