connorhPolygon Bridge
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
›
⌄
-- Bridged Amounts to Polygon
with tmp AS (
select DATE(block_timestamp) AS balance_date,event_name, LOWER(COALESCE(event_inputs:depositReceiver,event_inputs:exitor)) AS user_address,
CASE WHEN event_name <> 'LockedEther' THEN event_inputs:amount/POWER(10,18)*-1 ELSE event_inputs:amount/POWER(10,18) END AS amount_eth
from ethereum.events_emitted
where event_name IN ('LockedEther','ExitedEther') AND contract_address = '0x8484ef722627bf18ca5ae6bcf031c23e6e922b30' AND user_address IS NOT NULL
), deltas AS (
SELECT balance_date, user_address,SUM(amount_eth) AS amount
FROM tmp
GROUP BY 1,2
ORDER BY balance_date
), balances AS (
SELECT balance_date, user_address,
SUM(amount) over (partition by user_address order by balance_date asc rows between unbounded preceding and current row) AS net_bridged
FROM deltas
ORDER BY balance_date DESC
)
SELECT *
FROM balances
WHERE balance > 0
Run a query to Download Data