Skip to content

Instantly share code, notes, and snippets.

@Vergan-star
Created September 30, 2020 06:04
Show Gist options
  • Save Vergan-star/6dc7e6273fbe430e73c53bdee0514de1 to your computer and use it in GitHub Desktop.
Save Vergan-star/6dc7e6273fbe430e73c53bdee0514de1 to your computer and use it in GitHub Desktop.
btc_volume
WITH deposits as
(
SELECT
block_time,
sum(e.value/1e18 * p.price) as vol
FROM erc20."ERC20_evt_Transfer" e
LEFT JOIN ethereum."transactions" tx ON evt_tx_hash = tx.hash
INNER JOIN prices."layer1_usd_btc" p ON p.minute = date_trunc('minute', block_time)
WHERE e."contract_address" = '\x8dAEBADE922dF735c38C80C7eBD708Af50815fAa' -- tBTC contract address
AND e."from" = '\x0000000000000000000000000000000000000000'
GROUP BY 1
ORDER BY 1 desc
)
SELECT
sum(vol) as "Cumulative BTC Deposit Volume"
FROM deposits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment