Query editor
/*──────────────────────────────────────────────────────────────(QUERY A) Dogwallets - RECOLECTOR DE EVENTOS EXITOSOS (Período Completo)Recoge todas las operaciones/trades y verifica que sus transacciones fueron exitosas.──────────────────────────────────────────────────────────────*/WITHparams AS (SELECT'GDYAPTNACFQVAPUCD6LIV3RK75ERETZAID6KAN6K6NCPLEOBUCWPVC3R' AS dogwallet_funder,DATE '2025-05-26' AS date_start,DATE '2025-07-25' AS date_end),successful_transaction_ids AS (SELECT DISTINCT idFROM stellar.history_transactionsWHERE successful = trueAND closed_at >= (SELECT date_start FROM params) - interval '2' dayAND closed_at <= (SELECT date_end FROM params) + interval '2' day),accounts_dogwallets AS (SELECT DISTINCT h.accountFROM stellar.history_operations hWHERE h.type_string = 'create_account' AND h.funder = (SELECT dogwallet_funder FROM params)),ops_simple AS (SELECT o.transaction_id, date_trunc('day', o.closed_at) AS event_day, o.source_account AS account, CAST(o.amount AS DOUBLE) AS amount, CASE WHEN o.asset_type = 'native' THEN 'XLM' ELSE o.asset_code END AS asset_code, CASE WHEN o.asset_type = 'native' THEN NULL ELSE o.asset_issuer END AS asset_issuerFROM stellar.history_operations oWHERE o.source_account IN (SELECT account FROM accounts_dogwallets) AND o.type_string IN ('payment', 'path_payment_strict_send', 'path_payment_strict_receive') AND o.closed_at >= (SELECT date_start FROM params) AND o.closed_at < date_add('day', 1, (SELECT date_end FROM params))),ops_lp AS (SELECT o.transaction_id, date_trunc('day', o.closed_at) AS event_day, o.source_account AS account, CAST(COALESCE(o.reserve_a_deposit_amount, 0) - COALESCE(o.reserve_a_withdraw_amount, 0) AS DOUBLE) AS amount, CASE WHEN o.reserve_a_asset_type = 'native' THEN 'XLM' ELSE o.reserve_a_asset_code END AS asset_code, CASE WHEN o.reserve_a_asset_type = 'native' THEN NULL ELSE o.reserve_a_asset_issuer END AS asset_issuer FROM stellar.history_operations o WHERE o.source_account IN (SELECT account FROM accounts_dogwallets) AND o.type_string IN ('liquidity_pool_deposit','liquidity_pool_withdraw') AND o.closed_at >= (SELECT date_start FROM params) AND o.closed_at < date_add('day', 1, (SELECT date_end FROM params))UNION ALLSELECT o.transaction_id, date_trunc('day', o.closed_at) AS event_day, o.source_account AS account, CAST(COALESCE(o.reserve_b_deposit_amount, 0) - COALESCE(o.reserve_b_withdraw_amount, 0) AS DOUBLE) AS amount, CASE WHEN o.reserve_b_asset_type = 'native' THEN 'XLM' ELSE o.reserve_b_asset_code END, CASE WHEN o.reserve_b_asset_type = 'native' THEN NULL ELSE o.reserve_b_asset_issuer END FROM stellar.history_operations o WHERE o.source_account IN (SELECT account FROM accounts_dogwallets) AND o.type_string IN ('liquidity_pool_deposit','liquidity_pool_withdraw') AND o.closed_at >= (SELECT date_start FROM params) AND o.closed_at < date_add('day', 1, (SELECT date_end FROM params))),trades AS (SELECT ho.transaction_id, date_trunc('day', ht.closed_at) AS event_day, CASE WHEN ht.selling_account_address = adw.account THEN ht.selling_account_address ELSE ht.buying_account_address END AS account, CAST(CASE WHEN ht.selling_account_address = adw.account THEN ht.selling_amount ELSE ht.buying_amount END AS DOUBLE) AS amount, CASE WHEN ht.selling_account_address = adw.account THEN CASE WHEN ht.selling_asset_type='native' THEN 'XLM' ELSE ht.selling_asset_code END ELSE CASE WHEN ht.buying_asset_type='native' THEN 'XLM' ELSE ht.buying_asset_code END END AS asset_code, CASE WHEN ht.selling_account_address = adw.account THEN CASE WHEN ht.selling_asset_type='native' THEN NULL ELSE ht.selling_asset_issuer END ELSE CASE WHEN ht.buying_asset_type='native' THEN NULL ELSE ht.buying_asset_issuer END END AS asset_issuerFROM stellar.history_trades htJOIN accounts_dogwallets adw ON ht.selling_account_address = adw.account OR ht.buying_account_address = adw.accountJOIN stellar.history_operations ho ON ht.history_operation_id = ho.idWHERE ht.closed_at >= (SELECT date_start FROM params) AND ht.closed_at < date_add('day', 1, (SELECT date_end FROM params)) AND ht.selling_liquidity_pool_id IS NULL),all_events AS (SELECT * FROM ops_simple UNION ALL SELECT * FROM ops_lp UNION ALL SELECT * FROM trades)SELECT ev.transaction_id, ev.account, ev.event_day, ev.amount, ev.asset_code, ev.asset_issuerFROM all_events evJOIN successful_transaction_ids st ON ev.transaction_id = st.idWHERE ev.amount <> 0