-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from Synthetixio/transformers/fix-blocks-join
Transfomer - Fix JOIN in core vault views
- Loading branch information
Showing
11 changed files
with
211 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 28 additions & 31 deletions
59
...ers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_collateral_arbitrum_mainnet.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
51 changes: 24 additions & 27 deletions
51
transformers/synthetix/models/raw/arbitrum/mainnet/core/core_vault_debt_arbitrum_mainnet.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
59 changes: 28 additions & 31 deletions
59
...ers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_collateral_arbitrum_sepolia.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
51 changes: 24 additions & 27 deletions
51
transformers/synthetix/models/raw/arbitrum/sepolia/core/core_vault_debt_arbitrum_sepolia.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
60 changes: 28 additions & 32 deletions
60
transformers/synthetix/models/raw/base/mainnet/core/core_vault_collateral_base_mainnet.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.