Created
September 30, 2020 06:03
-
-
Save Vergan-star/e05f4c3107ae8293063cb358628c6353 to your computer and use it in GitHub Desktop.
tbtc_suuply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH tBTC AS | |
( | |
SELECT | |
date_trunc('day', block_time) as day, | |
COALESCE(sum(e.value/1e18), 0) as supply | |
FROM erc20."ERC20_evt_Transfer" e | |
LEFT JOIN ethereum."transactions" tx ON evt_tx_hash = tx.hash | |
WHERE "contract_address" = '\x8dAEBADE922dF735c38C80C7eBD708Af50815fAa' -- tBTC contract address | |
and e."from" = '\x0000000000000000000000000000000000000000' | |
GROUP BY 1 | |
UNION ALL | |
SELECT | |
date_trunc('day', block_time) as day, | |
COALESCE(sum(-e.value/1e18), 0) as supply | |
FROM erc20."ERC20_evt_Transfer" e | |
LEFT JOIN ethereum."transactions" tx ON evt_tx_hash = tx.hash | |
WHERE "contract_address" = '\x8dAEBADE922dF735c38C80C7eBD708Af50815fAa' -- tBTC contract address | |
and e."to" = '\x0000000000000000000000000000000000000000' | |
GROUP BY 1 | |
) | |
SELECT | |
sum(supply) | |
FROM tBTC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment