Query editor
/*──────────────────────────────────────────────────────────────Dogstar Dogwallets - Weekly Volume Trend (Last 12 Weeks - No Effects)▸ Shows the total WTV in USD generated per week by ALL Dogwallets.▸ Volume INCLUDES specified ops and trades initiated by accounts.▸ Volume EXCLUDES passive effects like receiving credits.──────────────────────────────────────────────────────────────*/WITHparams AS (SELECTdate_trunc('week', date_add('week', -12, current_date)) AS pricing_window_start,current_date AS pricing_window_end,'GDYAPTNACFQVAPUCD6LIV3RK75ERETZAID6KAN6K6NCPLEOBUCWPVC3R' AS dogwallet_funder,'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN' AS usdc_issuer),accounts_dogwallets AS (SELECT DISTINCT h.accountFROM stellar.history_operations hJOIN params p ON TRUEWHEREh.type_string = 'create_account'AND h.funder = p.dogwallet_funder),is_allowed_asset AS (SELECT asset_code, asset_issuer FROM query_5034222),ops AS (SELECT 'ops' AS source_cte, date_trunc('day', o.closed_at) AS event_day, 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_issuer, CAST(o.amount AS DOUBLE) AS amountFROM stellar.history_operations o JOIN accounts_dogwallets adw ON o.source_account = adw.account JOIN params p ON TRUE JOIN is_allowed_asset allowed ON (CASE WHEN o.asset_type='native' THEN 'XLM' ELSE o.asset_code END) = allowed.asset_code AND (CASE WHEN o.asset_type='native' THEN TRUE ELSE o.asset_issuer = allowed.asset_issuer END)WHERE o.type_string IN ('payment', 'path_payment_strict_send', 'path_payment_strict_receive', 'liquidity_pool_deposit', 'liquidity_pool_withdraw')AND o.closed_at >= p.pricing_window_startAND o.closed_at <= p.pricing_window_end),trades AS (SELECT 'trades' AS source_cte, date_trunc('day', ht.closed_at) AS event_day, CASE WHEN ht.selling_asset_type='native' THEN 'XLM' ELSE ht.selling_asset_code END AS asset_code, CASE WHEN ht.selling_asset_type='native' THEN NULL ELSE ht.selling_asset_issuer END AS asset_issuer, CAST(ht.selling_amount AS DOUBLE) AS amountFROM stellar.history_trades ht JOIN accounts_dogwallets adw ON ht.selling_account_address = adw.account OR ht.buying_account_address = adw.account JOIN params p ON TRUE JOIN is_allowed_asset allowed_selling ON (CASE WHEN ht.selling_asset_type='native' THEN 'XLM' ELSE ht.selling_asset_code END) = allowed_selling.asset_code AND (CASE WHEN ht.selling_asset_type='native' THEN TRUE ELSE ht.selling_asset_issuer = allowed_selling.asset_issuer END) JOIN is_allowed_asset allowed_buying ON (CASE WHEN ht.buying_asset_type='native' THEN 'XLM' ELSE ht.buying_asset_code END) = allowed_buying.asset_code AND (CASE WHEN ht.buying_asset_type='native' THEN TRUE ELSE ht.buying_asset_issuer = allowed_buying.asset_issuer END)WHERE ht.selling_liquidity_pool_id IS NULLAND ht.closed_at >= p.pricing_window_startAND ht.closed_at <= p.pricing_window_end),-- La CTE 'credits' ha sido eliminada.events AS (SELECT source_cte, event_day, asset_code, asset_issuer, amount FROM opsUNION ALLSELECT source_cte, event_day, asset_code, asset_issuer, amount FROM trades-- La línea que unía 'credits' ha sido eliminada.),daily_xlm_avg_price AS (SELECTdate_trunc('day', ht.closed_at) AS day,AVG(CASEWHEN ht.buying_asset_code = 'USDC' AND ht.selling_asset_type = 'native' THEN ht.buying_amount / ht.selling_amountWHEN ht.selling_asset_code = 'USDC' AND ht.buying_asset_type = 'native' THEN ht.selling_amount / ht.buying_amount