This commit is contained in:
2026-06-08 12:32:58 +02:00
parent f81e0f3bea
commit f2ea1a392f
55 changed files with 7993 additions and 306 deletions

View File

@@ -0,0 +1,48 @@
-- file: validation_sql/SQL_TRACE_RAYDIUM_CPMM_AUDIT_40F_0_7_50_PRE_R2.sql
-- Purpose: locate the Raydium CPMM audit-only discriminator 40f4bc78a7e9690a
-- so the instruction can be inspected manually on Solscan or decoded from local meta_json.
SELECT
tx.signature,
tx.slot,
de.id AS decoded_event_id,
de.pool_account,
de.token_a_mint,
de.token_b_mint,
json_extract(de.payload_json, '$.instructionIndex') AS instruction_index,
json_extract(de.payload_json, '$.innerInstructionIndex') AS inner_instruction_index,
json_extract(de.payload_json, '$.programId') AS program_id,
json_extract(de.payload_json, '$.discriminatorHex') AS discriminator_hex,
json_extract(de.payload_json, '$.accountCount') AS account_count,
json_extract(de.payload_json, '$.accounts') AS accounts_json,
json_extract(de.payload_json, '$.data') AS instruction_data,
de.payload_json
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx
ON tx.id = de.transaction_id
WHERE de.protocol_name = 'raydium_cpmm'
AND de.event_kind = 'raydium_cpmm.instruction_audit'
AND json_extract(de.payload_json, '$.discriminatorHex') = '40f4bc78a7e9690a'
ORDER BY tx.slot, tx.signature, instruction_index, inner_instruction_index;
-- Optional: include the raw projected instruction row if decoded_event.instruction_id is populated.
SELECT
tx.signature,
tx.slot,
de.id AS decoded_event_id,
ci.id AS chain_instruction_id,
ci.instruction_index,
ci.inner_instruction_index,
ci.program_id,
ci.accounts_json,
ci.data_json,
de.payload_json
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx
ON tx.id = de.transaction_id
LEFT JOIN k_sol_chain_instructions ci
ON ci.id = de.instruction_id
WHERE de.protocol_name = 'raydium_cpmm'
AND de.event_kind = 'raydium_cpmm.instruction_audit'
AND json_extract(de.payload_json, '$.discriminatorHex') = '40f4bc78a7e9690a'
ORDER BY tx.slot, tx.signature, ci.instruction_index, ci.inner_instruction_index;

View File

