Skip to content

Commit

Permalink
SPE-209 Transfers + GMX models as views (duneanalytics#4622)
Browse files Browse the repository at this point in the history
* Transfer models as views + message in non legacy

* gmx models as views

* disable check tag step in CI

will revert before merge

* Remove models already translated

* Revert "gmx models as views"

This reverts commit cf51bd1.

* Revert "disable check tag step in CI"

This reverts commit bc6c448.

* fix

* Revert "Revert "disable check tag step in CI""

This reverts commit e357159.

* Revert "Revert "Revert "disable check tag step in CI"""

This reverts commit e68c115.
  • Loading branch information
couralex6 authored Oct 17, 2023
1 parent 3035611 commit d3fdbd6
Show file tree
Hide file tree
Showing 53 changed files with 210 additions and 485 deletions.
5 changes: 4 additions & 1 deletion models/gmx/arbitrum/glp/gmx_arbitrum_glp_aum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
\'["1chioku"]\') }}'
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

/*
Expand Down
9 changes: 1 addition & 8 deletions models/gmx/arbitrum/glp/gmx_arbitrum_glp_aum_legacy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

alias = alias('glp_aum', legacy_model=True),
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'minute'],
post_hook='{{ expose_spells(\'["arbitrum"]\',
"project",
Expand Down Expand Up @@ -46,9 +44,4 @@ SELECT -- This query calculates the AUM of each component of GLP

dai_available_assets * dai_current_price AS dai_aum
FROM {{ref('gmx_arbitrum_glp_components_legacy')}}
{% if is_incremental() %}
WHERE minute >= date_trunc("day", now() - interval '1 day')
{% endif %}
{% if not is_incremental() %}
WHERE minute >= '{{project_start_date}}'
{% endif %}
WHERE minute >= '{{project_start_date}}'
5 changes: 4 additions & 1 deletion models/gmx/arbitrum/glp/gmx_arbitrum_glp_components.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
\'["1chioku"]\') }}'
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

SELECT
Expand Down
4 changes: 4 additions & 0 deletions models/gmx/arbitrum/glp/gmx_arbitrum_glp_components_base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

WITH minute AS -- This CTE generates a series of minute values
Expand Down
207 changes: 0 additions & 207 deletions models/gmx/arbitrum/glp/gmx_arbitrum_glp_components_base_legacy.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

alias = alias('glp_components', legacy_model=True),
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'minute'],
post_hook='{{ expose_spells(\'["arbitrum"]\',
"project",
Expand Down Expand Up @@ -56,9 +54,4 @@ SELECT
dai_available_assets, -- DAI Pool Amounts - Decimal Places 18
dai_current_price
FROM {{ref('gmx_arbitrum_glp_components_base_legacy')}}
{% if is_incremental() %}
WHERE minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
{% if not is_incremental() %}
WHERE minute >= '{{project_start_date}}'
{% endif %}
WHERE minute >= '{{project_start_date}}'
5 changes: 4 additions & 1 deletion models/gmx/arbitrum/glp/gmx_arbitrum_glp_fees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
\'["1chioku"]\') }}'
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

WITH minute AS -- This CTE generates a series of minute values
Expand Down
22 changes: 0 additions & 22 deletions models/gmx/arbitrum/glp/gmx_arbitrum_glp_fees_legacy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

alias = alias('glp_fees', legacy_model=True),
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'minute'],
post_hook='{{ expose_spells(\'["arbitrum"]\',
"project",
Expand All @@ -21,12 +19,7 @@ WITH minute AS -- This CTE generates a series of minute values
SELECT *
FROM
(
{% if not is_incremental() %}
SELECT explode(sequence(TIMESTAMP '{{project_start_date}}', CURRENT_TIMESTAMP, INTERVAL 1 minute)) AS minute -- 2021-08-31 08:13 is the timestamp of the first vault transaction
{% endif %}
{% if is_incremental() %}
SELECT explode(sequence(date_trunc("day", now() - interval '1 week'), CURRENT_TIMESTAMP, INTERVAL 1 minute)) AS minute
{% endif %}
)
),

Expand Down Expand Up @@ -54,12 +47,7 @@ fglp_balances AS -- This CTE returns the accuals of WETH tokens in the Fee GLP c
FROM {{ source('erc20_arbitrum', 'evt_transfer') }}
WHERE `to` = '0x4e971a87900b931ff39d1aad67697f49835400b6' -- Fee GLP contract
AND `contract_address` = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' -- WETH Arbitrum Smart Contract
{% if not is_incremental() %}
AND evt_block_time >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
AND evt_block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
) a
GROUP BY a.minute
) b
Expand Down Expand Up @@ -88,12 +76,7 @@ FROM
weth_cum_balance
FROM fglp_balances
-- excess time filter
{% if not is_incremental() %}
WHERE minute >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
WHERE minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
) b
ON a.minute = b.minute
LEFT JOIN
Expand All @@ -103,12 +86,7 @@ FROM
weth_current_price
FROM {{ref('gmx_arbitrum_glp_components_legacy')}}
-- excess time filter
{% if not is_incremental() %}
WHERE minute >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
WHERE minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
) c
ON a.minute = c.minute
) x
5 changes: 4 additions & 1 deletion models/gmx/arbitrum/glp/gmx_arbitrum_glp_float.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
\'["1chioku"]\') }}'
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

WITH minute AS -- This CTE generates a series of minute values
Expand Down
22 changes: 0 additions & 22 deletions models/gmx/arbitrum/glp/gmx_arbitrum_glp_float_legacy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

alias = alias('glp_float', legacy_model=True),
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'minute'],
post_hook='{{ expose_spells(\'["arbitrum"]\',
"project",
Expand All @@ -21,12 +19,7 @@ WITH minute AS -- This CTE generates a series of minute values
SELECT *
FROM
(
{% if not is_incremental() %}
SELECT explode(sequence(TIMESTAMP '{{project_start_date}}', CURRENT_TIMESTAMP, INTERVAL 1 minute)) AS minute -- 2021-08-31 08:13 is the timestamp of the first vault transaction
{% endif %}
{% if is_incremental() %}
SELECT explode(sequence(date_trunc("day", now() - interval '1 week'), CURRENT_TIMESTAMP, INTERVAL 1 minute)) AS minute
{% endif %}
)
),

Expand All @@ -52,25 +45,15 @@ glp_balances AS -- This CTE returns the accuals of WETH tokens in the Fee GLP co
date_trunc('minute', evt_block_time) AS minute,
mintAmount/1e18 AS mint_burn_value
FROM {{source('gmx_arbitrum', 'GlpManager_evt_AddLiquidity')}}
{% if not is_incremental() %}
WHERE evt_block_time >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}

UNION

SELECT
date_trunc('minute', evt_block_time) AS minute,
(-1 * glpAmount)/1e18 AS mint_burn_value
FROM {{source('gmx_arbitrum', 'GlpManager_evt_RemoveLiquidity')}}
{% if not is_incremental() %}
WHERE evt_block_time >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
) a
GROUP BY a.minute
) b
Expand All @@ -95,12 +78,7 @@ FROM
glp_mint_burn_value,
glp_cum_balance
FROM glp_balances
{% if not is_incremental() %}
WHERE minute >= '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
WHERE minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
) b
ON a.minute = b.minute
) x
5 changes: 4 additions & 1 deletion models/gmx/arbitrum/vault/gmx_arbitrum_vault_balances.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
\'["1chioku"]\') }}'
)
}}

/*
note: this spell has not been migrated to dunesql, therefore is only a view on spark
please migrate to dunesql to ensure up-to-date logic & data
*/
{% set project_start_date = '2021-08-31 08:13' %}

WITH minute AS -- This CTE generates a series of minute values
Expand Down
Loading

0 comments on commit d3fdbd6

Please sign in to comment.