-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
96e3248
Initial sql files, schema, and sources
mtitus6 675ca33
Merge branch 'duneanalytics:main' into main
mtitus6 7053bd3
Update rocketpool_minipool_master.sql
mtitus6 c6c086a
Merge branch 'main' of https://github.com/mtitus6/spellbook
mtitus6 795b301
Update rocketpool_minipool_master.sql
mtitus6 649fd0e
cleanup headers, optimize joins
mtitus6 8103d41
Merge branch 'duneanalytics:main' into main
mtitus6 09077a4
fix run errors
mtitus6 8d27b99
Merge branch 'main' of https://github.com/mtitus6/spellbook
mtitus6 21dd43b
add fields to trans joins
mtitus6 b8fff14
Merge branch 'main' into main
mtitus6 e81bd21
Update rocketpool_minipool_balance_distribution.sql
mtitus6 ea532bb
Update rocketpool_minipool_deposit_credit.sql
mtitus6 111a8d6
Update dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_m…
mtitus6 7cebe1f
Update rocketpool_minipool_deposit_credit.sql
mtitus6 ba49b6a
Update rocketpool_node_operators.sql
mtitus6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...ubprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_balance_distribution.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{ config( | ||
schema = 'rocketpool_ethereum', | ||
alias = 'minipool_balance_distribution', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = 'minipool' | ||
) | ||
}} | ||
|
||
select distinct | ||
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 | ||
and dist.call_block_number = trans.block_number | ||
mtitus6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
and dist._rewardsOnly = false -- Only full minipool distributions | ||
and dist.call_success = true | ||
{% if is_incremental() -%} | ||
and {{ incremental_predicate('dist.call_block_time') }} | ||
{% else -%} | ||
and dist.call_block_time > timestamp '2023-04-01' | ||
{% endif -%} | ||
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 | ||
jeff-dude marked this conversation as resolved.
Show resolved
Hide resolved
|
42 changes: 42 additions & 0 deletions
42
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_beacon_deposit.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
43 changes: 43 additions & 0 deletions
43
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_beacon_withdrawal.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
14 changes: 14 additions & 0 deletions
14
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_bond_reduction.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') }} |
35 changes: 35 additions & 0 deletions
35
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_created_destroyed.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
44 changes: 44 additions & 0 deletions
44
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_deposit_credit.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{ config( | ||
schema = 'rocketpool_ethereum', | ||
alias = 'minipool_deposit_credit', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['minipool','call_block_time'] | ||
) | ||
}} | ||
|
||
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 | ||
and dep.call_block_time = trans.block_time | ||
{% if is_incremental() -%} | ||
and {{ incremental_predicate('dep.call_block_time') }} | ||
{% else -%} | ||
and dep.call_block_time > timestamp '2023-04-16' | ||
{% endif -%} | ||
where | ||
trans.block_time > cast('2023-04-16' as timestamp) | ||
and trans.value <= dep.bond_amount |
18 changes: 18 additions & 0 deletions
18
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_deposit_standard.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
45 changes: 45 additions & 0 deletions
45
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_deposit_vacant.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
77 changes: 77 additions & 0 deletions
77
dbt_subprojects/daily_spellbook/models/rocketpool/rocketpool_minipool_master.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.