@@ -0,0 +1,399 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_CLMM_0_7_50_PRE_R2.sql
-- Raydium CLMM 0.7.50-pre-r2 re-verification pack.
-- Goal: repeat the Launchpad-style closure checks on a dedicated CLMM
-- database, after replay with skipDexDecode='no' and forceDexDecode='yes'.
-- Expected invariants:
-- - no `unknown` or empty event_family except the synthetic `program` row;
-- - no observed discriminator missing from coverage;
-- - no residual upstream fallback for locally-covered entries;
-- - no successful, actionable decoded event left without its materialized row;
-- - no failed transaction materialized into business tables;
-- - decoded-only entries such as CPMM anchor IDL management and CLMM router/program-data
-- corroboration events are excluded from materialization shortfall checks.
-- 01. Coverage detail.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
ORDER BY entry_kind, entry_name, discriminator_hex;
->
collect_personal_fee_event event fee k_sol_fee_events upstream_git_mapped_unverified raydium_clmm.collect_personal_fee_event a6ae69c051a15369 0 0 0
collect_protocol_fee_event event fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_clmm.collect_protocol_fee_event ce57114f2d29d53d 4 4 0
config_change_event event admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.config_change_event f7bd07776a705f97 4 4 0
create_personal_position_event event position_open k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.create_personal_position_event 641e57f9c4df9ace 26 23 0
decrease_liquidity_event event liquidity_remove k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.decrease_liquidity_event 3ade563a44325538 16 16 0
increase_liquidity_event event liquidity_add k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.increase_liquidity_event 314f69d420221e54 9 8 0
liquidity_calculate_event event liquidity_calculation k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_clmm.liquidity_calculate_event ed7094e63954b4a2 58 0 0
liquidity_change_event event liquidity_change k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.liquidity_change_event 7ef0afce9e58996b 50 45 0
pool_created_event event pool_create k_sol_pool_lifecycle_events upstream_git_local_corpus_materialized raydium_clmm.pool_created_event 195e4b2f7063353f 14 13 0
swap_event event swap k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_clmm.swap_event 40c6cde8260871e2 1456 0 0
update_reward_infos_event event reward k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.update_reward_infos_event 6d7fba4e724125ec 7 7 0
close_limit_order instruction order_cancel k_sol_orderbook_events upstream_git_local_corpus_materialized raydium_clmm.close_limit_order 4c7c800fd55725fa 24 22 0
close_position instruction position_close k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_clmm.close_position 7b86510031446262 16 0 0
close_protocol_position instruction position_close k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_clmm.close_protocol_position c975989055556cb2 3 0 0
collect_fund_fee instruction fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_clmm.collect_fund_fee a78a4e95dfc2067e 5 3 0
collect_protocol_fee instruction fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_clmm.collect_protocol_fee 8888fcddc2427e59 11 11 0
collect_remaining_rewards instruction reward k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.collect_remaining_rewards 12eda6c52210d590 10 6 0
cpi_event instruction cpi_transport k_sol_dex_decoded_events_only upstream_git_mapped_unverified raydium_clmm.cpi_event e445a52e51cb9a1d 0 0 0
create_amm_config instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.create_amm_config 8934edd4d7756c68 9 7 0
create_customizable_pool instruction pool_create k_sol_pool_lifecycle_events upstream_git_local_corpus_materialized raydium_clmm.create_customizable_pool 2b44d4a7592fa401 5 3 0
create_dynamic_fee_config instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.create_dynamic_fee_config bd0eb5785576e33e 1 1 0
create_operation_account instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.create_operation_account 3f5794216d230868 4 1 0
create_pool instruction pool_create k_sol_pool_lifecycle_events upstream_git_local_corpus_materialized raydium_clmm.create_pool e992d18ecf6840bc 8 8 0
create_support_mint_associated instruction account_create k_sol_token_account_events upstream_git_local_corpus_observed raydium_clmm.create_support_mint_associated 11fb415c88f20ea9 5 0 0
decrease_limit_order instruction order_cancel k_sol_orderbook_events upstream_git_local_corpus_materialized raydium_clmm.decrease_limit_order 759d3c674231a300 24 22 0
decrease_liquidity instruction liquidity_remove k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.decrease_liquidity a026d06f685b2c01 16 1 0
decrease_liquidity_v2 instruction liquidity_remove k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.decrease_liquidity_v2 3a7fbc3e4f52c460 25 23 0
increase_limit_order instruction order_place k_sol_orderbook_events upstream_git_local_corpus_materialized raydium_clmm.increase_limit_order b19059ecfaba7d63 6 6 0
increase_liquidity instruction liquidity_add k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.increase_liquidity 2e9cf3760dcdfbb2 6 2 0
increase_liquidity_v2 instruction liquidity_add k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.increase_liquidity_v2 851d59df45eeb00a 7 6 0
initialize_reward instruction pool_create k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.initialize_reward 5f87c0c4f281e644 7 4 0
open_limit_order instruction order_place k_sol_orderbook_events upstream_git_local_corpus_materialized raydium_clmm.open_limit_order 9d20dab7471d1293 10 5 0
open_position instruction position_open k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.open_position 87802f4d0f98f031 9 1 0
open_position_v2 instruction position_open k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.open_position_v2 4db84ad67056f1c7 11 7 0
open_position_with_token22_nft instruction position_open k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_clmm.open_position_with_token22_nft 4dffae527d1dc92e 19 15 0
set_reward_params instruction reward k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.set_reward_params 7034a74b20c9d389 6 4 0
settle_limit_order instruction settle_funds k_sol_orderbook_events upstream_git_local_corpus_materialized raydium_clmm.settle_limit_order cd4e74215c691a60 9 9 0
swap instruction swap k_sol_trade_events upstream_git_local_corpus_materialized raydium_clmm.swap f8c69e91e17587c8 1464 910 910
swap_router_base_in instruction swap k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_clmm.swap_router_base_in 457d73daf5baf2c4 90 0 0
swap_v2 instruction swap k_sol_trade_events upstream_git_local_corpus_materialized raydium_clmm.swap_v2 2b04ed0b1ac91e62 715 276 276
transfer_reward_owner instruction reward k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.transfer_reward_owner 07160c53f22b3079 7 5 0
update_amm_config instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.update_amm_config 313cae889a1c74c8 11 8 0
update_dynamic_fee_config instruction admin_config k_sol_pool_admin_events upstream_git_mapped_unverified raydium_clmm.update_dynamic_fee_config 0707500802c784f0 0 0 0
update_operation_account instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.update_operation_account 7f467728bce33d07 4 3 0
update_pool_status instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_clmm.update_pool_status 82576c062ee0757b 6 4 0
update_reward_infos instruction reward k_sol_reward_events upstream_git_local_corpus_materialized raydium_clmm.update_reward_infos a3ace0340b9a6adf 7 7 0
program program k_sol_dex_decoded_events_only upstream_git_unverified 0 0 0
SELECT
decoder_code,
COUNT(*) AS listed_entry_count,
SUM(CASE WHEN local_event_kind IS NOT NULL AND local_event_kind <> '' THEN 1 ELSE 0 END) AS decoded_entry_count,
SUM(CASE WHEN observed_count > 0 THEN 1 ELSE 0 END) AS observed_entry_count,
SUM(CASE WHEN materialized_count > 0 THEN 1 ELSE 0 END) AS materialized_entry_count,
COALESCE(SUM(observed_count), 0) AS total_observed_count,
COALESCE(SUM(materialized_count), 0) AS total_materialized_count,
COALESCE(SUM(trade_count), 0) AS trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
GROUP BY decoder_code;
->
raydium_clmm 47 46 43 37 4204 1500 1186
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
AND (
event_family IS NULL
OR event_family = ''
OR event_family = 'unknown'
)
AND entry_kind <> 'program'
ORDER BY entry_kind, entry_name;
-> vide
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_clmm'
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, instruction_name, discriminator_hex;
->
raydium_clmm.swap f8c69e91e17587c8 1464 1327
raydium_clmm.swap_v2 2b04ed0b1ac91e62 715 459
raydium_clmm.swap_router_base_in 457d73daf5baf2c4 90 88
raydium_clmm.close_limit_order 4c7c800fd55725fa 28 24
raydium_clmm.decrease_limit_order 759d3c674231a300 28 24
raydium_clmm.decrease_liquidity_v2 3a7fbc3e4f52c460 25 18
raydium_clmm.create_support_mint_associated 11fb415c88f20ea9 22 5
raydium_clmm.update_amm_config 313cae889a1c74c8 20 11
raydium_clmm.open_position_with_token22_nft 4dffae527d1dc92e 19 19
raydium_clmm.collect_fund_fee a78a4e95dfc2067e 18 5
raydium_clmm.close_position 7b86510031446262 16 16
raydium_clmm.decrease_liquidity a026d06f685b2c01 16 16
raydium_clmm.create_amm_config 8934edd4d7756c68 12 9
raydium_clmm.collect_protocol_fee 8888fcddc2427e59 11 4
raydium_clmm.open_position_v2 4db84ad67056f1c7 11 11
raydium_clmm.collect_remaining_rewards 12eda6c52210d590 10 10
raydium_clmm.create_pool e992d18ecf6840bc 10 10
raydium_clmm.open_limit_order 9d20dab7471d1293 10 10
raydium_clmm.open_position 87802f4d0f98f031 9 9
raydium_clmm.set_reward_params 7034a74b20c9d389 9 6
raydium_clmm.settle_limit_order cd4e74215c691a60 9 9
raydium_clmm.transfer_reward_owner 07160c53f22b3079 9 7
raydium_clmm.increase_liquidity_v2 851d59df45eeb00a 7 7
raydium_clmm.initialize_reward 5f87c0c4f281e644 7 7
raydium_clmm.update_reward_infos a3ace0340b9a6adf 7 7
raydium_clmm.increase_limit_order b19059ecfaba7d63 6 6
raydium_clmm.increase_liquidity 2e9cf3760dcdfbb2 6 6
raydium_clmm.update_pool_status 82576c062ee0757b 6 6
raydium_clmm.close_protocol_position c975989055556cb2 5 3
raydium_clmm.create_customizable_pool 2b44d4a7592fa401 5 5
raydium_clmm.update_operation_account 7f467728bce33d07 5 4
raydium_clmm.create_dynamic_fee_config bd0eb5785576e33e 4 1
raydium_clmm.create_operation_account 3f5794216d230868 4 4
SELECT
io.discriminator_hex,
MIN(io.instruction_name) AS sample_instruction_name,
MIN(io.decoded_event_kind) AS sample_decoded_event_kind,
COUNT(*) AS observed_count,
COUNT(DISTINCT io.signature) AS tx_count
FROM k_sol_instruction_observations io
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.discriminator_hex = io.discriminator_hex
WHERE io.decoder_code = 'raydium_clmm'
AND io.discriminator_hex IS NOT NULL
AND io.discriminator_hex <> ''
AND ce.id IS NULL
GROUP BY io.discriminator_hex
ORDER BY observed_count DESC, io.discriminator_hex;
-> vide
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
->
raydium_clmm.swap 1464 0 0 0 0 0 0 0 0 910
raydium_clmm.swap_event 1456 0 0 0 0 0 0 0 0 0
raydium_clmm.swap_v2 715 0 0 0 0 0 0 0 0 276
raydium_clmm.swap_router_base_in 90 0 0 0 0 0 0 0 0 0
raydium_clmm.liquidity_calculate_event 58 0 0 0 0 0 0 0 0 0
raydium_clmm.liquidity_change_event 50 45 0 0 0 0 0 0 0 0
raydium_clmm.create_personal_position_event 26 23 0 0 0 0 0 0 0 0
raydium_clmm.decrease_liquidity_v2 25 23 0 0 0 0 0 0 0 0
raydium_clmm.close_limit_order 24 0 0 0 0 0 0 22 0 0
raydium_clmm.decrease_limit_order 24 0 0 0 0 0 0 22 0 0
raydium_clmm.open_position_with_token22_nft 19 15 0 0 0 0 0 0 0 0
raydium_clmm.close_position 16 7 0 0 0 0 0 0 0 0
raydium_clmm.decrease_liquidity 16 1 0 0 0 0 0 0 0 0
raydium_clmm.decrease_liquidity_event 16 16 0 0 0 0 0 0 0 0
raydium_clmm.pool_created_event 14 0 0 0 0 0 13 0 0 0
raydium_clmm.collect_protocol_fee 11 0 11 0 0 0 0 0 0 0
raydium_clmm.open_position_v2 11 7 0 0 0 0 0 0 0 0
raydium_clmm.update_amm_config 11 0 0 0 8 0 0 0 0 0
raydium_clmm.collect_remaining_rewards 10 0 0 6 0 0 0 0 0 0
raydium_clmm.open_limit_order 10 0 0 0 0 0 0 5 0 0
raydium_clmm.create_amm_config 9 0 0 0 7 0 0 0 0 0
raydium_clmm.increase_liquidity_event 9 8 0 0 0 0 0 0 0 0
raydium_clmm.open_position 9 1 0 0 0 0 0 0 0 0
raydium_clmm.settle_limit_order 9 0 0 0 0 0 0 9 0 0
raydium_clmm.create_pool 8 0 0 0 0 0 8 0 0 0
raydium_clmm.increase_liquidity_v2 7 6 0 0 0 0 0 0 0 0
raydium_clmm.initialize_reward 7 0 0 4 0 0 4 0 0 0
raydium_clmm.transfer_reward_owner 7 0 0 5 0 0 0 0 0 0
raydium_clmm.update_reward_infos 7 0 0 7 7 0 0 0 0 0
raydium_clmm.update_reward_infos_event 7 0 0 7 7 0 0 0 0 0
raydium_clmm.increase_limit_order 6 0 0 0 0 0 0 6 0 0
raydium_clmm.increase_liquidity 6 2 0 0 0 0 0 0 0 0
raydium_clmm.set_reward_params 6 0 0 4 4 0 0 0 0 0
raydium_clmm.update_pool_status 6 0 0 0 4 0 0 0 0 0
raydium_clmm.collect_fund_fee 5 0 3 0 0 0 0 0 0 0
raydium_clmm.create_customizable_pool 5 0 0 0 0 0 3 0 0 0
raydium_clmm.create_support_mint_associated 5 0 0 0 0 0 0 0 5 0
raydium_clmm.collect_protocol_fee_event 4 0 4 0 0 0 0 0 0 0
raydium_clmm.config_change_event 4 0 0 0 4 0 0 0 0 0
raydium_clmm.create_operation_account 4 0 0 0 1 0 0 0 0 0
raydium_clmm.update_operation_account 4 0 0 0 3 0 0 0 0 0
raydium_clmm.close_protocol_position 3 0 0 0 0 0 0 0 0 0
raydium_clmm.create_dynamic_fee_config 1 0 0 0 1 0 0 0 0 0
SELECT
de.event_kind,
ce.entry_name,
ce.entry_kind,
ce.event_family,
ce.expected_db_target,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind, ce.entry_name, ce.entry_kind, ce.event_family, ce.expected_db_target
HAVING
COALESCE(ce.expected_db_target, '') <> 'k_sol_dex_decoded_events_only'
AND (liquidity_count + fee_count + reward_count + admin_count + launch_count + lifecycle_count + orderbook_count + token_account_count + trade_count + failed_tx_count) < decoded_count
ORDER BY decoded_count DESC, de.event_kind;
->
raydium_clmm.liquidity_change_event liquidity_change_event event liquidity_change k_sol_liquidity_events 50 1 45 0 0 0 0 0 0 0 0
raydium_clmm.create_personal_position_event create_personal_position_event event position_open k_sol_liquidity_events 26 0 23 0 0 0 0 0 0 0 0
raydium_clmm.decrease_liquidity decrease_liquidity instruction liquidity_remove k_sol_liquidity_events 16 5 1 0 0 0 0 0 0 0 0
raydium_clmm.open_position_v2 open_position_v2 instruction position_open k_sol_liquidity_events 11 3 7 0 0 0 0 0 0 0 0
raydium_clmm.increase_liquidity_event increase_liquidity_event event liquidity_add k_sol_liquidity_events 9 0 8 0 0 0 0 0 0 0 0
raydium_clmm.open_position open_position instruction position_open k_sol_liquidity_events 9 5 1 0 0 0 0 0 0 0 0
raydium_clmm.increase_liquidity increase_liquidity instruction liquidity_add k_sol_liquidity_events 6 3 2 0 0 0 0 0 0 0 0
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
AND tx.err_json IS NOT NULL
AND tx.err_json <> ''
AND tx.err_json <> 'null'
GROUP BY de.event_kind
HAVING
COUNT(le.id) > 0
OR COUNT(fe.id) > 0
OR COUNT(re.id) > 0
OR COUNT(ae.id) > 0
OR COUNT(la.id) > 0
OR COUNT(pe.id) > 0
OR COUNT(oe.id) > 0
OR COUNT(ta.id) > 0
OR COUNT(te.id) > 0
ORDER BY de.event_kind;
-> vide
-- 09. Residual instruction audit rows.
-- Expected: zero rows after full direct mapping.
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_clmm'
AND event_kind = 'raydium_clmm.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
-- 10. Redundant upstream fallback matches for locally covered entries.
-- Expected: zero rows.
SELECT
json_extract(ug.payload_json, '$.upstreamDecoderCode') AS upstream_decoder_code,
json_extract(ug.payload_json, '$.upstreamEntryName') AS entry_name,
json_extract(ug.payload_json, '$.upstreamDiscriminatorHex') AS discriminator_hex,
json_extract(ug.payload_json, '$.upstreamSourceRepo') AS source_repo,
COUNT(*) AS fallback_count,
COUNT(DISTINCT ug.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events ug
JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = json_extract(ug.payload_json, '$.upstreamDecoderCode')
AND ce.entry_name = json_extract(ug.payload_json, '$.upstreamEntryName')
AND ce.discriminator_hex = json_extract(ug.payload_json, '$.upstreamDiscriminatorHex')
AND ce.local_event_kind IS NOT NULL
AND ce.local_event_kind <> ''
WHERE ug.protocol_name = 'upstream_git'
AND ug.event_kind = 'upstream_git.instruction_match'
AND json_extract(ug.payload_json, '$.upstreamDecoderCode') = 'raydium_clmm'
GROUP BY upstream_decoder_code, entry_name, discriminator_hex, source_repo
ORDER BY fallback_count DESC, entry_name;
-- 11. Decoded event kinds without a coverage entry.
-- Expected: zero rows, excluding explicit `.instruction_audit` if it remains by design.
SELECT
de.event_kind,
COUNT(*) AS decoded_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
WHERE de.protocol_name = 'raydium_clmm'
AND ce.id IS NULL
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 12. Non-swap decoded events that created trades.
-- Expected: zero rows.
SELECT
de.event_kind,
ce.event_family,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind, ce.event_family
HAVING ce.event_family <> 'swap'
AND COUNT(te.id) > 0
ORDER BY trade_count DESC, de.event_kind;

View File

@@ -0,0 +1,272 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_CLMM_0_7_50_RECHECK.sql
-- Raydium CLMM 0.7.50 re-verification pack.
-- Goal: repeat the Launchpad-style closure checks on a dedicated CLMM
-- database, after replay with skipDexDecode='no' and forceDexDecode='yes'.
-- Expected invariants:
-- - no `unknown` or empty event_family except the synthetic `program` row;
-- - no observed discriminator missing from coverage;
-- - no residual upstream fallback for locally-covered entries;
-- - no successful, actionable decoded event left without its materialized row;
-- - no failed transaction materialized into business tables;
-- - decoded-only entries such as CPMM anchor IDL management and CLMM router/program-data
-- corroboration events are excluded from materialization shortfall checks.
-- 01. Coverage detail.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
ORDER BY entry_kind, entry_name, discriminator_hex;
-- 02. Coverage summary.
SELECT
decoder_code,
COUNT(*) AS listed_entry_count,
SUM(CASE WHEN local_event_kind IS NOT NULL AND local_event_kind <> '' THEN 1 ELSE 0 END) AS decoded_entry_count,
SUM(CASE WHEN observed_count > 0 THEN 1 ELSE 0 END) AS observed_entry_count,
SUM(CASE WHEN materialized_count > 0 THEN 1 ELSE 0 END) AS materialized_entry_count,
COALESCE(SUM(observed_count), 0) AS total_observed_count,
COALESCE(SUM(materialized_count), 0) AS total_materialized_count,
COALESCE(SUM(trade_count), 0) AS trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
GROUP BY decoder_code;
-- 03. Coverage family normalization guard.
-- Expected: zero rows, or only the synthetic `program` row if it intentionally has no family.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_clmm'
AND (
event_family IS NULL
OR event_family = ''
OR event_family = 'unknown'
)
AND entry_kind <> 'program'
ORDER BY entry_kind, entry_name;
-- 04. Instruction observations by discriminator.
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_clmm'
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, instruction_name, discriminator_hex;
-- 05. Observed discriminators absent from coverage.
-- Expected: zero rows.
SELECT
io.discriminator_hex,
MIN(io.instruction_name) AS sample_instruction_name,
MIN(io.decoded_event_kind) AS sample_decoded_event_kind,
COUNT(*) AS observed_count,
COUNT(DISTINCT io.signature) AS tx_count
FROM k_sol_instruction_observations io
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.discriminator_hex = io.discriminator_hex
WHERE io.decoder_code = 'raydium_clmm'
AND io.discriminator_hex IS NOT NULL
AND io.discriminator_hex <> ''
AND ce.id IS NULL
GROUP BY io.discriminator_hex
ORDER BY observed_count DESC, io.discriminator_hex;
-- 06. Decoded event distribution and materialization links.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 07. Successful decoded events not materialized where coverage target says they should be.
-- Expected: zero rows, except expected_db_target='k_sol_dex_decoded_events_only' and failed tx rows.
SELECT
de.event_kind,
ce.entry_name,
ce.entry_kind,
ce.event_family,
ce.expected_db_target,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind, ce.entry_name, ce.entry_kind, ce.event_family, ce.expected_db_target
HAVING
COALESCE(ce.expected_db_target, '') <> 'k_sol_dex_decoded_events_only'
AND (liquidity_count + fee_count + reward_count + admin_count + launch_count + lifecycle_count + orderbook_count + token_account_count + trade_count + failed_tx_count) < decoded_count
ORDER BY decoded_count DESC, de.event_kind;
-- 08. Failed transaction materialization guard.
-- Expected: zero rows.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
AND tx.err_json IS NOT NULL
AND tx.err_json <> ''
AND tx.err_json <> 'null'
GROUP BY de.event_kind
HAVING
COUNT(le.id) > 0
OR COUNT(fe.id) > 0
OR COUNT(re.id) > 0
OR COUNT(ae.id) > 0
OR COUNT(la.id) > 0
OR COUNT(pe.id) > 0
OR COUNT(oe.id) > 0
OR COUNT(ta.id) > 0
OR COUNT(te.id) > 0
ORDER BY de.event_kind;
-- 09. Residual instruction audit rows.
-- Expected: zero rows after full direct mapping.
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_clmm'
AND event_kind = 'raydium_clmm.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
-- 10. Redundant upstream fallback matches for locally covered entries.
-- Expected: zero rows.
SELECT
json_extract(ug.payload_json, '$.upstreamDecoderCode') AS upstream_decoder_code,
json_extract(ug.payload_json, '$.upstreamEntryName') AS entry_name,
json_extract(ug.payload_json, '$.upstreamDiscriminatorHex') AS discriminator_hex,
json_extract(ug.payload_json, '$.upstreamSourceRepo') AS source_repo,
COUNT(*) AS fallback_count,
COUNT(DISTINCT ug.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events ug
JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = json_extract(ug.payload_json, '$.upstreamDecoderCode')
AND ce.entry_name = json_extract(ug.payload_json, '$.upstreamEntryName')
AND ce.discriminator_hex = json_extract(ug.payload_json, '$.upstreamDiscriminatorHex')
AND ce.local_event_kind IS NOT NULL
AND ce.local_event_kind <> ''
WHERE ug.protocol_name = 'upstream_git'
AND ug.event_kind = 'upstream_git.instruction_match'
AND json_extract(ug.payload_json, '$.upstreamDecoderCode') = 'raydium_clmm'
GROUP BY upstream_decoder_code, entry_name, discriminator_hex, source_repo
ORDER BY fallback_count DESC, entry_name;
-- 11. Decoded event kinds without a coverage entry.
-- Expected: zero rows, excluding explicit `.instruction_audit` if it remains by design.
SELECT
de.event_kind,
COUNT(*) AS decoded_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
WHERE de.protocol_name = 'raydium_clmm'
AND ce.id IS NULL
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 12. Non-swap decoded events that created trades.
-- Expected: zero rows.
SELECT
de.event_kind,
ce.event_family,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_clmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_clmm'
GROUP BY de.event_kind, ce.event_family
HAVING ce.event_family <> 'swap'
AND COUNT(te.id) > 0
ORDER BY trade_count DESC, de.event_kind;

View File

@@ -0,0 +1,315 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_CPMM_0_7_50_PRE_R2.sql
-- Raydium CPMM 0.7.50-pre-r2 re-verification pack.
-- Goal: repeat the Launchpad-style closure checks on a dedicated CPMM
-- database, after replay with skipDexDecode='no' and forceDexDecode='yes'.
-- Expected invariants:
-- - no `unknown` or empty event_family except the synthetic `program` row;
-- - no observed discriminator missing from coverage;
-- - no residual upstream fallback for locally-covered entries;
-- - no successful, actionable decoded event left without its materialized row;
-- - no failed transaction materialized into business tables;
-- - decoded-only entries such as CPMM anchor IDL management and CLMM router/program-data
-- corroboration events are excluded from materialization shortfall checks.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
ORDER BY entry_kind, entry_name, discriminator_hex;
->
lp_change_event event liquidity k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_cpmm.lp_change_event 79a3cdc939da753c 25 25 0
swap_event event swap k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_cpmm.swap_event 40c6cde8260871e2 529 0 0
anchor_idl_instruction instruction idl_management k_sol_dex_decoded_events_only upstream_git_local_corpus_observed raydium_cpmm.anchor_idl_instruction 40f4bc78a7e9690a 6 0 0
close_permission_pda instruction admin_config k_sol_pool_admin_events upstream_git_mapped_unverified raydium_cpmm.close_permission_pda 9c5420764587467b 0 0 0
collect_creator_fee instruction fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_cpmm.collect_creator_fee 1416567bc61cdb84 4 4 0
collect_fund_fee instruction fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_cpmm.collect_fund_fee a78a4e95dfc2067e 7 7 0
collect_protocol_fee instruction fee k_sol_fee_events upstream_git_local_corpus_materialized raydium_cpmm.collect_protocol_fee 8888fcddc2427e59 15 15 0
cpi_event instruction cpi_transport k_sol_dex_decoded_events_only upstream_git_mapped_unverified raydium_cpmm.cpi_event e445a52e51cb9a1d 0 0 0
create_amm_config instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_cpmm.create_amm_config 8934edd4d7756c68 6 6 0
create_permission_pda instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_cpmm.create_permission_pda 878802d889a9b5ca 4 4 0
deposit instruction liquidity_add k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_cpmm.deposit f223c68952e1f2b6 11 11 0
initialize instruction pool_create k_sol_pool_lifecycle_events upstream_git_local_corpus_materialized raydium_cpmm.initialize afaf6d1f0d989bed 5 5 0
initialize_with_permission instruction pool_create k_sol_pool_lifecycle_events upstream_git_local_corpus_materialized raydium_cpmm.initialize_with_permission 3f37fe4131b25979 4 4 0
swap_base_input instruction swap k_sol_trade_events upstream_git_local_corpus_materialized raydium_cpmm.swap_base_input 8fbe5adac41e33de 750 482 482
swap_base_output instruction swap k_sol_trade_events upstream_git_local_corpus_materialized raydium_cpmm.swap_base_output 37d96256a34ab4ad 25 17 17
update_amm_config instruction admin_config k_sol_pool_admin_events upstream_git_local_corpus_materialized raydium_cpmm.update_amm_config 313cae889a1c74c8 13 13 0
update_pool_status instruction admin_config k_sol_pool_admin_events upstream_git_mapped_unverified raydium_cpmm.update_pool_status 82576c062ee0757b 0 0 0
withdraw instruction liquidity_remove k_sol_liquidity_events upstream_git_local_corpus_materialized raydium_cpmm.withdraw b712469c946da122 14 14 0
program program k_sol_dex_decoded_events_only upstream_git_unverified 0 0 0
SELECT
decoder_code,
COUNT(*) AS listed_entry_count,
SUM(CASE WHEN local_event_kind IS NOT NULL AND local_event_kind <> '' THEN 1 ELSE 0 END) AS decoded_entry_count,
SUM(CASE WHEN observed_count > 0 THEN 1 ELSE 0 END) AS observed_entry_count,
SUM(CASE WHEN materialized_count > 0 THEN 1 ELSE 0 END) AS materialized_entry_count,
COALESCE(SUM(observed_count), 0) AS total_observed_count,
COALESCE(SUM(materialized_count), 0) AS total_materialized_count,
COALESCE(SUM(trade_count), 0) AS trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
GROUP BY decoder_code;
->
raydium_cpmm 19 18 15 13 1418 607 499
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
AND (
event_family IS NULL
OR event_family = ''
OR event_family = 'unknown'
)
AND entry_kind <> 'program'
ORDER BY entry_kind, entry_name;
-> vide
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_cpmm'
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, instruction_name, discriminator_hex;
->
raydium_cpmm.swap_base_input 8fbe5adac41e33de 750 741
raydium_cpmm.swap_base_output 37d96256a34ab4ad 25 25
raydium_cpmm.collect_protocol_fee 8888fcddc2427e59 15 15
raydium_cpmm.withdraw b712469c946da122 14 13
raydium_cpmm.update_amm_config 313cae889a1c74c8 13 5
raydium_cpmm.deposit f223c68952e1f2b6 11 11
raydium_cpmm.collect_fund_fee a78a4e95dfc2067e 7 7
raydium_cpmm.create_amm_config 8934edd4d7756c68 6 4
raydium_cpmm.initialize afaf6d1f0d989bed 5 5
raydium_cpmm.collect_creator_fee 1416567bc61cdb84 4 4
raydium_cpmm.create_permission_pda 878802d889a9b5ca 4 4
raydium_cpmm.initialize_with_permission 3f37fe4131b25979 4 4
40f4bc78a7e9690a 3 3
SELECT
io.discriminator_hex,
MIN(io.instruction_name) AS sample_instruction_name,
MIN(io.decoded_event_kind) AS sample_decoded_event_kind,
COUNT(*) AS observed_count,
COUNT(DISTINCT io.signature) AS tx_count
FROM k_sol_instruction_observations io
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.discriminator_hex = io.discriminator_hex
WHERE io.decoder_code = 'raydium_cpmm'
AND io.discriminator_hex IS NOT NULL
AND io.discriminator_hex <> ''
AND ce.id IS NULL
GROUP BY io.discriminator_hex
ORDER BY observed_count DESC, io.discriminator_hex;
-> vide
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
->
raydium_cpmm.swap_base_input 750 0 0 0 0 0 0 0 0 482
raydium_cpmm.swap_event 529 0 0 0 0 0 0 0 0 0
raydium_cpmm.lp_change_event 25 25 0 0 0 0 0 0 0 0
raydium_cpmm.swap_base_output 25 0 0 0 0 0 0 0 0 17
raydium_cpmm.collect_protocol_fee 15 0 15 0 0 0 0 0 0 0
raydium_cpmm.withdraw 14 14 0 0 0 0 0 0 0 0
raydium_cpmm.update_amm_config 13 0 0 0 13 0 0 0 0 0
raydium_cpmm.deposit 11 11 0 0 0 0 0 0 0 0
raydium_cpmm.collect_fund_fee 7 0 7 0 0 0 0 0 0 0
raydium_cpmm.create_amm_config 6 0 0 0 6 0 0 0 0 0
raydium_cpmm.initialize 5 0 0 0 0 0 5 0 0 0
raydium_cpmm.collect_creator_fee 4 0 4 0 0 0 0 0 0 0
raydium_cpmm.create_permission_pda 4 0 0 0 4 0 0 0 0 0
raydium_cpmm.initialize_with_permission 4 0 0 0 0 0 4 0 0 0
raydium_cpmm.anchor_idl_instruction 3 0 0 0 0 0 0 0 0 0
raydium_cpmm.instruction_audit 3 0 0 0 0 0 0 0 0 0
SELECT
de.event_kind,
ce.entry_name,
ce.entry_kind,
ce.event_family,
ce.expected_db_target,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind, ce.entry_name, ce.entry_kind, ce.event_family, ce.expected_db_target
HAVING
COALESCE(ce.expected_db_target, '') <> 'k_sol_dex_decoded_events_only'
AND (liquidity_count + fee_count + reward_count + admin_count + launch_count + lifecycle_count + orderbook_count + token_account_count + trade_count + failed_tx_count) < decoded_count
ORDER BY decoded_count DESC, de.event_kind;
-> vide
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
AND tx.err_json IS NOT NULL
AND tx.err_json <> ''
AND tx.err_json <> 'null'
GROUP BY de.event_kind
HAVING
COUNT(le.id) > 0
OR COUNT(fe.id) > 0
OR COUNT(re.id) > 0
OR COUNT(ae.id) > 0
OR COUNT(la.id) > 0
OR COUNT(pe.id) > 0
OR COUNT(oe.id) > 0
OR COUNT(ta.id) > 0
OR COUNT(te.id) > 0
ORDER BY de.event_kind;
-> vide
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_cpmm'
AND event_kind = 'raydium_cpmm.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
->
40f4bc78a7e9690a 3 3
SELECT
json_extract(ug.payload_json, '$.upstreamDecoderCode') AS upstream_decoder_code,
json_extract(ug.payload_json, '$.upstreamEntryName') AS entry_name,
json_extract(ug.payload_json, '$.upstreamDiscriminatorHex') AS discriminator_hex,
json_extract(ug.payload_json, '$.upstreamSourceRepo') AS source_repo,
COUNT(*) AS fallback_count,
COUNT(DISTINCT ug.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events ug
JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = json_extract(ug.payload_json, '$.upstreamDecoderCode')
AND ce.entry_name = json_extract(ug.payload_json, '$.upstreamEntryName')
AND ce.discriminator_hex = json_extract(ug.payload_json, '$.upstreamDiscriminatorHex')
AND ce.local_event_kind IS NOT NULL
AND ce.local_event_kind <> ''
WHERE ug.protocol_name = 'upstream_git'
AND ug.event_kind = 'upstream_git.instruction_match'
AND json_extract(ug.payload_json, '$.upstreamDecoderCode') = 'raydium_cpmm'
GROUP BY upstream_decoder_code, entry_name, discriminator_hex, source_repo
ORDER BY fallback_count DESC, entry_name;
-> vide
SELECT
de.event_kind,
COUNT(*) AS decoded_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
WHERE de.protocol_name = 'raydium_cpmm'
AND ce.id IS NULL
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
->
raydium_cpmm.instruction_audit 3
SELECT
de.event_kind,
ce.event_family,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind, ce.event_family
HAVING ce.event_family <> 'swap'
AND COUNT(te.id) > 0
ORDER BY trade_count DESC, de.event_kind;
-> vide

View File

@@ -0,0 +1,273 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_CPMM_0_7_50_RECHECK.sql
-- Raydium CPMM 0.7.50 re-verification pack.
-- Goal: repeat the Launchpad-style closure checks on a dedicated CPMM
-- database, after replay with skipDexDecode='no' and forceDexDecode='yes'.
-- Expected invariants:
-- - no `unknown` or empty event_family except the synthetic `program` row;
-- - no observed discriminator missing from coverage;
-- - no residual upstream fallback for locally-covered entries;
-- - no successful, actionable decoded event left without its materialized row;
-- - no failed transaction materialized into business tables;
-- - decoded-only entries such as CPMM anchor IDL management and CLMM router/program-data
-- corroboration events are excluded from materialization shortfall checks.
-- 01. Coverage detail.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
ORDER BY entry_kind, entry_name, discriminator_hex;
-- 02. Coverage summary.
SELECT
decoder_code,
COUNT(*) AS listed_entry_count,
SUM(CASE WHEN local_event_kind IS NOT NULL AND local_event_kind <> '' THEN 1 ELSE 0 END) AS decoded_entry_count,
SUM(CASE WHEN observed_count > 0 THEN 1 ELSE 0 END) AS observed_entry_count,
SUM(CASE WHEN materialized_count > 0 THEN 1 ELSE 0 END) AS materialized_entry_count,
COALESCE(SUM(observed_count), 0) AS total_observed_count,
COALESCE(SUM(materialized_count), 0) AS total_materialized_count,
COALESCE(SUM(trade_count), 0) AS trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
GROUP BY decoder_code;
-- 03. Coverage family normalization guard.
-- Expected: zero rows, or only the synthetic `program` row if it intentionally has no family.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_cpmm'
AND (
event_family IS NULL
OR event_family = ''
OR event_family = 'unknown'
)
AND entry_kind <> 'program'
ORDER BY entry_kind, entry_name;
-- 04. Instruction observations by discriminator.
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_cpmm'
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, instruction_name, discriminator_hex;
-- 05. Observed discriminators absent from coverage.
-- Expected: zero rows.
SELECT
io.discriminator_hex,
MIN(io.instruction_name) AS sample_instruction_name,
MIN(io.decoded_event_kind) AS sample_decoded_event_kind,
COUNT(*) AS observed_count,
COUNT(DISTINCT io.signature) AS tx_count
FROM k_sol_instruction_observations io
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.discriminator_hex = io.discriminator_hex
WHERE io.decoder_code = 'raydium_cpmm'
AND io.discriminator_hex IS NOT NULL
AND io.discriminator_hex <> ''
AND ce.id IS NULL
GROUP BY io.discriminator_hex
ORDER BY observed_count DESC, io.discriminator_hex;
-- 06. Decoded event distribution and materialization links.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 07. Successful decoded events not materialized where coverage target says they should be.
-- Expected: zero rows, except expected_db_target='k_sol_dex_decoded_events_only' and failed tx rows.
SELECT
de.event_kind,
ce.entry_name,
ce.entry_kind,
ce.event_family,
ce.expected_db_target,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind, ce.entry_name, ce.entry_kind, ce.event_family, ce.expected_db_target
HAVING
COALESCE(ce.expected_db_target, '') <> 'k_sol_dex_decoded_events_only'
AND (liquidity_count + fee_count + reward_count + admin_count + launch_count + lifecycle_count + orderbook_count + token_account_count + trade_count + failed_tx_count) < decoded_count
ORDER BY decoded_count DESC, de.event_kind;
-- 08. Failed transaction materialization guard.
-- Expected: zero rows.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(le.id) AS liquidity_count,
COUNT(fe.id) AS fee_count,
COUNT(re.id) AS reward_count,
COUNT(ae.id) AS admin_count,
COUNT(la.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(oe.id) AS orderbook_count,
COUNT(ta.id) AS token_account_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx ON tx.id = de.transaction_id
LEFT JOIN k_sol_liquidity_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_reward_events re ON re.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events la ON la.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_orderbook_events oe ON oe.decoded_event_id = de.id
LEFT JOIN k_sol_token_account_events ta ON ta.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
AND tx.err_json IS NOT NULL
AND tx.err_json <> ''
AND tx.err_json <> 'null'
GROUP BY de.event_kind
HAVING
COUNT(le.id) > 0
OR COUNT(fe.id) > 0
OR COUNT(re.id) > 0
OR COUNT(ae.id) > 0
OR COUNT(la.id) > 0
OR COUNT(pe.id) > 0
OR COUNT(oe.id) > 0
OR COUNT(ta.id) > 0
OR COUNT(te.id) > 0
ORDER BY de.event_kind;
-- 09. Residual instruction audit rows.
-- Expected: zero rows after full direct mapping. `40f4bc78a7e9690a` should now
-- appear as `raydium_cpmm.anchor_idl_instruction`, not instruction_audit.
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_cpmm'
AND event_kind = 'raydium_cpmm.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
-- 10. Redundant upstream fallback matches for locally covered entries.
-- Expected: zero rows.
SELECT
json_extract(ug.payload_json, '$.upstreamDecoderCode') AS upstream_decoder_code,
json_extract(ug.payload_json, '$.upstreamEntryName') AS entry_name,
json_extract(ug.payload_json, '$.upstreamDiscriminatorHex') AS discriminator_hex,
json_extract(ug.payload_json, '$.upstreamSourceRepo') AS source_repo,
COUNT(*) AS fallback_count,
COUNT(DISTINCT ug.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events ug
JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = json_extract(ug.payload_json, '$.upstreamDecoderCode')
AND ce.entry_name = json_extract(ug.payload_json, '$.upstreamEntryName')
AND ce.discriminator_hex = json_extract(ug.payload_json, '$.upstreamDiscriminatorHex')
AND ce.local_event_kind IS NOT NULL
AND ce.local_event_kind <> ''
WHERE ug.protocol_name = 'upstream_git'
AND ug.event_kind = 'upstream_git.instruction_match'
AND json_extract(ug.payload_json, '$.upstreamDecoderCode') = 'raydium_cpmm'
GROUP BY upstream_decoder_code, entry_name, discriminator_hex, source_repo
ORDER BY fallback_count DESC, entry_name;
-- 11. Decoded event kinds without a coverage entry.
-- Expected: zero rows, excluding explicit `.instruction_audit` if it remains by design.
SELECT
de.event_kind,
COUNT(*) AS decoded_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
WHERE de.protocol_name = 'raydium_cpmm'
AND ce.id IS NULL
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 12. Non-swap decoded events that created trades.
-- Expected: zero rows.
SELECT
de.event_kind,
ce.event_family,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_cpmm'
GROUP BY de.event_kind, ce.event_family
HAVING ce.event_family <> 'swap'
AND COUNT(te.id) > 0
ORDER BY trade_count DESC, de.event_kind;

View File

@@ -0,0 +1,46 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_CPMM_AUDIT_CLEANUP_0_7_50_FINAL.sql
-- Raydium CPMM residual audit cleanup validation for 0.7.50 final.
-- These queries must be empty after applying the final cleanup patch and replaying with
-- skipDexDecode=no, forceDexDecode=yes, deferInstructionObservations=yes.
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_cpmm'
AND event_kind = 'raydium_cpmm.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
SELECT
de.event_kind,
COUNT(*) AS decoded_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_dex_event_coverage_entries ce
ON ce.decoder_code = 'raydium_cpmm'
AND ce.local_event_kind = de.event_kind
WHERE de.protocol_name = 'raydium_cpmm'
AND ce.id IS NULL
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- Manual emergency cleanup only if the application replay still leaves the legacy audit rows.
-- It intentionally unlinks k_sol_instruction_observations first, because existing DBs created
-- before ON DELETE SET NULL may otherwise retain decoded_event_id references.
UPDATE k_sol_instruction_observations
SET decoded_event_id = NULL
WHERE decoded_event_id IN (
SELECT id
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_cpmm'
AND event_kind = 'raydium_cpmm.instruction_audit'
AND instr(lower(COALESCE(payload_json, '')), '40f4bc78a7e9690a') > 0
);
DELETE FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_cpmm'
AND event_kind = 'raydium_cpmm.instruction_audit'
AND instr(lower(COALESCE(payload_json, '')), '40f4bc78a7e9690a') > 0;

View File

@@ -0,0 +1,347 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_LAUNCHPAD_0_7_50.sql
-- Raydium Launchpad 0.7.50 validation pack.
-- Notes:
-- - k_sol_pools uses column `address`, not `pool_address`.
-- - raydium_pool_v4 is deliberately excluded from runtime validation until its
-- program id and role are confirmed from source/corpus audit.
-- 01. Coverage detail.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_launchpad'
ORDER BY entry_kind, entry_name, discriminator_hex;
-- 02. Coverage summary.
SELECT
decoder_code,
COUNT(*) AS listed_entry_count,
SUM(CASE WHEN local_event_kind IS NOT NULL AND local_event_kind <> '' THEN 1 ELSE 0 END) AS decoded_entry_count,
SUM(CASE WHEN observed_count > 0 THEN 1 ELSE 0 END) AS observed_entry_count,
SUM(CASE WHEN materialized_count > 0 THEN 1 ELSE 0 END) AS materialized_entry_count,
COALESCE(SUM(observed_count), 0) AS total_observed_count,
COALESCE(SUM(materialized_count), 0) AS total_materialized_count,
COALESCE(SUM(trade_count), 0) AS trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_launchpad'
GROUP BY decoder_code;
-- 03. Instruction observations.
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_launchpad'
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, instruction_name;
-- 04. Decoded event distribution.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 05. Upstream fallback residual. Expected: empty.
SELECT
json_extract(payload_json, '$.upstreamDecoderCode') AS upstream_decoder_code,
json_extract(payload_json, '$.upstreamEntryName') AS entry_name,
json_extract(payload_json, '$.upstreamDiscriminatorHex') AS discriminator_hex,
COUNT(*) AS fallback_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'upstream_git'
AND event_kind = 'upstream_git.instruction_match'
AND json_extract(payload_json, '$.upstreamDecoderCode') = 'raydium_launchpad'
GROUP BY upstream_decoder_code, entry_name, discriminator_hex
ORDER BY fallback_count DESC, entry_name;
-- 06. Failed transaction materialization guard. Expected: trade_count = 0.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx
ON tx.id = de.transaction_id
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
AND tx.err_json IS NOT NULL
AND tx.err_json <> ''
AND tx.err_json <> 'null'
GROUP BY de.event_kind
ORDER BY trade_count DESC, decoded_count DESC;
-- 07. Residual audit discriminators.
-- Expected after pre5: e445a52e51cb9a1d should no longer remain in decoded audit rows.
SELECT
json_extract(payload_json, '$.discriminatorHex') AS discriminator_hex,
COUNT(*) AS audit_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_launchpad'
AND event_kind = 'raydium_launchpad.instruction_audit'
GROUP BY discriminator_hex
ORDER BY audit_count DESC, discriminator_hex;
-- 08. Self-CPI transport still present inside residual audit rows.
-- Expected after pre5: empty for known embedded event discriminators.
SELECT
json_extract(payload_json, '$.anchorSelfCpiLog') AS anchor_self_cpi_log,
json_extract(payload_json, '$.anchorSelfCpiLogSelectorHex') AS cpi_selector_hex,
json_extract(payload_json, '$.anchorEventDiscriminatorHex') AS anchor_event_discriminator_hex,
COUNT(*) AS decoded_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_launchpad'
AND event_kind = 'raydium_launchpad.instruction_audit'
AND json_extract(payload_json, '$.anchorSelfCpiLog') = 1
GROUP BY
anchor_self_cpi_log,
cpi_selector_hex,
anchor_event_discriminator_hex
ORDER BY decoded_count DESC, anchor_event_discriminator_hex;
-- 09. Direct Launchpad self-CPI events.
SELECT
event_kind,
json_extract(payload_json, '$.anchorEventDiscriminatorHex') AS anchor_event_discriminator_hex,
COUNT(*) AS decoded_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_launchpad'
AND event_kind IN (
'raydium_launchpad.trade_event',
'raydium_launchpad.pool_create_event',
'raydium_launchpad.claim_vested_event',
'raydium_launchpad.create_vesting_event'
)
GROUP BY event_kind, anchor_event_discriminator_hex
ORDER BY decoded_count DESC, event_kind;
-- 10. Launchpad initialize* pool hints.
SELECT
de.event_kind,
de.pool_account,
de.token_a_mint,
de.token_b_mint,
json_extract(de.payload_json, '$.instructionName') AS instruction_name,
COUNT(*) AS decoded_count,
COUNT(DISTINCT de.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events de
WHERE de.protocol_name = 'raydium_launchpad'
AND de.event_kind IN (
'raydium_launchpad.initialize',
'raydium_launchpad.initialize_v2',
'raydium_launchpad.initialize_with_token_2022'
)
GROUP BY
de.event_kind,
de.pool_account,
de.token_a_mint,
de.token_b_mint,
instruction_name
ORDER BY decoded_count DESC, de.event_kind;
-- 11. Launchpad pool/pair catalog materialized from initialize*.
SELECT
p.address AS pool_address,
pa.id AS pair_id,
d.code AS dex_code,
bt.mint AS base_mint,
bt.symbol AS base_symbol,
qt.mint AS quote_mint,
qt.symbol AS quote_symbol,
p.pool_kind,
p.status
FROM k_sol_pools p
JOIN k_sol_dexes d
ON d.id = p.dex_id
LEFT JOIN k_sol_pairs pa
ON pa.pool_id = p.id
LEFT JOIN k_sol_tokens bt
ON bt.id = pa.base_token_id
LEFT JOIN k_sol_tokens qt
ON qt.id = pa.quote_token_id
WHERE d.code = 'raydium_launchpad'
ORDER BY p.id DESC;
-- 12. Specific pool/pair probe.
SELECT
p.address AS pool_address,
pa.id AS pair_id,
d.code AS dex_code
FROM k_sol_pools p
JOIN k_sol_dexes d
ON d.id = p.dex_id
LEFT JOIN k_sol_pairs pa
ON pa.pool_id = p.id
WHERE p.address = '6HLQPoLrzX6LqePRiXQ1GGs2Dd9K3dp9VhTSHBugYzzZ';
-- 13. Pool-create events that do not yet have normalized local catalog rows.
SELECT
de.pool_account,
COUNT(*) AS decoded_count,
COUNT(DISTINCT de.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_pools p
ON p.address = de.pool_account
WHERE de.protocol_name = 'raydium_launchpad'
AND de.event_kind = 'raydium_launchpad.pool_create_event'
AND p.id IS NULL
GROUP BY de.pool_account
ORDER BY decoded_count DESC, de.pool_account;
-- 14. Launchpad buy/sell instruction pool hints used to backfill catalog rows.
SELECT
de.event_kind,
de.pool_account,
de.token_a_mint,
de.token_b_mint,
json_extract(de.payload_json, '$.instructionName') AS instruction_name,
COUNT(*) AS decoded_count,
COUNT(DISTINCT de.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events de
WHERE de.protocol_name = 'raydium_launchpad'
AND de.event_kind IN (
'raydium_launchpad.buy_exact_in',
'raydium_launchpad.buy_exact_out',
'raydium_launchpad.sell_exact_in',
'raydium_launchpad.sell_exact_out'
)
GROUP BY
de.event_kind,
de.pool_account,
de.token_a_mint,
de.token_b_mint,
instruction_name
ORDER BY decoded_count DESC, de.event_kind;
-- 15. Direct Launchpad trade-event materialization readiness.
SELECT
de.pool_account,
json_extract(de.payload_json, '$.tradeSide') AS trade_side,
json_extract(de.payload_json, '$.baseAmountRaw') AS base_amount_raw,
json_extract(de.payload_json, '$.quoteAmountRaw') AS quote_amount_raw,
json_extract(de.payload_json, '$.tradeCandidate') AS trade_candidate,
json_extract(de.payload_json, '$.candleCandidate') AS candle_candidate,
COUNT(*) AS decoded_count,
COUNT(te.id) AS trade_count,
COUNT(DISTINCT de.transaction_id) AS tx_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
AND de.event_kind = 'raydium_launchpad.trade_event'
GROUP BY
de.pool_account,
trade_side,
base_amount_raw,
quote_amount_raw,
trade_candidate,
candle_candidate
ORDER BY decoded_count DESC, de.pool_account;
-- 16. Launchpad pairs with decoded trade events but no materialized trade rows.
SELECT
p.address AS pool_address,
pa.id AS pair_id,
COUNT(de.id) AS decoded_trade_event_count,
COUNT(te.id) AS materialized_trade_count
FROM k_sol_pools p
JOIN k_sol_dexes d
ON d.id = p.dex_id
JOIN k_sol_pairs pa
ON pa.pool_id = p.id
LEFT JOIN k_sol_dex_decoded_events de
ON de.pool_account = p.address
AND de.protocol_name = 'raydium_launchpad'
AND de.event_kind = 'raydium_launchpad.trade_event'
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE d.code = 'raydium_launchpad'
GROUP BY p.address, pa.id
HAVING decoded_trade_event_count > 0
ORDER BY decoded_trade_event_count DESC, p.address;
-- 17. Launchpad candles by pair after trade-event promotion.
SELECT
pair_id,
timeframe_seconds,
COUNT(*) AS candle_count,
SUM(trade_count) AS trade_count,
MIN(bucket_start_unix) AS first_bucket_start_unix,
MAX(bucket_start_unix) AS last_bucket_start_unix
FROM k_sol_pair_candles
WHERE pair_id IN (
SELECT pa.id
FROM k_sol_pairs pa
JOIN k_sol_pools p ON p.id = pa.pool_id
JOIN k_sol_dexes d ON d.id = p.dex_id
WHERE d.code = 'raydium_launchpad'
)
GROUP BY pair_id, timeframe_seconds
ORDER BY pair_id, timeframe_seconds;
-- 18. Launchpad trade events still not materializable after pre7.
-- Expected after pre7: rows should be limited to failed transactions or missing token balance metadata.
SELECT
de.pool_account,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(CASE WHEN json_extract(de.payload_json, '$.tradeCandidate') = 1 THEN de.id END) AS trade_candidate_count,
COUNT(CASE WHEN json_extract(de.payload_json, '$.baseAmountRaw') IS NULL THEN de.id END) AS missing_base_amount_count,
COUNT(CASE WHEN json_extract(de.payload_json, '$.quoteAmountRaw') IS NULL THEN de.id END) AS missing_quote_amount_count,
COUNT(te.id) AS materialized_trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx
ON tx.id = de.transaction_id
LEFT JOIN k_sol_trade_events te
ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
AND de.event_kind = 'raydium_launchpad.trade_event'
GROUP BY de.pool_account
HAVING materialized_trade_count = 0
ORDER BY decoded_count DESC, de.pool_account;
-- 19. Launchpad event payload parser health.
-- Expected after pre7: direct trade_event rows should expose raw amount fields for successful self-CPI events.
SELECT
json_extract(payload_json, '$.anchorSelfCpiDataLength') AS anchor_self_cpi_data_length,
json_extract(payload_json, '$.anchorEventPayloadSize') AS anchor_event_payload_size,
json_extract(payload_json, '$.tradeDirectionRaw') AS trade_direction_raw,
json_extract(payload_json, '$.amountInRaw') AS amount_in_raw,
json_extract(payload_json, '$.amountOutRaw') AS amount_out_raw,
json_extract(payload_json, '$.baseAmountRaw') AS base_amount_raw,
json_extract(payload_json, '$.quoteAmountRaw') AS quote_amount_raw,
COUNT(*) AS decoded_count,
COUNT(DISTINCT transaction_id) AS tx_count
FROM k_sol_dex_decoded_events
WHERE protocol_name = 'raydium_launchpad'
AND event_kind = 'raydium_launchpad.trade_event'
GROUP BY
anchor_self_cpi_data_length,
anchor_event_payload_size,
trade_direction_raw,
amount_in_raw,
amount_out_raw,
base_amount_raw,
quote_amount_raw
ORDER BY decoded_count DESC;

View File

@@ -0,0 +1,112 @@
-- file: validation_sql/SQL_VALIDATION_RAYDIUM_LAUNCHPAD_0_7_50_PRE9.sql
-- Raydium Launchpad pre9 validation additions.
-- 1. Coverage entries, including late Carbon instructions and launch-event target table.
SELECT
entry_name,
entry_kind,
event_family,
expected_db_target,
proof_status,
local_event_kind,
discriminator_hex,
observed_count,
materialized_count,
trade_count
FROM k_sol_dex_event_coverage_entries
WHERE decoder_code = 'raydium_launchpad'
ORDER BY entry_kind, entry_name, discriminator_hex;
-- 2. Launchpad-specific materialized events.
SELECT
le.event_kind,
le.event_role,
le.pool_account,
COUNT(*) AS launch_event_count,
COUNT(DISTINCT le.signature) AS tx_count
FROM k_sol_launch_events le
WHERE le.protocol_name = 'raydium_launchpad'
GROUP BY le.event_kind, le.event_role, le.pool_account
ORDER BY launch_event_count DESC, le.event_kind, le.pool_account;
-- 3. Fee materialization for Launchpad fee instructions.
SELECT
fe.event_kind,
fe.pool_account,
COUNT(*) AS fee_event_count,
COUNT(DISTINCT fe.signature) AS tx_count
FROM k_sol_fee_events fe
WHERE fe.protocol_name = 'raydium_launchpad'
GROUP BY fe.event_kind, fe.pool_account
ORDER BY fee_event_count DESC, fe.event_kind;
-- 4. Admin/config/access materialization for Launchpad admin instructions.
SELECT
ae.event_kind,
ae.admin_action,
ae.pool_account,
COUNT(*) AS admin_event_count,
COUNT(DISTINCT ae.signature) AS tx_count
FROM k_sol_pool_admin_events ae
WHERE ae.protocol_name = 'raydium_launchpad'
GROUP BY ae.event_kind, ae.admin_action, ae.pool_account
ORDER BY admin_event_count DESC, ae.event_kind;
-- 5. Late Carbon instruction corpus identifiers.
SELECT
instruction_name,
discriminator_hex,
COUNT(*) AS observed_count,
COUNT(DISTINCT signature) AS tx_count
FROM k_sol_instruction_observations
WHERE decoder_code = 'raydium_launchpad'
AND discriminator_hex IN (
'7bb4b8816fb9bb3b', -- close_platform_global_access
'a25b92c75d85eaed', -- create_platform_global_access
'9247ad4562130f6a', -- create_platform_vesting_account
'e445a52e51cb9a1d' -- cpi_event / Anchor self-CPI transport
)
GROUP BY instruction_name, discriminator_hex
ORDER BY observed_count DESC, discriminator_hex;
-- 6. Residual Launchpad decoded events that are still only decoded, not materialized.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(fe.id) AS fee_count,
COUNT(ae.id) AS admin_count,
COUNT(le.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
GROUP BY de.event_kind
ORDER BY decoded_count DESC, de.event_kind;
-- 7. Residual decoded-only Launchpad events split by failed/success transaction.
SELECT
de.event_kind,
COUNT(*) AS decoded_count,
COUNT(CASE WHEN tx.err_json IS NOT NULL AND tx.err_json <> '' AND tx.err_json <> 'null' THEN de.id END) AS failed_tx_count,
COUNT(fe.id) AS fee_count,
COUNT(ae.id) AS admin_count,
COUNT(le.id) AS launch_count,
COUNT(pe.id) AS lifecycle_count,
COUNT(te.id) AS trade_count
FROM k_sol_dex_decoded_events de
JOIN k_sol_chain_transactions tx
ON tx.id = de.transaction_id
LEFT JOIN k_sol_fee_events fe ON fe.decoded_event_id = de.id
LEFT JOIN k_sol_pool_admin_events ae ON ae.decoded_event_id = de.id
LEFT JOIN k_sol_launch_events le ON le.decoded_event_id = de.id
LEFT JOIN k_sol_pool_lifecycle_events pe ON pe.decoded_event_id = de.id
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = de.id
WHERE de.protocol_name = 'raydium_launchpad'
GROUP BY de.event_kind
HAVING (fee_count + admin_count + launch_count + lifecycle_count + trade_count) < decoded_count
ORDER BY decoded_count DESC, de.event_kind;