Skip to content

rocketpool minipools and node operators #8055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_balance_distribution',
materialized = 'table'
)
}}

select
trans.to as minipool,
true as is_distributed
from
{{ source('ethereum','transactions') }} as trans
right join {{ source('rocketpool_ethereum','RocketMinipoolDelegate_call_distributeBalance') }} as dist
on dist.call_tx_hash = trans.hash
where
dist.call_block_time > timestamp '2023-04-01'
and trans.block_time > timestamp '2023-04-01'
and dist._rewardsOnly = false -- Only full minipool distributions
and dist.call_success = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_beacon_deposit',
materialized = 'table'
)
}}

with
pub_key as (
select
pubkey,
minipool
from {{ ref('rocketpool_minipool_deposit_standard') }}

union

select
pubkey,
minipool
from {{ ref('rocketpool_minipool_deposit_credit') }}

union

select
pubkey,
minipool
from {{ ref('rocketpool_minipool_deposit_vacant') }}
)

select
pub_key.minipool,
pub_key.pubkey,
sum(
bytearray_to_uint256(bytearray_reverse(dep.amount)) / 1e9
) as beacon_amount_deposited
from
{{ source('eth2_ethereum','DepositContract_evt_DepositEvent') }} as dep
right join pub_key
on pub_key.pubkey = dep.pubkey
group by
1,
2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_beacon_withdrawal',
materialized = 'table'
)
}}

with
pub_key as (
select
minipool,
pubkey,
validator_index
from
{{ ref('rocketpool_minipool_pubkey_index')}}
),

withdrawals as (
select
wth.block_time as t,
pky.validator_index,
wth.amount / 1e9 as amount,
pky.minipool,
pky.pubkey
from {{ source('ethereum','withdrawals') }} as wth
right join pub_key as pky
on pky.validator_index = wth.validator_index
)

select
minipool,
validator_index,
pubkey,
max(t) as last_withdrawal_t,
sum(amount) as beacon_amount_withdrawn,
sum(if(amount < 8, amount, 0)) as beacon_amount_skim_withdrawn,
bool_or(amount > 8) as exited
from
withdrawals
group by
1,
2,
3
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_bond_reduction',
materialized = 'table'
)
}}

select
minipool,
evt_block_time,
newBondAmount / 1e18 as new_bond_amount,
0.14 as new_node_fee
from
{{ source('rocketpool_ethereum','RocketMinipoolBondReducer_evt_BeginBondReduction') }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_created_destroyed',
materialized = 'table'
)
}}

with created as (
select
minipool,
node as node_address,
contract_address,
evt_block_time as created_time
from
{{ source('rocketpool_ethereum','rocketminipoolmanager_evt_minipoolcreated') }}
)
,
destroyed as (
select
minipool,
node as node_address,
contract_address,
evt_block_time as destroyed_time
from
{{ source('rocketpool_ethereum','rocketminipoolmanager_evt_minipooldestroyed') }}
)

select
created.minipool,
created.node_address,
created.contract_address,
created.created_time,
destroyed.destroyed_time
from created
left join destroyed on created.minipool = destroyed.minipool
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_deposit_credit',
materialized = 'table'
)
}}

with
deposit_with_credit_calls as (
select
_expectedMinipoolAddress as minipool,
call_block_time,
call_tx_hash as tx_hash,
coalesce(_bondAmount, cast('16000000000000000000' as uint256)) as bond_amount,
_validatorPubkey as pubkey,
_minimumNodeFee / 1e18 as node_fee
from
{{ source('rocketpool_ethereum','RocketNodeDeposit_call_depositWithCredit') }}
where
call_success = true
)

select
dep.minipool,
dep.call_block_time,
dep.bond_amount / 1e18 as bond_amount,
dep.pubkey,
dep.node_fee
from
{{ source('ethereum','transactions') }} as trans
right join deposit_with_credit_calls as dep
on dep.tx_hash = trans.hash
where
trans.block_time > cast('2023-04-16' as timestamp)
and trans.value <= dep.bond_amount
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_deposit_standard',
materialized = 'table'
)
}}

