FatemeTheLadyStargate01
Updated 2023-02-19
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
--Stargate: 'optimism', 'USDC', '0xDecC0c09c3B5f6e92EF4184125D5648a66E35298'
--Stargate: 'optimism', 'DAI', '0x165137624F1f692e69659f944BF69DE02874ee27'
--USDC: 0x7F5c764cBc14f9669B88837ca1490cCa17c31607
--DAI: 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1
----------------------------------------------------------------------------------USDC
with
tx_labels as (
SELECT
tx_hash as tx1,
CASE
WHEN to_a = 1 and txns = 1 THEN 'Bridge from OP'
WHEN from_a = 1 and txns = 1 THEN 'Bridge to OP'
WHEN from_a = 1 and txns = 2 THEN 'Withdraw Liquidity'
WHEN to_a = 1 and txns = 2 THEN 'Deposit Liquidity'
end as event
FROM
(SELECT
tx_hash,
COUNT(CASE WHEN to_address LIKE lower('0xDecC0c09c3B5f6e92EF4184125D5648a66E35298') then 1 END) as to_a,
COUNT(CASE WHEN from_address LIKE lower('0xDecC0c09c3B5f6e92EF4184125D5648a66E35298') then 1 END) as from_a,
count(*) as txns
FROM optimism.core.fact_token_transfers
WHERE
tx_hash in (SELECT tx_hash
FROM optimism.core.fact_token_transfers
WHERE to_address LIKE lower('0xDecC0c09c3B5f6e92EF4184125D5648a66E35298')
OR from_address LIKE lower('0xDecC0c09c3B5f6e92EF4184125D5648a66E35298')
GROUP BY 1)
GROUP BY 1))
,tab1 as (
SELECT
date_trunc('{{date_range}}', block_timestamp) as date,
Run a query to Download Data