AN-5209/Upd staking model (#358)

* Upd staking model

* drop _s suffix

* rm event_data col

* upd desc
This commit is contained in:
Jack Forgash 2024-09-13 11:07:37 -06:00 committed by GitHub
parent ccf595e199
commit 9a7151bfc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 10 deletions

View File

@ -1,5 +1,5 @@
{% docs delegator %}
The Flow account address for the wallet delegating to a node.
The Flow account address for the wallet delegating to a node. This is derived from the first authorizer on the transaction and may be inaccurate if the transaction was signed by an EOA. Refer to delegator_id as the unique identifier for the delegator, taken directly from the emitted event data.
{% enddocs %}
{% enddocs %}

View File

@ -11,6 +11,7 @@ SELECT
block_height,
tx_succeeded,
delegator,
delegator_id,
action,
amount,
node_id,
@ -21,4 +22,4 @@ SELECT
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__staking_actions_s') }}
{{ ref('silver__staking_actions') }}

View File

@ -48,12 +48,16 @@ models:
- name: delegator
description: "{{ doc('delegator') }}"
tests:
- not_null
- not_null:
where: delegator_id is not null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- VARCHAR
- STRING
- name: delegator_id
description: "{{ doc('delegator') }}"
- name: action
description: "{{ doc('action') }}"
tests:

View File

@ -52,7 +52,11 @@ flow_staking AS (
tx_succeeded,
event_contract,
event_type AS action,
event_data :amount :: FLOAT AS amount,
COALESCE(
event_data :amount :: FLOAT,
-- amount for event NewNodeCreated rep initial stake
event_data :amountCommitted :: FLOAT
) AS amount,
event_data :delegatorID :: STRING AS delegator_id,
event_data :nodeID :: STRING AS node_id,
_inserted_timestamp,
@ -63,11 +67,33 @@ flow_staking AS (
event_contract = 'A.8624b52f9ddcd04a.FlowIDTableStaking'
AND event_type IN (
'DelegatorTokensCommitted',
'DelegatorRewardTokensWithdrawn',
'DelegatorUnstakedTokensWithdrawn',
'TokensCommitted',
'DelegatorTokensStaked',
'TokensStaked',
'DelegatorTokensRequestedToUnstake',
'DelegatorTokensUnstaking',
'TokensUnstaking',
'DelegatorTokensUnstaked',
'TokensUnstaked',
'DelegatorUnstakedTokensWithdrawn',
'UnstakedTokensWithdrawn',
'DelegatorRewardTokensWithdrawn',
'RewardTokensWithdrawn',
'UnstakedTokensWithdrawn'
-- important additions to include
-- initial stake, any self-unstake, refund
'NewNodeCreated',
'NodeTokensRequestedToUnstake',
'NodeRemovedAndRefunded',
'RewardsPaid',
'DelegatorRewardsPaid'
)
),
add_auth AS (
@ -114,7 +140,8 @@ FINAL AS (
block_timestamp,
block_height,
tx_succeeded,
primary_authorizer AS delegator,
IFF(delegator_id IS NOT NULL, primary_authorizer, null) AS delegator,
delegator_id,
action,
amount,
node_id,

View File

@ -1,7 +1,7 @@
version: 2
models:
- name: silver__staking_actions_s
- name: silver__staking_actions
description: |-
This table provides transaction-level info on FLOW staking activities.