diff --git a/transformers/synthetix/.sqlfluff b/transformers/synthetix/.sqlfluff index 8b1c4c38..37591132 100644 --- a/transformers/synthetix/.sqlfluff +++ b/transformers/synthetix/.sqlfluff @@ -1,6 +1,6 @@ [sqlfluff] dialect = postgres -templater = jinja +ignore = templating runaway_limit = 10 max_line_length = 80 indent_unit = space diff --git a/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_collateral_arbitrum_mainnet.sql b/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_collateral_arbitrum_mainnet.sql index 12244a88..61209af0 100644 --- a/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_collateral_arbitrum_mainnet.sql +++ b/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_collateral_arbitrum_mainnet.sql @@ -1,43 +1,40 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - amount AS numeric - ) AS amount, - CAST( - "value" AS numeric - ) AS collateral_value - FROM + cast( + amount as numeric + ) as amount, + cast( + value as numeric + ) as collateral_value + from {{ source( 'raw_arbitrum_mainnet', "core_get_vault_collateral" ) }} - WHERE - amount IS NOT NULL + where + amount is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.amount') }} AS amount, - {{ convert_wei('base.collateral_value') }} AS collateral_value -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.amount') }} as amount, + {{ convert_wei('base.collateral_value') }} as collateral_value +from base - JOIN {{ ref('blocks_arbitrum_mainnet') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_arbitrum_mainnet', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_debt_arbitrum_mainnet.sql b/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_debt_arbitrum_mainnet.sql index a3cace75..579a4592 100644 --- a/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_debt_arbitrum_mainnet.sql +++ b/transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_debt_arbitrum_mainnet.sql @@ -1,39 +1,36 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - value_1 AS numeric - ) AS debt - FROM + cast( + value_1 as numeric + ) as debt + from {{ source( 'raw_arbitrum_mainnet', "core_get_vault_debt" ) }} - WHERE - value_1 IS NOT NULL + where + value_1 is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.debt') }} AS debt -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.debt') }} as debt +from base - JOIN {{ ref('blocks_arbitrum_mainnet') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_arbitrum_mainnet', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_collateral_arbitrum_sepolia.sql b/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_collateral_arbitrum_sepolia.sql index b3a9754c..5c19fd03 100644 --- a/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_collateral_arbitrum_sepolia.sql +++ b/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_collateral_arbitrum_sepolia.sql @@ -1,43 +1,40 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - amount AS numeric - ) AS amount, - CAST( - "value" AS numeric - ) AS collateral_value - FROM + cast( + amount as numeric + ) as amount, + cast( + value as numeric + ) as collateral_value + from {{ source( 'raw_arbitrum_sepolia', "core_get_vault_collateral" ) }} - WHERE - amount IS NOT NULL + where + amount is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.amount') }} AS amount, - {{ convert_wei('base.collateral_value') }} AS collateral_value -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.amount') }} as amount, + {{ convert_wei('base.collateral_value') }} as collateral_value +from base - JOIN {{ ref('blocks_arbitrum_sepolia') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_arbitrum_sepolia', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_debt_arbitrum_sepolia.sql b/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_debt_arbitrum_sepolia.sql index faee00b3..562dfc79 100644 --- a/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_debt_arbitrum_sepolia.sql +++ b/transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_debt_arbitrum_sepolia.sql @@ -1,39 +1,36 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - value_1 AS numeric - ) AS debt - FROM + cast( + value_1 as numeric + ) as debt + from {{ source( 'raw_arbitrum_sepolia', "core_get_vault_debt" ) }} - WHERE - value_1 IS NOT NULL + where + value_1 is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.debt') }} AS debt -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.debt') }} as debt +from base - JOIN {{ ref('blocks_arbitrum_sepolia') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_arbitrum_sepolia', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/base/mainnet/core/core_vault_collateral_base_mainnet.sql b/transformers/synthetix/models/raw/base/mainnet/core/core_vault_collateral_base_mainnet.sql index affe3382..499b4bb1 100644 --- a/transformers/synthetix/models/raw/base/mainnet/core/core_vault_collateral_base_mainnet.sql +++ b/transformers/synthetix/models/raw/base/mainnet/core/core_vault_collateral_base_mainnet.sql @@ -1,44 +1,40 @@ -{{ - config( - materialized='table' - ) -}} - - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - amount AS numeric - ) AS amount, - CAST( - "value" AS numeric - ) AS collateral_value - FROM + cast( + amount as numeric + ) as amount, + cast( + value as numeric + ) as collateral_value + from {{ source( 'raw_base_mainnet', "core_get_vault_collateral" ) }} - WHERE - amount IS NOT NULL + where + amount is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.amount') }} AS amount, - {{ convert_wei('base.collateral_value') }} AS collateral_value -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.amount') }} as amount, + {{ convert_wei('base.collateral_value') }} as collateral_value +from base - JOIN {{ ref('blocks_base_mainnet') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_base_mainnet', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/base/mainnet/core/core_vault_debt_base_mainnet.sql b/transformers/synthetix/models/raw/base/mainnet/core/core_vault_debt_base_mainnet.sql index 67a575da..d80c6bd8 100644 --- a/transformers/synthetix/models/raw/base/mainnet/core/core_vault_debt_base_mainnet.sql +++ b/transformers/synthetix/models/raw/base/mainnet/core/core_vault_debt_base_mainnet.sql @@ -1,40 +1,36 @@ -{{ - config( - materialized='table' - ) -}} - - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - value_1 AS numeric - ) AS debt - FROM + cast( + value_1 as numeric + ) as debt + from {{ source( 'raw_base_mainnet', "core_get_vault_debt" ) }} - WHERE - value_1 IS NOT NULL + where + value_1 is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.debt') }} AS debt -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.debt') }} as debt +from base - JOIN {{ ref('blocks_base_mainnet') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_base_mainnet', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/base/sepolia/core/core_vault_collateral_base_sepolia.sql b/transformers/synthetix/models/raw/base/sepolia/core/core_vault_collateral_base_sepolia.sql index 28fa8cb5..162f7f7f 100644 --- a/transformers/synthetix/models/raw/base/sepolia/core/core_vault_collateral_base_sepolia.sql +++ b/transformers/synthetix/models/raw/base/sepolia/core/core_vault_collateral_base_sepolia.sql @@ -1,43 +1,40 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - amount AS numeric - ) AS amount, - CAST( - "value" AS numeric - ) AS collateral_value - FROM + cast( + amount as numeric + ) as amount, + cast( + value as numeric + ) as collateral_value + from {{ source( 'raw_base_sepolia', "core_get_vault_collateral" ) }} - WHERE - amount IS NOT NULL + where + amount is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.amount') }} AS amount, - {{ convert_wei('base.collateral_value') }} AS collateral_value -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.amount') }} as amount, + {{ convert_wei('base.collateral_value') }} as collateral_value +from base - JOIN {{ ref('blocks_base_sepolia') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_base_sepolia', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/base/sepolia/core/core_vault_debt_base_sepolia.sql b/transformers/synthetix/models/raw/base/sepolia/core/core_vault_debt_base_sepolia.sql index 841731ad..2170054d 100644 --- a/transformers/synthetix/models/raw/base/sepolia/core/core_vault_debt_base_sepolia.sql +++ b/transformers/synthetix/models/raw/base/sepolia/core/core_vault_debt_base_sepolia.sql @@ -1,39 +1,36 @@ -{{ - config( - materialized='table' - ) -}} - -WITH base AS ( - SELECT +with base as ( + select block_number, contract_address, chain_id, pool_id, collateral_type, - CAST( - value_1 AS numeric - ) AS debt - FROM + cast( + value_1 as numeric + ) as debt + from {{ source( 'raw_base_sepolia', "core_get_vault_debt" ) }} - WHERE - value_1 IS NOT NULL + where + value_1 is not null ) -SELECT - blocks.ts, - base.block_number, + +select + to_timestamp(blocks.timestamp) as ts, + cast( + blocks.block_number as integer + ) as block_number, base.contract_address, - CAST( - base.pool_id AS INTEGER - ) AS pool_id, - CAST( - base.collateral_type AS VARCHAR - ) AS collateral_type, - {{ convert_wei('base.debt') }} AS debt -FROM + cast( + base.pool_id as integer + ) as pool_id, + cast( + base.collateral_type as varchar + ) as collateral_type, + {{ convert_wei('base.debt') }} as debt +from base - JOIN {{ ref('blocks_base_sepolia') }} AS blocks - ON base.block_number = blocks.block_number +inner join {{ source('raw_base_sepolia', 'blocks_parquet') }} as blocks + on base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_collateral_eth_mainnet.sql b/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_collateral_eth_mainnet.sql index 0068b34b..b1379093 100644 --- a/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_collateral_eth_mainnet.sql +++ b/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_collateral_eth_mainnet.sql @@ -33,5 +33,5 @@ SELECT {{ convert_wei('base.collateral_value') }} AS collateral_value FROM base - JOIN {{ ref('blocks_eth_mainnet') }} AS blocks + JOIN {{ source('raw_eth_mainnet', 'blocks_parquet') }} AS blocks ON base.block_number = blocks.block_number diff --git a/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_debt_eth_mainnet.sql b/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_debt_eth_mainnet.sql index a5a1b516..b9fd9036 100644 --- a/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_debt_eth_mainnet.sql +++ b/transformers/synthetix/models/raw/eth/mainnet/core/core_vault_debt_eth_mainnet.sql @@ -29,5 +29,5 @@ SELECT {{ convert_wei('base.debt') }} AS debt FROM base - JOIN {{ ref('blocks_eth_mainnet') }} AS blocks + JOIN {{ source('raw_eth_mainnet', 'blocks_parquet') }} AS blocks ON base.block_number = blocks.block_number