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 Aug 14, 2021
1 parent 6863c62 commit ede1ca3
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 65 deletions.
40 changes: 21 additions & 19 deletions dune/balancer/view_swaps.sql
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
CREATE OR REPLACE VIEW balancer.view_swaps AS
SELECT
block_time,
token_a_symbol,
token_b_symbol,
token_a_amount,
token_b_amount,
trader_a,
trader_b,
token_a_amount_raw,
token_b_amount_raw,
usd_amount,
token_a_address,
token_b_address,
exchange_contract_address AS contract_address,
tx_hash,
tx_from,
trace_address,
evt_index
FROM dex.trades
WHERE project = 'Balancer'
block_time,
token_a_symbol,
token_b_symbol,
token_a_amount,
token_b_amount,
trader_a,
trader_b,
token_a_amount_raw,
token_b_amount_raw,
usd_amount,
token_a_address,
token_b_address,
exchange_contract_address AS contract_address,
tx_hash,
tx_from,
trace_address,
evt_index
FROM
dex.trades
WHERE
project = 'Balancer';
87 changes: 47 additions & 40 deletions labels/ethereum/balancer_arbitrage.sql
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
SELECT
DISTINCT(t.to) AS address,
'arbitrage bot' AS label,
'dapp usage' AS type,
'balancerlabs' AS author
FROM dex.trades t1
INNER JOIN dex.trades t2
ON t1.tx_hash = t2.tx_hash
AND t1.token_a_address = t2.token_b_address
AND t1.token_b_address = t2.token_a_address
AND ((t1.project = 'Balancer' AND t2.project = 'Uniswap') or (t1.project = 'Uniswap' AND t2.project = 'Balancer'))
INNER JOIN ethereum.transactions t ON t.hash = t1.tx_hash
WHERE t1.block_time >= '{{timestamp}}'
AND t2.block_time >= '{{timestamp}}'
AND t.to NOT IN (
select address
from labels.labels
where author = 'balancerlabs'
and type = 'balancer_source'
)
SELECT DISTINCT
(t.`to`) AS address,
'arbitrage bot' AS label,
'dapp usage' AS type,
'balancerlabs' AS author
FROM
dex.trades AS t1
INNER JOIN
dex.trades AS t2
ON t1.tx_hash = t2.tx_hash AND t1.token_a_address = t2.token_b_address AND t1.token_b_address = t2.token_a_address AND
((t1.project = 'Balancer' AND t2.project = 'Uniswap') OR (t1.project = 'Uniswap' AND t2.project = 'Balancer'))
INNER JOIN
ethereum.transactions AS t
ON t.`hash` = t1.tx_hash
WHERE
t1.block_time >= '{{timestamp}}' AND t2.block_time >= '{{timestamp}}' AND t.`to` NOT IN (
SELECT
address
FROM
labels.labels
WHERE
author = 'balancerlabs' AND type = 'balancer_source'
)
UNION ALL
SELECT
DISTINCT(t.to) AS address,
'arbitrage bot' AS label,
'dapp usage' AS type,
'balancerlabs' AS author
FROM dex.trades t1
INNER JOIN dex.trades t2
ON t1.tx_hash = t2.tx_hash
AND t1.token_a_address = t2.token_b_address
AND t1.token_b_address = t2.token_a_address
AND ((t1.project = 'Balancer' AND t2.project = 'Sushiswap') or (t1.project = 'Sushiswap' AND t2.project = 'Balancer'))
INNER JOIN ethereum.transactions t ON t.hash = t1.tx_hash
WHERE t1.block_time >= '{{timestamp}}'
AND t2.block_time >= '{{timestamp}}'
AND t.to NOT IN (
select address
from labels.labels
where author = 'balancerlabs'
and type = 'balancer_source'
)
SELECT DISTINCT
(t.`to`) AS address,
'arbitrage bot' AS label,
'dapp usage' AS type,
'balancerlabs' AS author
FROM
dex.trades AS t1
INNER JOIN
dex.trades AS t2
ON t1.tx_hash = t2.tx_hash AND t1.token_a_address = t2.token_b_address AND t1.token_b_address = t2.token_a_address AND
((t1.project = 'Balancer' AND t2.project = 'Sushiswap') OR (t1.project = 'Sushiswap' AND t2.project =
'Balancer'))
INNER JOIN
ethereum.transactions AS t
ON t.`hash` = t1.tx_hash
WHERE
t1.block_time >= '{{timestamp}}' AND t2.block_time >= '{{timestamp}}' AND t.`to` NOT IN (
SELECT
address
FROM
labels.labels
WHERE
author = 'balancerlabs' AND type = 'balancer_source'
);
12 changes: 6 additions & 6 deletions labels/ethereum/foundation_users.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SELECT
address,
name AS label,
'foundation user' as type,
'foundation' as author
address,
name AS label,
'foundation user' AS type,
'foundation' AS author
FROM
foundation.user_names
foundation.user_names
WHERE
updated_at >= '{{timestamp}}'
updated_at >= '{{timestamp}}';

0 comments on commit ede1ca3

Please sign in to comment.