mirror of
https://github.com/FlipsideCrypto/axelar-models.git
synced 2026-02-06 14:26:54 +00:00
validator commission
This commit is contained in:
parent
ab260a9845
commit
889589c3d6
5
models/descriptions/validator_address_reward.md
Normal file
5
models/descriptions/validator_address_reward.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs validator_address_reward %}
|
||||
|
||||
The wallet address that recieves the commissiion of the validator.
|
||||
|
||||
{% enddocs %}
|
||||
18
models/gold/core__fact_validator_commission.sql
Normal file
18
models/gold/core__fact_validator_commission.sql
Normal file
@ -0,0 +1,18 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }}}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
tx_succeeded,
|
||||
tx_caller_address,
|
||||
msg_group,
|
||||
amount,
|
||||
currency,
|
||||
validator_address_operator,
|
||||
validator_address_reward
|
||||
FROM
|
||||
{{ ref('silver__validator_commission') }}
|
||||
45
models/gold/core__fact_validator_commission.yml
Normal file
45
models/gold/core__fact_validator_commission.yml
Normal file
@ -0,0 +1,45 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_validator_commission
|
||||
description: Information about all validator commission that have been claimed on Axelar.
|
||||
columns:
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_CALLER_ADDRESS
|
||||
description: "{{ doc('tx_caller_address') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: AMOUNT
|
||||
description: The amount of tokens in the staking action
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: CURRENCY
|
||||
description: "{{ doc('currency') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: VALIDATOR_ADDRESS_OPERATOR
|
||||
description: "{{ doc('validator_address') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: VALIDATOR_ADDRESS_REWARD
|
||||
description: "{{ doc('validator_address_reward') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
124
models/silver/silver__validator_commission.sql
Normal file
124
models/silver/silver__validator_commission.sql
Normal file
@ -0,0 +1,124 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "tx_id",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE']
|
||||
) }}
|
||||
|
||||
WITH txs AS (
|
||||
|
||||
SELECT
|
||||
DISTINCT A.tx_id,
|
||||
A.msg_group
|
||||
FROM
|
||||
{{ ref('silver__msg_attributes') }} A
|
||||
WHERE
|
||||
msg_type = 'withdraw_commission'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
msg_attributes_base AS (
|
||||
SELECT
|
||||
A.tx_id,
|
||||
A.block_id,
|
||||
A.block_timestamp,
|
||||
A.tx_succeeded,
|
||||
A.msg_type,
|
||||
A.msg_group,
|
||||
A.msg_index,
|
||||
A.attribute_key,
|
||||
A.attribute_value,
|
||||
A._inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__msg_attributes') }} A
|
||||
JOIN txs b
|
||||
ON A.tx_id = b.tx_id
|
||||
WHERE
|
||||
(
|
||||
A.msg_group = b.msg_group
|
||||
OR (
|
||||
A.msg_group IS NULL
|
||||
AND msg_type || attribute_key = 'txacc_seq'
|
||||
)
|
||||
)
|
||||
AND msg_type || attribute_key IN (
|
||||
'withdraw_commissionamount',
|
||||
'transferrecipient',
|
||||
'messagesender',
|
||||
'txacc_seq'
|
||||
)
|
||||
AND NOT (
|
||||
msg_type || attribute_key = 'messagesender'
|
||||
AND len(attribute_value) = 45
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
combo AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
MAX(msg_group) AS msg_group,
|
||||
OBJECT_AGG(
|
||||
attribute_key :: STRING,
|
||||
attribute_value :: variant
|
||||
) AS j,
|
||||
SPLIT_PART(
|
||||
j :acc_seq :: STRING,
|
||||
'/',
|
||||
0
|
||||
) AS tx_caller_address,
|
||||
j :recipient :: STRING AS validator_address_reward,
|
||||
j :sender :: STRING AS validator_address_operator,
|
||||
j :amount :: STRING AS amount
|
||||
FROM
|
||||
msg_attributes_base
|
||||
GROUP BY
|
||||
tx_id
|
||||
),
|
||||
block_tx_inserted AS (
|
||||
SELECT
|
||||
DISTINCT A.tx_id,
|
||||
A.block_id,
|
||||
A.block_timestamp,
|
||||
A.tx_succeeded,
|
||||
A._inserted_timestamp
|
||||
FROM
|
||||
msg_attributes_base A
|
||||
)
|
||||
SELECT
|
||||
b.block_id,
|
||||
b.block_timestamp,
|
||||
A.tx_id,
|
||||
b.tx_succeeded,
|
||||
A.tx_caller_address,
|
||||
A.msg_group,
|
||||
REPLACE(
|
||||
A.amount,
|
||||
'uaxl'
|
||||
) :: INT AS amount,
|
||||
'uaxl' AS currency,
|
||||
A.validator_address_operator,
|
||||
A.validator_address_reward,
|
||||
b._inserted_timestamp
|
||||
FROM
|
||||
combo A
|
||||
JOIN block_tx_inserted b
|
||||
ON A.tx_id = b.tx_id
|
||||
98
models/silver/silver__validator_commission.yml
Normal file
98
models/silver/silver__validator_commission.yml
Normal file
@ -0,0 +1,98 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__validator_commission
|
||||
description: Records of all validator commission claims
|
||||
columns:
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: TX_SUCCEEDED
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
- name: TX_CALLER_ADDRESS
|
||||
description: "{{ doc('tx_caller_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: axelar[0-9a-z]{39,39}
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('amount') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CURRENCY
|
||||
description: "{{ doc('currency') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: VALIDATOR_ADDRESS_OPERATOR
|
||||
description: "{{ doc('validator_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: axelarvaloper[0-9a-z]{39,39}
|
||||
- name: VALIDATOR_ADDRESS_REWARD
|
||||
description: "{{ doc('validator_address_reward') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: axelar[0-9a-z]{39,39}
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
Loading…
Reference in New Issue
Block a user