diff --git a/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_account_activity_arbitrum_mainnet.sql b/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_account_activity_arbitrum_mainnet.sql index ca00283a..7e7b383b 100644 --- a/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_account_activity_arbitrum_mainnet.sql +++ b/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_account_activity_arbitrum_mainnet.sql @@ -8,7 +8,7 @@ with delegated as ( block_timestamp, account_id, 'Delegated' as account_action - from {{ ref('core_delegation_updated_arbitrum_mainnet') }} as core + from {{ ref('core_delegation_updated_arbitrum_mainnet') }} ), withdrawn as ( @@ -16,7 +16,7 @@ withdrawn as ( block_timestamp, account_id, 'Withdrawn' as account_action - from {{ ref('core_withdrawn_arbitrum_mainnet') }} as core + from {{ ref('core_withdrawn_arbitrum_mainnet') }} ), claimed as ( @@ -24,7 +24,7 @@ claimed as ( block_timestamp, account_id, 'Claimed' as account_action - from {{ ref('core_rewards_claimed_arbitrum_mainnet') }} as core + from {{ ref('core_rewards_claimed_arbitrum_mainnet') }} ), combined as ( @@ -39,4 +39,4 @@ select block_timestamp, account_action, account_id -from combined \ No newline at end of file +from combined diff --git a/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_active_stakers_daily_arbitrum_mainnet.sql b/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_active_stakers_daily_arbitrum_mainnet.sql index 12397697..109c22ab 100644 --- a/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_active_stakers_daily_arbitrum_mainnet.sql +++ b/transformers/synthetix/models/marts/arbitrum/mainnet/core/fct_core_active_stakers_daily_arbitrum_mainnet.sql @@ -8,42 +8,45 @@ with delegation_updated as ( block_timestamp, account_id, amount - from {{ ref('core_delegation_updated_arbitrum_mainnet') }} as core + from {{ ref('core_delegation_updated_arbitrum_mainnet') }} ), dim as ( - select - d.date, - accounts.account_id + select + d.block_date, + accounts_unique.account_id from ( - select + select generate_series( date_trunc('day', date('2023-12-15')), date_trunc('day', current_date), '1 day'::interval - ) as date + ) as block_date ) as d cross join ( select distinct account_id from delegation_updated - ) as accounts + ) as accounts_unique ), stakers as ( - select - date, + select + dim.block_date, dim.account_id, - case when coalesce(last(amount) over ( - partition by dim.account_id - order by date - rows between unbounded preceding and current row - ), 0) = 0 then 0 else 1 end as is_staking + case + when coalesce(last(delegation_updated.amount) over ( + partition by dim.account_id + order by dim.block_date + rows between unbounded preceding and current row + ), 0) = 0 then 0 + else 1 + end as is_staking from dim - left join delegation_updated - on dim.date = date(delegation_updated.block_timestamp) + left join delegation_updated on + dim.block_date = date(delegation_updated.block_timestamp) and dim.account_id = delegation_updated.account_id ) select - date, + block_date, sum(is_staking) as nof_stakers_daily from stakers -group by date \ No newline at end of file +group by block_date diff --git a/transformers/synthetix/models/marts/arbitrum/mainnet/core/schema.yml b/transformers/synthetix/models/marts/arbitrum/mainnet/core/schema.yml index bffb4543..0d1c3a8a 100644 --- a/transformers/synthetix/models/marts/arbitrum/mainnet/core/schema.yml +++ b/transformers/synthetix/models/marts/arbitrum/mainnet/core/schema.yml @@ -23,7 +23,7 @@ models: - name: fct_core_active_stakers_daily_arbitrum_mainnet description: "Daily number of active stakers" columns: - - name: date + - name: block_date description: "Date" data_type: date tests: diff --git a/transformers/synthetix/models/marts/arbitrum/mainnet/perp/fct_perp_accounts_settled_orders_arbitrum_mainnet.sql b/transformers/synthetix/models/marts/arbitrum/mainnet/perp/fct_perp_accounts_settled_orders_arbitrum_mainnet.sql index 8a0d7c3a..bde6d783 100644 --- a/transformers/synthetix/models/marts/arbitrum/mainnet/perp/fct_perp_accounts_settled_orders_arbitrum_mainnet.sql +++ b/transformers/synthetix/models/marts/arbitrum/mainnet/perp/fct_perp_accounts_settled_orders_arbitrum_mainnet.sql @@ -3,7 +3,7 @@ tags = ["perp", "account_activity", "arbitrum", "mainnet"] ) }} -select +select block_timestamp, account_id -from {{ ref('perp_order_settled_arbitrum_mainnet') }} \ No newline at end of file +from {{ ref('perp_order_settled_arbitrum_mainnet') }} diff --git a/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_account_activity_arbitrum_sepolia.sql b/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_account_activity_arbitrum_sepolia.sql index 5e64ba43..22b47978 100644 --- a/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_account_activity_arbitrum_sepolia.sql +++ b/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_account_activity_arbitrum_sepolia.sql @@ -8,7 +8,7 @@ with delegated as ( block_timestamp, account_id, 'Delegated' as account_action - from {{ ref('core_delegation_updated_arbitrum_sepolia') }} as core + from {{ ref('core_delegation_updated_arbitrum_sepolia') }} ), withdrawn as ( @@ -16,7 +16,7 @@ withdrawn as ( block_timestamp, account_id, 'Withdrawn' as account_action - from {{ ref('core_withdrawn_arbitrum_sepolia') }} as core + from {{ ref('core_withdrawn_arbitrum_sepolia') }} ), claimed as ( @@ -24,7 +24,7 @@ claimed as ( block_timestamp, account_id, 'Claimed' as account_action - from {{ ref('core_rewards_claimed_arbitrum_sepolia') }} as core + from {{ ref('core_rewards_claimed_arbitrum_sepolia') }} ), combined as ( @@ -39,4 +39,4 @@ select block_timestamp, account_action, account_id -from combined \ No newline at end of file +from combined diff --git a/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_active_stakers_daily_arbitrum_sepolia.sql b/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_active_stakers_daily_arbitrum_sepolia.sql index b65bc37a..fab88560 100644 --- a/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_active_stakers_daily_arbitrum_sepolia.sql +++ b/transformers/synthetix/models/marts/arbitrum/sepolia/core/fct_core_active_stakers_daily_arbitrum_sepolia.sql @@ -8,42 +8,45 @@ with delegation_updated as ( block_timestamp, account_id, amount - from {{ ref('core_delegation_updated_arbitrum_sepolia') }} as core + from {{ ref('core_delegation_updated_arbitrum_sepolia') }} ), dim as ( - select - d.date, - accounts.account_id + select + d.block_date, + accounts_unique.account_id from ( - select + select generate_series( date_trunc('day', date('2023-12-15')), date_trunc('day', current_date), '1 day'::interval - ) as date + ) as block_date ) as d cross join ( select distinct account_id from delegation_updated - ) as accounts + ) as accounts_unique ), stakers as ( - select - date, + select + dim.block_date, dim.account_id, - case when coalesce(last(amount) over ( - partition by dim.account_id - order by date - rows between unbounded preceding and current row - ), 0) = 0 then 0 else 1 end as is_staking + case + when coalesce(last(delegation_updated.amount) over ( + partition by dim.account_id + order by dim.block_date + rows between unbounded preceding and current row + ), 0) = 0 then 0 + else 1 + end as is_staking from dim - left join delegation_updated - on dim.date = date(delegation_updated.block_timestamp) + left join delegation_updated on + dim.block_date = date(delegation_updated.block_timestamp) and dim.account_id = delegation_updated.account_id ) select - date, + block_date, sum(is_staking) as nof_stakers_daily from stakers -group by date \ No newline at end of file +group by block_date diff --git a/transformers/synthetix/models/marts/arbitrum/sepolia/core/schema.yml b/transformers/synthetix/models/marts/arbitrum/sepolia/core/schema.yml index a696eee9..04193656 100644 --- a/transformers/synthetix/models/marts/arbitrum/sepolia/core/schema.yml +++ b/transformers/synthetix/models/marts/arbitrum/sepolia/core/schema.yml @@ -23,7 +23,7 @@ models: - name: fct_core_active_stakers_daily_arbitrum_sepolia description: "Daily number of active stakers" columns: - - name: date + - name: block_date description: "Date" data_type: date tests: diff --git a/transformers/synthetix/models/marts/arbitrum/sepolia/perp/fct_perp_accounts_settled_orders_arbitrum_sepolia.sql b/transformers/synthetix/models/marts/arbitrum/sepolia/perp/fct_perp_accounts_settled_orders_arbitrum_sepolia.sql index 089d0abc..2cc04b01 100644 --- a/transformers/synthetix/models/marts/arbitrum/sepolia/perp/fct_perp_accounts_settled_orders_arbitrum_sepolia.sql +++ b/transformers/synthetix/models/marts/arbitrum/sepolia/perp/fct_perp_accounts_settled_orders_arbitrum_sepolia.sql @@ -3,7 +3,7 @@ tags = ["perp", "account_activity", "arbitrum", "sepolia"] ) }} -select +select block_timestamp, account_id -from {{ ref('perp_order_settled_arbitrum_sepolia') }} \ No newline at end of file +from {{ ref('perp_order_settled_arbitrum_sepolia') }} diff --git a/transformers/synthetix/models/marts/base/mainnet/core/fct_core_account_activity_base_mainnet.sql b/transformers/synthetix/models/marts/base/mainnet/core/fct_core_account_activity_base_mainnet.sql index ef0f3a09..1885898d 100644 --- a/transformers/synthetix/models/marts/base/mainnet/core/fct_core_account_activity_base_mainnet.sql +++ b/transformers/synthetix/models/marts/base/mainnet/core/fct_core_account_activity_base_mainnet.sql @@ -8,7 +8,7 @@ with delegated as ( block_timestamp, account_id, 'Delegated' as account_action - from {{ ref('core_delegation_updated_base_mainnet') }} as core + from {{ ref('core_delegation_updated_base_mainnet') }} ), withdrawn as ( @@ -16,7 +16,7 @@ withdrawn as ( block_timestamp, account_id, 'Withdrawn' as account_action - from {{ ref('core_withdrawn_base_mainnet') }} as core + from {{ ref('core_withdrawn_base_mainnet') }} ), claimed as ( @@ -24,7 +24,7 @@ claimed as ( block_timestamp, account_id, 'Claimed' as account_action - from {{ ref('core_rewards_claimed_base_mainnet') }} as core + from {{ ref('core_rewards_claimed_base_mainnet') }} ), combined as ( @@ -39,4 +39,4 @@ select block_timestamp, account_action, account_id -from combined \ No newline at end of file +from combined diff --git a/transformers/synthetix/models/marts/base/mainnet/core/fct_core_active_stakers_daily_base_mainnet.sql b/transformers/synthetix/models/marts/base/mainnet/core/fct_core_active_stakers_daily_base_mainnet.sql index 7abf742c..a2b5a7ad 100644 --- a/transformers/synthetix/models/marts/base/mainnet/core/fct_core_active_stakers_daily_base_mainnet.sql +++ b/transformers/synthetix/models/marts/base/mainnet/core/fct_core_active_stakers_daily_base_mainnet.sql @@ -8,42 +8,45 @@ with delegation_updated as ( block_timestamp, account_id, amount - from {{ ref('core_delegation_updated_base_mainnet') }} as core + from {{ ref('core_delegation_updated_base_mainnet') }} ), dim as ( - select - d.date, - accounts.account_id + select + d.block_date, + accounts_unique.account_id from ( - select + select generate_series( date_trunc('day', date('2023-12-15')), date_trunc('day', current_date), '1 day'::interval - ) as date + ) as block_date ) as d cross join ( select distinct account_id from delegation_updated - ) as accounts + ) as accounts_unique ), stakers as ( - select - date, + select + dim.block_date, dim.account_id, - case when coalesce(last(amount) over ( - partition by dim.account_id - order by date - rows between unbounded preceding and current row - ), 0) = 0 then 0 else 1 end as is_staking + case + when coalesce(last(delegation_updated.amount) over ( + partition by dim.account_id + order by dim.block_date + rows between unbounded preceding and current row + ), 0) = 0 then 0 + else 1 + end as is_staking from dim - left join delegation_updated - on dim.date = date(delegation_updated.block_timestamp) + left join delegation_updated on + dim.block_date = date(delegation_updated.block_timestamp) and dim.account_id = delegation_updated.account_id ) select - date, + block_date, sum(is_staking) as nof_stakers_daily from stakers -group by date \ No newline at end of file +group by block_date diff --git a/transformers/synthetix/models/marts/base/mainnet/core/schema.yml b/transformers/synthetix/models/marts/base/mainnet/core/schema.yml index 5e834760..57ad6b38 100644 --- a/transformers/synthetix/models/marts/base/mainnet/core/schema.yml +++ b/transformers/synthetix/models/marts/base/mainnet/core/schema.yml @@ -23,7 +23,7 @@ models: - name: fct_core_active_stakers_daily_base_mainnet description: "Daily number of active stakers" columns: - - name: date + - name: block_date description: "Date" data_type: date tests: diff --git a/transformers/synthetix/models/marts/base/mainnet/perp/fct_perp_accounts_settled_orders_base_mainnet.sql b/transformers/synthetix/models/marts/base/mainnet/perp/fct_perp_accounts_settled_orders_base_mainnet.sql index e31a9d81..345964b6 100644 --- a/transformers/synthetix/models/marts/base/mainnet/perp/fct_perp_accounts_settled_orders_base_mainnet.sql +++ b/transformers/synthetix/models/marts/base/mainnet/perp/fct_perp_accounts_settled_orders_base_mainnet.sql @@ -3,7 +3,7 @@ tags = ["perp", "account_activity", "base", "mainnet"] ) }} -select +select block_timestamp, account_id -from {{ ref('perp_order_settled_base_mainnet') }} \ No newline at end of file +from {{ ref('perp_order_settled_base_mainnet') }} diff --git a/transformers/synthetix/models/marts/base/sepolia/core/fct_core_account_activity_base_sepolia.sql b/transformers/synthetix/models/marts/base/sepolia/core/fct_core_account_activity_base_sepolia.sql index 7be301fb..d3d95206 100644 --- a/transformers/synthetix/models/marts/base/sepolia/core/fct_core_account_activity_base_sepolia.sql +++ b/transformers/synthetix/models/marts/base/sepolia/core/fct_core_account_activity_base_sepolia.sql @@ -8,7 +8,7 @@ with delegated as ( block_timestamp, account_id, 'Delegated' as account_action - from {{ ref('core_delegation_updated_base_sepolia') }} as core + from {{ ref('core_delegation_updated_base_sepolia') }} ), withdrawn as ( @@ -16,7 +16,7 @@ withdrawn as ( block_timestamp, account_id, 'Withdrawn' as account_action - from {{ ref('core_withdrawn_base_sepolia') }} as core + from {{ ref('core_withdrawn_base_sepolia') }} ), claimed as ( @@ -24,7 +24,7 @@ claimed as ( block_timestamp, account_id, 'Claimed' as account_action - from {{ ref('core_rewards_claimed_base_sepolia') }} as core + from {{ ref('core_rewards_claimed_base_sepolia') }} ), combined as ( @@ -39,4 +39,4 @@ select block_timestamp, account_action, account_id -from combined \ No newline at end of file +from combined diff --git a/transformers/synthetix/models/marts/base/sepolia/core/fct_core_active_stakers_daily_base_sepolia.sql b/transformers/synthetix/models/marts/base/sepolia/core/fct_core_active_stakers_daily_base_sepolia.sql index a8160153..d15bf2cf 100644 --- a/transformers/synthetix/models/marts/base/sepolia/core/fct_core_active_stakers_daily_base_sepolia.sql +++ b/transformers/synthetix/models/marts/base/sepolia/core/fct_core_active_stakers_daily_base_sepolia.sql @@ -8,42 +8,45 @@ with delegation_updated as ( block_timestamp, account_id, amount - from {{ ref('core_delegation_updated_base_sepolia') }} as core + from {{ ref('core_delegation_updated_base_sepolia') }} ), dim as ( - select - d.date, - accounts.account_id + select + d.block_date, + accounts_unique.account_id from ( - select + select generate_series( date_trunc('day', date('2023-12-15')), date_trunc('day', current_date), '1 day'::interval - ) as date + ) as block_date ) as d cross join ( select distinct account_id from delegation_updated - ) as accounts + ) as accounts_unique ), stakers as ( - select - date, + select + dim.block_date, dim.account_id, - case when coalesce(last(amount) over ( - partition by dim.account_id - order by date - rows between unbounded preceding and current row - ), 0) = 0 then 0 else 1 end as is_staking + case + when coalesce(last(delegation_updated.amount) over ( + partition by dim.account_id + order by dim.block_date + rows between unbounded preceding and current row + ), 0) = 0 then 0 + else 1 + end as is_staking from dim - left join delegation_updated - on dim.date = date(delegation_updated.block_timestamp) + left join delegation_updated on + dim.block_date = date(delegation_updated.block_timestamp) and dim.account_id = delegation_updated.account_id ) select - date, + block_date, sum(is_staking) as nof_stakers_daily from stakers -group by date \ No newline at end of file +group by block_date diff --git a/transformers/synthetix/models/marts/base/sepolia/core/schema.yml b/transformers/synthetix/models/marts/base/sepolia/core/schema.yml index b3430e89..4fa7bc4f 100644 --- a/transformers/synthetix/models/marts/base/sepolia/core/schema.yml +++ b/transformers/synthetix/models/marts/base/sepolia/core/schema.yml @@ -23,7 +23,7 @@ models: - name: fct_core_active_stakers_daily_base_sepolia description: "Daily number of active stakers" columns: - - name: date + - name: block_date description: "Date" data_type: date tests: diff --git a/transformers/synthetix/models/marts/base/sepolia/perp/fct_perp_accounts_settled_orders_base_sepolia.sql b/transformers/synthetix/models/marts/base/sepolia/perp/fct_perp_accounts_settled_orders_base_sepolia.sql index b4d4be9d..5d15a05b 100644 --- a/transformers/synthetix/models/marts/base/sepolia/perp/fct_perp_accounts_settled_orders_base_sepolia.sql +++ b/transformers/synthetix/models/marts/base/sepolia/perp/fct_perp_accounts_settled_orders_base_sepolia.sql @@ -3,7 +3,7 @@ tags = ["perp", "account_activity", "base", "sepolia"] ) }} -select +select block_timestamp, account_id -from {{ ref('perp_order_settled_base_sepolia') }} \ No newline at end of file +from {{ ref('perp_order_settled_base_sepolia') }} diff --git a/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_account_activity_eth_mainnet.sql b/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_account_activity_eth_mainnet.sql index ad84e3c0..d35a5e97 100644 --- a/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_account_activity_eth_mainnet.sql +++ b/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_account_activity_eth_mainnet.sql @@ -8,7 +8,7 @@ with delegated as ( block_timestamp, account_id, 'Delegated' as account_action - from {{ ref('core_delegation_updated_eth_mainnet') }} as core + from {{ ref('core_delegation_updated_eth_mainnet') }} ), withdrawn as ( @@ -16,7 +16,7 @@ withdrawn as ( block_timestamp, account_id, 'Withdrawn' as account_action - from {{ ref('core_withdrawn_eth_mainnet') }} as core + from {{ ref('core_withdrawn_eth_mainnet') }} ), claimed as ( @@ -24,7 +24,7 @@ claimed as ( block_timestamp, account_id, 'Claimed' as account_action - from {{ ref('core_rewards_claimed_eth_mainnet') }} as core + from {{ ref('core_rewards_claimed_eth_mainnet') }} ), combined as ( @@ -39,4 +39,4 @@ select block_timestamp, account_action, account_id -from combined \ No newline at end of file +from combined diff --git a/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_active_stakers_daily_eth_mainnet.sql b/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_active_stakers_daily_eth_mainnet.sql index 4e133b6c..82dd35aa 100644 --- a/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_active_stakers_daily_eth_mainnet.sql +++ b/transformers/synthetix/models/marts/eth/mainnet/core/fct_core_active_stakers_daily_eth_mainnet.sql @@ -8,42 +8,45 @@ with delegation_updated as ( block_timestamp, account_id, amount - from {{ ref('core_delegation_updated_eth_mainnet') }} as core + from {{ ref('core_delegation_updated_eth_mainnet') }} ), dim as ( - select - d.date, - accounts.account_id + select + d.block_date, + accounts_unique.account_id from ( - select + select generate_series( date_trunc('day', date('2023-12-15')), date_trunc('day', current_date), '1 day'::interval - ) as date + ) as block_date ) as d cross join ( select distinct account_id from delegation_updated - ) as accounts + ) as accounts_unique ), stakers as ( - select - date, + select + dim.block_date, dim.account_id, - case when coalesce(last(amount) over ( - partition by dim.account_id - order by date - rows between unbounded preceding and current row - ), 0) = 0 then 0 else 1 end as is_staking + case + when coalesce(last(delegation_updated.amount) over ( + partition by dim.account_id + order by dim.block_date + rows between unbounded preceding and current row + ), 0) = 0 then 0 + else 1 + end as is_staking from dim - left join delegation_updated - on dim.date = date(delegation_updated.block_timestamp) + left join delegation_updated on + dim.block_date = date(delegation_updated.block_timestamp) and dim.account_id = delegation_updated.account_id ) select - date, + block_date, sum(is_staking) as nof_stakers_daily from stakers -group by date \ No newline at end of file +group by block_date diff --git a/transformers/synthetix/models/marts/eth/mainnet/core/schema.yml b/transformers/synthetix/models/marts/eth/mainnet/core/schema.yml index 925f9e43..a9cb2ab0 100644 --- a/transformers/synthetix/models/marts/eth/mainnet/core/schema.yml +++ b/transformers/synthetix/models/marts/eth/mainnet/core/schema.yml @@ -23,7 +23,7 @@ models: - name: fct_core_active_stakers_daily_eth_mainnet description: "Daily number of active stakers" columns: - - name: date + - name: block_date description: "Date" data_type: date tests: