mirror of
https://github.com/FlipsideCrypto/ton-models.git
synced 2026-02-06 13:46:46 +00:00
checks
This commit is contained in:
parent
1e75bfea39
commit
77dae1f7cd
35
models/gold/core/core__fact_account_states.sql
Normal file
35
models/gold/core/core__fact_account_states.sql
Normal file
@ -0,0 +1,35 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['fact_account_states_id'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(account);",
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
account,
|
||||
TO_TIMESTAMP(TIMESTAMP) AS block_timestamp,
|
||||
TIMESTAMP,
|
||||
last_trans_lt,
|
||||
last_trans_hash AS last_tx_hash,
|
||||
account_status,
|
||||
balance,
|
||||
frozen_hash,
|
||||
HASH AS account_state_hash,
|
||||
account_states_id AS fact_account_states_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__account_states') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
32
models/gold/core/core__fact_balances.sql
Normal file
32
models/gold/core/core__fact_balances.sql
Normal file
@ -0,0 +1,32 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['fact_balances_history_id'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(address);",
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
address,
|
||||
TO_TIMESTAMP(TIMESTAMP) AS block_timestamp,
|
||||
asset,
|
||||
amount,
|
||||
mintless_claimed,
|
||||
lt,
|
||||
balances_history_id AS fact_balances_history_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__balances_history') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
@ -39,9 +39,7 @@ SELECT
|
||||
gen_catchain_seqno,
|
||||
min_ref_mc_seqno,
|
||||
before_split,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['shard','seqno','workchain']
|
||||
) }} AS fact_blocks_id,
|
||||
blocks_id AS fact_blocks_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
|
||||
42
models/gold/core/core__fact_jetton_events.sql
Normal file
42
models/gold/core/core__fact_jetton_events.sql
Normal file
@ -0,0 +1,42 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['jetton_events_id'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
cluster_by = ['block_timestamp::DATE','source','destination'],
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
TO_TIMESTAMP(utime) AS block_timestamp,
|
||||
tx_hash,
|
||||
CASE
|
||||
WHEN tx_aborted THEN FALSE
|
||||
ELSE TRUE
|
||||
END tx_succeeded,
|
||||
TYPE,
|
||||
source,
|
||||
destination,
|
||||
forward_ton_amount,
|
||||
amount,
|
||||
jetton,
|
||||
COMMENT,
|
||||
query_id,
|
||||
tx_lt,
|
||||
utime,
|
||||
tx_aborted,
|
||||
jetton_events_id AS fact_jetton_events_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__jetton_events') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
44
models/gold/core/defi/defi__fact_dex_pools.sql
Normal file
44
models/gold/core/defi/defi__fact_dex_pools.sql
Normal file
@ -0,0 +1,44 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['fact_dex_pools_id'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
cluster_by = ['block_timestamp_last_updated::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(pool);",
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
TO_TIMESTAMP(last_updated) AS block_timestamp_last_updated,
|
||||
TO_TIMESTAMP(discovered_at) AS block_timestamp_discovered_at,
|
||||
project,
|
||||
pool,
|
||||
version,
|
||||
is_liquid,
|
||||
reserves_right,
|
||||
reserves_left,
|
||||
jetton_right,
|
||||
jetton_left,
|
||||
total_supply,
|
||||
protocol_fee,
|
||||
referral_fee,
|
||||
lp_fee,
|
||||
tvl_ton,
|
||||
tvl_usd,
|
||||
last_updated,
|
||||
discovered_at,
|
||||
dex_pools_id AS fact_dex_pools_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__dex_pools') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
46
models/gold/core/defi/defi__fact_dex_trades.sql
Normal file
46
models/gold/core/defi/defi__fact_dex_trades.sql
Normal file
@ -0,0 +1,46 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['fact_dex_trades_id'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
cluster_by = ['block_timestamp_event::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash,pool_address,trader_address,token_bought_address,token_sold_address);",
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
TO_TIMESTAMP(event_time) AS block_timestamp_event,
|
||||
event_type,
|
||||
tx_hash,
|
||||
project_type,
|
||||
project,
|
||||
pool_address,
|
||||
version,
|
||||
trader_address,
|
||||
token_bought_address,
|
||||
token_sold_address,
|
||||
amount_bought_raw,
|
||||
amount_sold_raw,
|
||||
router_address,
|
||||
volume_ton,
|
||||
volume_usd,
|
||||
referral_address,
|
||||
platform_tag,
|
||||
trace_id,
|
||||
query_id,
|
||||
event_time,
|
||||
dex_trades_id AS fact_dex_trades_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__dex_trades') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
@ -36,6 +36,7 @@ SELECT
|
||||
address,
|
||||
amount,
|
||||
TIMESTAMP,
|
||||
mintless_claimed,
|
||||
_inserted_timestamp,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['address','asset','TIMESTAMP']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user