osmosis-models/models/silver/silver__locked_liquidity_transactions.sql
eric-laurello e3482847d3
AN-2245 superfluid staked balances (#64)
* check in

* WIP check in

* WIP check in

* locked LP actions and balances

* add business logic test, fix test failure & typos

* ds store

* ds store

* more logic tests
2022-10-21 13:18:58 -04:00

44 lines
781 B
SQL

{{ config(
materialized = 'incremental',
unique_key = "_unique_key",
incremental_strategy = 'merge',
cluster_by = ['_inserted_timestamp::DATE']
) }}
SELECT
DISTINCT tx_id,
msg_group,
msg_sub_group,
attribute_value AS lock_id,
_inserted_timestamp,
concat_ws(
'-',
A.tx_id,
COALESCE(
A.msg_group,
-1
),
COALESCE(
A.msg_sub_group,
-1
)
) AS _unique_key
FROM
{{ ref('silver__msg_attributes') }} A
WHERE
attribute_key IN (
'period_lock_id',
'lock_id'
)
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}