The Honey Jarvalidator revenue per block
Updated 2024-10-25
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
›
⌄
with
--get which validator is building the block from Distributed event
--get commission from BlockRewardProcessed, adding up baserate and commissionrate
--baserate = min reward given to validator by default
--commissionrate = reward going to validator based on set commission
--rewards = bgt amont going to reward vault
BGT_rewards as (
select r.tx_hash, b.block, baserate+commissionrate as validator_commission from (
select utils.udf_hex_to_int(substr(data,3,64))::int as block,
(utils.udf_hex_to_int(substr(data,67,64))::int)/1e18 as baserate,
(utils.udf_hex_to_int(substr(data,131,64))::int)/1e18 as commissionrate,
(utils.udf_hex_to_int(substr(data,196,64))::int)/1e18 as rewards,
tx_hash
from berachain.testnet.fact_event_logs
where topics[0]='0x270082d9115582606dc49fca400299402771f21cf81dde3c4c03cab4fe211277'
) r
join
(select tx_hash, block, sum(rewards) as rewards from (
select tx_hash, utils.udf_hex_to_int(topics[2])::varchar as block, (utils.udf_hex_to_int(substr(data,3,64))::int)/1e18 as rewards
from berachain.testnet.fact_event_logs
where topics[0]='0x96b077538301034fee0c56fc41bbee8e61ddedc1029eeeaff049fd4db8fac18a'
and concat('0x',substr(TOPICS[1], 27,64))=lower('0x40495a781095932e2fc8dcca69f5e358711fdd41')
)
group by 1,2
) b on b.tx_hash=r.tx_hash and (b.block-r.block)=0
where b.block between '{{start_block}}' and '{{end_block}}'
),
--get block number and which validator got it, directing to which vault
--get amount of tokens sent by that vault to the right validator
incentives as (select tx_hash, block, incentive_token, name, sum(amount) as amount from (
select b.tx_hash, block, vault, rewards, incentive_token, name, amount from (
select tx_hash, utils.udf_hex_to_int(topics[2])::varchar as block, (utils.udf_hex_to_int(substr(data,3,64))::int)/1e18 as rewards,
concat('0x',substr(TOPICS[3], 27,64)) as vault
from berachain.testnet.fact_event_logs
where topics[0]='0x96b077538301034fee0c56fc41bbee8e61ddedc1029eeeaff049fd4db8fac18a'
and concat('0x',substr(TOPICS[1], 27,64))=lower('0x40495a781095932e2fc8dcca69f5e358711fdd41')
QueryRunArchived: QueryRun has been archived