Query editor
/*──────────────────────────────────────────────────────────────Dogwallets - Operations & USD Volume per Account (SUCCESSFUL Transactions Only)Final Corrected Version: Simplified event gathering logic to fix errors and using Spot Price for performance.──────────────────────────────────────────────────────────────*/WITH/* 1. Parameters */params AS (SELECT'GDYAPTNACFQVAPUCD6LIV3RK75ERETZAID6KAN6K6NCPLEOBUCWPVC3R' AS dogwallet_funder,DATE '2025-05-26' AS date_start,LEAST(current_date, DATE '2025-06-21') AS date_end,LEAST(current_date, DATE '2025-06-21') - interval '7' day AS pricing_window_start,LEAST(current_date, DATE '2025-06-21') + interval '1' day AS pricing_window_end,'USDC' AS quote_code,'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN' AS usdc_issuer),/* 1.5. Successful Transactions IDs */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),/* 2. All Dogwallets */accounts_dogwallets AS (SELECT DISTINCT h.accountFROM stellar.history_operations hWHERE h.type_string = 'create_account'AND h.funder = (SELECT dogwallet_funder FROM params)),/* 3. Allowed assets list */allowed_assets AS (SELECT asset_code, asset_issuer FROM query_5034222UNION ALLSELECT 'XLM', NULL),/* 4. REWRITTEN & SIMPLIFIED: Gather all successful events */successful_events AS (-- Simple Payments from successful transactionsSELECT 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 oJOIN successful_transaction_ids st ON o.transaction_id = st.idWHERE 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))AND o.amount <> 0UNION ALL-- LP Operations from successful transactions (both reserves A and B)SELECT o.source_account AS account, CAST(amount AS DOUBLE) AS amount, asset_code, asset_issuerFROM (SELECT o.transaction_id, o.source_account,