mirror of
https://github.com/FlipsideCrypto/osmosis-models.git
synced 2026-02-06 11:26:55 +00:00
add is_unpool and convert actions
This commit is contained in:
parent
2be94d351a
commit
aadef7affb
@ -23,3 +23,25 @@ SELECT
|
||||
A.unpool_new_lock_ids
|
||||
FROM
|
||||
{{ ref('silver__locked_liquidity_actions') }} A
|
||||
UNION ALL
|
||||
SELECT
|
||||
A.block_id,
|
||||
A.block_timestamp,
|
||||
A.tx_id,
|
||||
A.tx_succeeded,
|
||||
A.msg_group,
|
||||
A.msg_type,
|
||||
A.msg_action,
|
||||
A.msg_action_description,
|
||||
A.locker_address,
|
||||
A.lock_id,
|
||||
NULL AS amount,
|
||||
NULL AS currency,
|
||||
NULL AS DECIMAL,
|
||||
NULL AS pool_id,
|
||||
NULL AS lock_duration,
|
||||
NULL AS unlock_time,
|
||||
A.is_superfluid,
|
||||
NULL AS unpool_new_lock_ids
|
||||
FROM
|
||||
{{ ref('silver__locked_liquidity_actions_convert') }} A
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'STAKING'
|
||||
}
|
||||
}
|
||||
}
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }} }
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
@ -20,6 +14,28 @@ SELECT
|
||||
currency,
|
||||
DECIMAL,
|
||||
validator_address,
|
||||
lock_id
|
||||
lock_id,
|
||||
IFF(
|
||||
action = 'undelegate'
|
||||
AND currency IS NOT NULL,
|
||||
TRUE,
|
||||
FALSE
|
||||
) AS is_unpool
|
||||
FROM
|
||||
{{ ref('silver__superfluid_staking') }}
|
||||
UNION ALL
|
||||
SELECT
|
||||
A.block_id,
|
||||
A.block_timestamp,
|
||||
A.tx_id,
|
||||
A.tx_succeeded,
|
||||
A.msg_action AS action,
|
||||
A.locker_address AS delegator_address,
|
||||
NULL AS amount,
|
||||
NULL AS currency,
|
||||
NULL AS DECIMAL,
|
||||
A.validator_address,
|
||||
A.lock_id,
|
||||
FALSE AS is_unpool
|
||||
FROM
|
||||
{{ ref('silver__locked_liquidity_actions_convert') }} A
|
||||
|
||||
@ -45,5 +45,9 @@ models:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: LOCK_ID
|
||||
description: An ID corresponding to the locking step of the transaction.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: IS_UNPOOL
|
||||
description: Boolean value indicating whether the transaction is an unpool action.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
@ -49,10 +49,16 @@ base_msg_atts AS (
|
||||
ON A.tx_id = b.tx_id
|
||||
AND A.msg_group = b.msg_group {# AND b.tx_grp_rn > 1 #}
|
||||
WHERE
|
||||
A.msg_type IN (
|
||||
'superfluid_delegate',
|
||||
'lock_tokens',
|
||||
'add_tokens_to_lock'
|
||||
(
|
||||
A.msg_type IN (
|
||||
'superfluid_delegate',
|
||||
'lock_tokens',
|
||||
'add_tokens_to_lock'
|
||||
)
|
||||
OR (
|
||||
A.msg_type = 'tx'
|
||||
AND A.attribute_key = 'acc_seq'
|
||||
)
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
@ -112,6 +118,23 @@ tx_msg_flat AS (
|
||||
A.msg_type,
|
||||
A._inserted_timestamp
|
||||
),
|
||||
lper AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
SPLIT_PART(
|
||||
attribute_value,
|
||||
'/',
|
||||
0
|
||||
) AS locker_address
|
||||
FROM
|
||||
base_msg_atts
|
||||
WHERE
|
||||
msg_type = 'tx' qualify ROW_NUMBER() over (
|
||||
PARTITION BY tx_id
|
||||
ORDER BY
|
||||
msg_index DESC
|
||||
) = 1
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
A.block_id,
|
||||
@ -122,33 +145,26 @@ FINAL AS (
|
||||
A.msg_type,
|
||||
j :lock_id :: INT AS lock_id,
|
||||
j :validator :: STRING AS validator,
|
||||
{# COALESCE(
|
||||
j :"add_tokens_to_lock--owner",
|
||||
j :"lock_tokens--owner",
|
||||
j :"begin_unlock--owner",
|
||||
j :"unlock--owner",
|
||||
j :"burn--burner",
|
||||
j :"unpool_pool_id--sender"
|
||||
) :: STRING AS locker,
|
||||
#}
|
||||
j,
|
||||
A._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
tx_msg_flat A
|
||||
A._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
tx_msg_flat A
|
||||
)
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
A.tx_id,
|
||||
tx_succeeded,
|
||||
msg_group,
|
||||
msg_type,
|
||||
'convert' AS msg_action,
|
||||
'convert' AS msg_action_description,
|
||||
b.locker_address,
|
||||
lock_id,
|
||||
validator,
|
||||
j,
|
||||
validator AS validator_address,
|
||||
TRUE AS is_superfluid,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
A.tx_id,
|
||||
msg_group,
|
||||
COALESCE(
|
||||
lock_id,
|
||||
@ -157,4 +173,6 @@ SELECT
|
||||
) AS _unique_key,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
FINAL
|
||||
FINAL A
|
||||
JOIN lper b
|
||||
ON A.tx_id = b.tx_id
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__locked_liquidity_actions_convert
|
||||
description: Records of all LP token locking transactions that have occurred on Osmosis, dating back to the genesis block. These actions include lock, unlock, unpool, and all superfluid actions.
|
||||
description: Records of all conversion of lp tokens to locked lp tokens transactions that have occurred on Osmosis, dating back to the genesis block
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_ID
|
||||
- MSG_GROUP
|
||||
- LOCK_ID
|
||||
- LOCKER
|
||||
- LOCKER_ADDRESS
|
||||
columns:
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
@ -58,7 +58,7 @@ models:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: LOCKER
|
||||
- name: LOCKER_ADDRESS
|
||||
description: "{{ doc('locker_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
@ -75,41 +75,19 @@ models:
|
||||
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') }}"
|
||||
- name: VALIDATOR_ADDRESS
|
||||
description: "{{ doc('validator_address') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: POOL_ID
|
||||
description: "{{ doc('pool_id') }}"
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: osmovaloper1[0-9a-z]{38,38}
|
||||
- name: IS_SUPERFLUID
|
||||
description: "{{ doc('is_superfluid') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: LOCK_DURATION
|
||||
description: "{{ doc('lock_duration') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: UNLOCK_TIME
|
||||
description: "{{ doc('unlock_time') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('inserted_timestamp') }}"
|
||||
tests:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user