Query editor
/*──────────────────────────────────────────────────────────────Dogstar Dogwallets - Current Week Total Volume▸ Calculates the total WTV in USD generated THIS WEEK SO FAR (Mon-Now)by ALL Dogwallets (funded by 'GDYA...VC3R').▸ Uses shared asset list (query_5034222).▸ Uses stable pricing calculated over the prior 12 weeks + current week up to now.──────────────────────────────────────────────────────────────*/WITHparams AS (SELECTdate_trunc('week', date_add('week', -12, current_date)) AS pricing_window_start,current_date AS pricing_window_end, -- Use current date for up-to-date stable pricing basis'GDYAPTNACFQVAPUCD6LIV3RK75ERETZAID6KAN6K6NCPLEOBUCWPVC3R' AS dogwallet_funder,'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN' AS usdc_issuer,date_trunc('week', current_date) AS current_week_start),-- Select ALL accounts ever created by the Dogwallet funderaccounts_dogwallets AS (SELECT DISTINCT h.accountFROM stellar.history_operations hJOIN params p ON TRUEWHERE h.type_string = 'create_account' AND h.funder = p.dogwallet_funder),-- Reads from the centralized asset list query (ID: 5034222)is_allowed_asset AS (SELECT asset_code, asset_issuer FROM query_5034222),-- Operations from Dogwallets occurring this weekops AS (SELECT -- *** Full SELECT list ***'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 oJOIN accounts_dogwallets adw ON o.source_account = adw.accountJOIN params p ON TRUEJOIN 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.current_week_start -- Filter events for current week),-- Trades from Dogwallets occurring this weektrades AS (SELECT -- *** Full SELECT list ***'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 htJOIN accounts_dogwallets adw ON ht.selling_account_address = adw.account OR ht.buying_account_address = adw.accountJOIN params p ON TRUEJOIN 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 NULL