siwakon-ethbgt-reward
Updated 2024-10-07
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
›
⌄
-- forked from bgt-reward @ https://flipsidecrypto.xyz/studio/queries/e92ea497-1c9c-4e3d-b45f-cef1381d4910
WITH daily_totals AS (
SELECT
date_trunc('day', block_timestamp) as date,
sum(bgt_value) as total_bgt_value
FROM
(
SELECT
block_timestamp,
utils.udf_hex_to_int('s2c', regexp_substr_all(SUBSTR(output, 3, len(output)), '.{64}')[0] :: string) :: bigint / pow(10, 18) as bgt_value
FROM
berachain.testnet.fact_traces
WHERE
from_address = '{{contract_address}}'
AND left(input, 10) = '0xc00007b0'
AND tx_succeeded = true
AND block_timestamp > '2024-06-12'
) subquery
GROUP BY
date_trunc('day', block_timestamp)
)
SELECT
date,
total_bgt_value,
SUM(total_bgt_value) OVER (ORDER BY date) as cumulative_bgt_value
FROM
daily_totals
ORDER BY
date DESC;
QueryRunArchived: QueryRun has been archived