select
_expectedMinipoolAddress as minipool,
call_block_time,
coalesce(_bondAmount / 1e18, 16) as bond_amount,
_validatorPubkey as pubkey,
_minimumNodeFee / 1e18 as node_fee
from
{{ source('rocketpool_ethereum','RocketNodeDeposit_call_deposit') }}
where
call_success = true
and _expectedMinipoolAddress is not null
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_deposit_vacant',
materialized = 'table'
)
}}

with deposits as (
select
_expectedminipooladdress as minipool,
call_block_time,
_bondamount / 1e18 as bond_amount,
_validatorpubkey as pubkey,
_minimumnodefee as node_fee
from
{{ source('rocketpool_ethereum','rocketnodedeposit_call_createvacantminipool') }}
where call_success = true
)
,
/* there were duplicate public keys used on 5 vacant minipools. this will ensure minipool is valid */
promoted as (
select to as minipool
from
{{ source('ethereum','transactions') }}
where
data = 0x13dc01dc /*promote*/
and to in (
select minipool
from
deposits
)
and success = true
and block_time > cast('2023-04-17' as timestamp)
)

select
deposits.minipool,
deposits.call_block_time,
deposits.bond_amount,
deposits.pubkey,
deposits.node_fee
from
deposits
inner join promoted on
deposits.minipool = promoted.minipool
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{ config(
schema = 'rocketpool_ethereum',
alias = 'minipool_master',
materialized = 'table',
post_hook='{{ expose_spells(\'["ethereum"]\',
"project",
"rocketpool",
\'["mtitus6"]\') }}'
)
}}

with minipool_deposits as (
select
pubkey,
minipool,
bond_amount,
node_fee,
'standard' as deposit_type
from {{ ref('rocketpool_minipool_deposit_standard') }}

union

select
pubkey,
minipool,
bond_amount,
node_fee,
'credit' as deposit_type
from {{ ref('rocketpool_minipool_deposit_credit') }}

union

select
pubkey,
minipool,
bond_amount,
node_fee,
'vacant' as deposit_type
from {{ ref('rocketpool_minipool_deposit_vacant') }}
)
select
minipool.minipool,
minipool.created_time,
minipool.destroyed_time,
minipool.node_address,
deposits.deposit_type,
deposits.bond_amount as orig_bond_amount,
deposits.node_fee as orig_node_fee,
queue.enqueued_time,
queue.dequeued_time,
queue.queue_days,
queue.queue_hrs,
beacon_dep.beacon_amount_deposited,
pubkey.pubkey,
pubkey.validator_index,
coalesce(reductions.new_bond_amount, deposits.bond_amount) as bond_amount,
coalesce(reductions.new_node_fee, deposits.node_fee) as node_fee,
reductions.new_bond_amount is not null as bond_reduced,
beacon_wth.exited,
beacon_wth.beacon_amount_withdrawn,
beacon_wth.beacon_amount_skim_withdrawn,
coalesce(dist.is_distributed, false) as is_distributed
from {{ ref('rocketpool_minipool_created_destroyed') }} as minipool
left join minipool_deposits as deposits
on minipool.minipool = deposits.minipool
left join {{ ref('rocketpool_minipool_bond_reduction') }} as reductions
on minipool.minipool = reductions.minipool
left join {{ ref('rocketpool_minipool_pubkey_index') }} as pubkey
on minipool.minipool = pubkey.minipool
left join {{ ref('rocketpool_minipool_beacon_deposit') }} as beacon_dep
on pubkey.pubkey = beacon_dep.pubkey
left join {{ ref('rocketpool_minipool_beacon_withdrawal') }} as beacon_wth
on deposits.minipool = beacon_wth.minipool
left join {{ ref('rocketpool_minipool_balance_distribution') }} as dist
on minipool.minipool = dist.minipool
left join {{ ref('rocketpool_minipool_queue') }} as queue
on minipool.minipool = queue.minipool
Loading