Query editor
WITH base_info AS (SELECT plain_issuer, issuer, etf_ticker, percentage_fee, address_sourceFROM (VALUES('Grayscale', get_href('https://etfs.grayscale.com/gbtc', 'Grayscale'), 'GBTC', 0.015, get_href('https://platform.arkhamintelligence.com/explorer/entity/grayscale', '🟠')), ('BlackRock', get_href('https://www.blackrock.com/us/financial-professionals/investment-strategies/bitcoin-investing', 'BlackRock'), 'IBIT', 0.0025, get_href('https://platform.arkhamintelligence.com/explorer/entity/blackrock', '🟠')), ('Fidelity', get_href('https://www.fidelity.com/etfs/fbtc', 'Fidelity'), 'FBTC', 0.0025, get_href('https://platform.arkhamintelligence.com/explorer/entity/fidelity', '🟠')), ('21Shares', get_href('https://21shares.com/en-US/product/ARKB', '21Shares'), 'ARKB', 0.0021, get_href('https://platform.arkhamintelligence.com/explorer/entity/ark-invest', '🟠') || ' ' || get_href('https://data.chain.link/feeds/ethereum/mainnet/arkb-por', '🔵')), ('Bitwise', get_href('https://bitbetf.com/', 'Bitwise'), 'BITB', 0.002, get_href('https://bitbetf.com/', '🟢')), ('Invesco', get_href('https://www.invesco.com/us/en/etf/galaxy-bitcoin-btco.html', 'Invesco'), 'BTCO', 0.0025, get_href('https://platform.arkhamintelligence.com/explorer/entity/invesco', '🟠')), ('VanEck', get_href('https://www.vaneck.com/us/en/investments/bitcoin-trust-hodl/overview/', 'VanEck'), 'HODL', 0.0025, get_href('https://platform.arkhamintelligence.com/explorer/entity/vaneck', '🟠')), ('Valkyrie', get_href('https://valkyrieinvest.com/brrr/', 'Valkyrie'), 'BRRR', 0.0025, get_href('https://platform.arkhamintelligence.com/explorer/entity/valkyrie', '🟠')), ('Franklin Templeton', get_href('https://www.franklintempleton.com/strategies/bitcoin-etf', 'Franklin Templeton'), 'EZBC', 0.0019, get_href('https://platform.arkhamintelligence.com/explorer/entity/franklin-templeton', '🟠')), ('WisdomTree', get_href('https://www.wisdomtree.com/investments/etfs/crypto/btcw', 'WisdomTree'), 'BTCW', 0.0030, get_href('https://platform.arkhamintelligence.com/explorer/entity/wisdomtree', '🟠'))) AS t(plain_issuer, issuer, etf_ticker, percentage_fee, address_source)ORDER BY address_source, percentage_fee DESC), tvl AS (SELECT f.issuer, f.etf_ticker, SUM(f.amount) AS tvlFROM (SELECT i.block_time, issuer, etf_ticker, 'deposit' AS flow_type, i.value AS amountFROM bitcoin.outputs iINNER JOIN query_3378085 -- Known ETF address lista ON a.address=i.addressAND a.track_inflowWHERE i.value > 0AND i.block_time > date('2019-07-24')AND i.block_time <= (SELECT time_limit FROM query_3433379)UNION ALLSELECT i.block_time, issuer, etf_ticker, 'withdrawal' AS flow_type, -1*i.value AS amountFROM bitcoin.inputs iINNER JOIN query_3378085 -- Known ETF address lista ON a.address=i.addressAND a.track_outflowWHERE i.value > 0AND i.block_time > date('2019-07-24')AND i.block_time <= (SELECT time_limit FROM query_3433379)) fGROUP BY 1, 2), totals AS (SELECT bi.plain_issuer, bi.issuer, COALESCE(CAST(t.tvl AS varchar), '⁉️') AS tvl, CAST(t.tvl AS double) AS tvl_double, t.tvl*pu.price AS usd_value--, COALESCE(CAST(t.usd_value AS varchar), '⁉️') AS usd_value