-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BigQuery AutoFormatter
committed
Aug 14, 2021
1 parent
6863c62
commit ede1ca3
Showing
3 changed files
with
74 additions
and
65 deletions.
There are no files selected for viewing
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
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'; |
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
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' | ||
); |
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
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}}'; |