Skip to content

Commit

Permalink
Auto-format queries
Browse files Browse the repository at this point in the history
  • Loading branch information
BigQuery AutoFormatter committed Feb 11, 2021
1 parent 7dc65c7 commit 92bbeb5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 37 deletions.
16 changes: 10 additions & 6 deletions dune/gas/MEV_ZeroCostTx.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
select t.*, b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data
from ethereum.transactions t
join ethereum.blocks b
on t.block_hash = b.hash
where t.gas_price = 0
and t.block_time >= '2021-01-01'
SELECT
t.*,
b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data
FROM
ethereum.transactions AS t
JOIN
ethereum.blocks AS b
ON t.block_hash = b.`hash`
WHERE
t.gas_price = 0 AND t.block_time >= '2021-01-01';
69 changes: 38 additions & 31 deletions dune/gas/TotalDeposits_Coinbase.sql
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
SELECT address, time, sum(amount/ 1e18) over(order by time)
FROM (

-- outbound transfers
SELECT "from" AS address, -tr.value AS amount , date_trunc('day', block_time) as time
FROM ethereum.traces tr
WHERE "from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24'
AND success
AND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)
AND block_time > '2021-01-04'AND block_time < '2021-02-07'


UNION ALL

-- inbound transfers
SELECT "to" AS address, value AS amount ,date_trunc('day', block_time) as time
FROM ethereum.traces
WHERE "to" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24'
AND success
AND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)
AND block_time > '2021-01-04' AND block_time < '2021-02-07'

UNION ALL

-- gas costs
SELECT "from" AS address, -gas_used * gas_price AS amount, date_trunc('day', block_time) as time
FROM ethereum.transactions
WHERE "from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24'
AND block_time > '2021-01-04'AND block_time < '2021-02-07'

) as t
SELECT
address,
time,
sum(amount / 1e18) OVER (
ORDER BY time)
FROM
-- outbound transfers
(
SELECT
"from" AS address,
- tr.value AS amount,
date_trunc('day', block_time) AS time
FROM
ethereum.traces AS tr
WHERE
"from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND success AND (call_type NOT IN ('delegatecall',
'callcode', 'staticcall') OR call_type IS null) AND block_time > '2021-01-04' AND block_time < '2021-02-07'
UNION ALL -- inbound transfers
SELECT
"to" AS address,
value AS amount,
date_trunc('day', block_time) AS time
FROM
ethereum.traces
WHERE
"to" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND success AND (call_type NOT IN ('delegatecall',
'callcode', 'staticcall') OR call_type IS null) AND block_time > '2021-01-04' AND block_time < '2021-02-07'
UNION ALL -- gas costs
SELECT
"from" AS address,
- gas_used * gas_price AS amount,
date_trunc('day', block_time) AS time
FROM
ethereum.transactions
WHERE
"from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND block_time > '2021-01-04' AND block_time <
'2021-02-07'
) AS t;

0 comments on commit 92bbeb5

Please sign in to comment.