This commit is contained in:
sam 2025-03-12 23:25:28 +08:00
parent 8df66e80c1
commit 29555ca590
235 changed files with 259 additions and 16338 deletions

View File

@ -30,7 +30,19 @@ models:
relation: true
columns: true
+on_schema_change: "append_new_columns"
fsc_evm:
+enabled: true
+copy_grants: true
+persist_docs:
relation: true
columns: true
+on_schema_change: "append_new_columns"
main_package:
+enabled: true
curated_package:
+enabled: true
decoder_package:
+enabled: true
tests:
+store_failures: true # all tests
@ -39,7 +51,7 @@ on-run-start:
- "{{ create_udfs() }}"
on-run-end:
- '{{ apply_meta_as_tags(results) }}'
- "{{ apply_meta_as_tags(results) }}"
dispatch:
- macro_namespace: dbt
@ -49,7 +61,7 @@ dispatch:
- dbt
query-comment:
comment: '{{ dbt_snowflake_query_tags.get_query_comment(node) }}'
comment: "{{ dbt_snowflake_query_tags.get_query_comment(node) }}"
append: true # Snowflake removes prefixed comments.
# Configuring models
@ -71,14 +83,14 @@ vars:
HEAL_MODELS: []
START_GHA_TASKS: False
#### STREAMLINE 2.0 BEGIN ####
#### STREAMLINE 2.0 BEGIN ####
API_INTEGRATION: '{{ var("config")[target.name]["API_INTEGRATION"] if var("config")[target.name] else var("config")["dev"]["API_INTEGRATION"] }}'
EXTERNAL_FUNCTION_URI: '{{ var("config")[target.name]["EXTERNAL_FUNCTION_URI"] if var("config")[target.name] else var("config")["dev"]["EXTERNAL_FUNCTION_URI"] }}'
ROLES: |
["INTERNAL_DEV"]
config:
# The keys correspond to dbt profiles and are case sensitive
# The keys correspond to dbt profiles and are case sensitive
dev:
API_INTEGRATION: AWS_ARBITRUM_API_STG_V2
EXTERNAL_FUNCTION_URI: sko0tcm8t1.execute-api.us-east-1.amazonaws.com/stg/
@ -94,17 +106,17 @@ vars:
- INTERNAL_DEV
- DBT_CLOUD_ARBITRUM
#### STREAMLINE 2.0 END ####
#### STREAMLINE 2.0 END ####
#### FSC_EVM BEGIN ####
# Visit https://github.com/FlipsideCrypto/fsc-evm/wiki for more information on required and optional variables
#### FSC_EVM BEGIN ####
# Visit https://github.com/FlipsideCrypto/fsc-evm/wiki for more information on required and optional variables
### GLOBAL VARIABLES BEGIN ###
## REQUIRED
GLOBAL_PROD_DB_NAME: 'arbitrum'
GLOBAL_NODE_SECRET_PATH: 'Vault/prod/arbitrum/quicknode/mainnet'
GLOBAL_NODE_URL: '{service}/{Authentication}'
GLOBAL_BLOCKS_PER_HOUR: 14200
GLOBAL_PROD_DB_NAME: "arbitrum"
GLOBAL_NODE_SECRET_PATH: "Vault/prod/arbitrum/quicknode/mainnet"
GLOBAL_NODE_URL: "{service}/{Authentication}"
GLOBAL_BLOCKS_PER_HOUR: 14200
GLOBAL_USES_STREAMLINE_V1: True
GLOBAL_USES_SINGLE_FLIGHT_METHOD: True
@ -150,5 +162,4 @@ vars:
# DECODED_LOGS_HISTORY_SQL_LIMIT: 1 #limit per monthly range
### DECODER_PACKAGE VARIABLES END ###
#### FSC_EVM END ####
#### FSC_EVM END ####

233
macros/get_vars.sql Normal file
View File

@ -0,0 +1,233 @@
{% macro vars_config(all_projects=false) %}
{# Retrieves variable configurations and values from project-specific macros.
When all_projects=True, gets variables from all projects.
Otherwise, gets variables only for the current project based on target database. #}
{# Initialize empty dictionary for all variables #}
{% set target_vars = {} %}
{# Determine current project based on database name #}
{% set target_db = target.database.lower() | replace('_dev', '') %}
{% if all_projects %}
{# Get all macro names in the context #}
{% set all_macros = context.keys() %}
{# Filter for project variable macros (those ending with _vars) #}
{% for macro_name in all_macros %}
{% if macro_name.endswith('_vars') %}
{# Extract project name from macro name #}
{% set project_name = macro_name.replace('_vars', '') %}
{# Call the project macro and add to target_vars #}
{% set project_config = context[macro_name]() %}
{# Only include if the result is a mapping #}
{% if project_config is mapping %}
{% do target_vars.update({project_name: project_config}) %}
{% endif %}
{% endif %}
{% endfor %}
{% else %}
{# Construct the macro name for this project #}
{% set project_macro = target_db ~ '_vars' %}
{# Try to call the macro directly #}
{% if context.get(project_macro) is not none %}
{% set project_config = context[project_macro]() %}
{% do target_vars.update({target_db: project_config}) %}
{% endif %}
{% endif %}
{{ return(target_vars) }}
{% endmacro %}
{% macro flatten_vars() %}
{# Converts the nested variable structure from vars_config() into a flat list of dictionaries.
Each dictionary contains project, key, parent_key, value properties. #}
{# Get the nested structure from vars_config() #}
{% set nested_vars = vars_config() %}
{# Convert the nested structure to the flat format expected by get_var() #}
{% set flat_vars = [] %}
{% for project, vars in nested_vars.items() %}
{% for key, value in vars.items() %}
{% if value is mapping %}
{# Handle nested mappings (where parent_key is not none) #}
{% for subkey, subvalue in value.items() %}
{% do flat_vars.append({
'project': project,
'key': subkey,
'parent_key': key,
'value': subvalue
}) %}
{% endfor %}
{% else %}
{% do flat_vars.append({
'project': project,
'key': key,
'parent_key': none,
'value': value
}) %}
{% endif %}
{% endfor %}
{% endfor %}
{{ return(flat_vars) }}
{% endmacro %}
{% macro get_var_logs(variable_key, default) %}
{# Logs variable information to the terminal and a table in the database.
Dependent on GET_VAR_LOGS_ENABLED and execute flags. #}
{% if var('GET_VAR_LOGS_ENABLED', false) and execute %}
{% set package = variable_key.split('_')[0] %}
{% set category = variable_key.split('_')[1] %}
{# Determine the data type of the default value #}
{% if default is not none %}
{% if default is string %}
{% set default_type = 'STRING' %}
{% set default_value = '\'\'' ~ default ~ '\'\'' %}
{% elif default is number %}
{% set default_type = 'NUMBER' %}
{% set default_value = default %}
{% elif default is boolean %}
{% set default_type = 'BOOLEAN' %}
{% set default_value = default %}
{% elif default is mapping %}
{% set default_type = 'OBJECT' %}
{% set default_value = default | tojson %}
{% elif default is sequence and default is not string %}
{% set default_type = 'ARRAY' %}
{% set default_value = default | tojson %}
{% elif default is iterable and default is not string %}
{% set default_type = 'ITERABLE' %}
{% set default_value = 'ITERABLE' %}
{% else %}
{% set default_type = 'UNKNOWN' %}
{% set default_value = 'UNKNOWN' %}
{% endif %}
{% else %}
{% set default_type = none %}
{% set default_value = none %}
{% endif %}
{% set log_query %}
CREATE TABLE IF NOT EXISTS {{target.database}}.bronze._master_keys (
package STRING,
category STRING,
variable_key STRING,
default_value STRING,
default_type STRING,
_inserted_timestamp TIMESTAMP_NTZ DEFAULT SYSDATE()
);
INSERT INTO {{target.database}}.bronze._master_keys (
package,
category,
variable_key,
default_value,
default_type
)
VALUES (
'{{ package }}',
'{{ category }}',
'{{ variable_key }}',
'{{ default_value }}',
'{{ default_type }}'
);
{% endset %}
{% do run_query(log_query) %}
{# Update terminal logs to include type information #}
{% do log(package ~ "|" ~ category ~ "|" ~ variable_key ~ "|" ~ default_value ~ "|" ~ default_type, info=True) %}
{% endif %}
{% endmacro %}
{% macro get_var(variable_key, default=none) %}
{# Retrieves a variable by key from either dbt's built-in var() function or from project configs.
Handles type conversion for strings, numbers, booleans, arrays, and JSON objects.
Returns the default value if the variable is not found. #}
{# Log variable info if enabled #}
{% do get_var_logs(variable_key, default) %}
{# Check if variable exists in dbt's built-in var() function. If it does, return the value. #}
{% if var(variable_key, none) is not none %}
{{ return(var(variable_key)) }}
{% endif %}
{# Get flattened variables from the config file #}
{% set all_vars = flatten_vars() %}
{% if execute %}
{# Filter variables based on the requested key #}
{% set filtered_vars = [] %}
{% for var_item in all_vars %}
{% if (var_item.key == variable_key or var_item.parent_key == variable_key) %}
{% do filtered_vars.append(var_item) %}
{% endif %}
{% endfor %}
{# If no results found, return the default value #}
{% if filtered_vars | length == 0 %}
{{ return(default) }}
{% endif %}
{% set first_var = filtered_vars[0] %}
{% set parent_key = first_var.parent_key %}
{% set value = first_var.value %}
{# Check if this is a simple variable (no parent key) or a mapping (has parent key) #}
{% if parent_key is none or parent_key == '' %}
{# Infer data type from value #}
{% if value is string %}
{% if value.startswith('[') and value.endswith(']') %}
{# For array type, parse and convert values to appropriate types #}
{% set array_values = value.strip('[]').split(',') %}
{% set converted_array = [] %}
{% for val in array_values %}
{% set stripped_val = val.strip() %}
{% if stripped_val.isdigit() %}
{% do converted_array.append(stripped_val | int) %}
{% elif stripped_val.replace('.','',1).isdigit() %}
{% do converted_array.append(stripped_val | float) %}
{% elif stripped_val.lower() in ['true', 'false'] %}
{% do converted_array.append(stripped_val.lower() == 'true') %}
{% else %}
{% do converted_array.append(stripped_val) %}
{% endif %}
{% endfor %}
{{ return(converted_array) }}
{% elif value.startswith('{') and value.endswith('}') %}
{# For JSON, VARIANT, OBJECT #}
{{ return(fromjson(value)) }}
{% elif value.isdigit() %}
{{ return(value | int) }}
{% elif value.replace('.','',1).isdigit() %}
{{ return(value | float) }}
{% elif value.lower() in ['true', 'false'] %}
{{ return(value.lower() == 'true') }}
{% else %}
{{ return(value) }}
{% endif %}
{% else %}
{# If value is already a non-string type (int, bool, etc.) #}
{{ return(value) }}
{% endif %}
{% else %}
{# For variables with a parent_key, build a dictionary of all child values #}
{% set mapping = {} %}
{% for var_item in filtered_vars %}
{# key: value pairings based on parent_key #}
{% do mapping.update({var_item.key: var_item.value}) %}
{% endfor %}
{{ return(mapping) }}
{% endif %}
{% else %}
{{ return(default) }}
{% endif %}
{% endmacro %}

View File

@ -1,87 +0,0 @@
{{ config (
materialized = "ephemeral"
) }}
WITH retry AS (
SELECT
contract_address,
GREATEST(
latest_call_block,
latest_event_block
) AS block_number,
total_interaction_count
FROM
{{ ref("silver__relevant_contracts") }}
r
LEFT JOIN {{ source(
'arbitrum_silver',
'verified_abis'
) }}
v USING (contract_address)
WHERE
r.total_interaction_count >= 250 -- high interaction count
AND GREATEST(
max_inserted_timestamp_logs,
max_inserted_timestamp_traces
) >= CURRENT_DATE - INTERVAL '30 days' -- recent activity
AND v.contract_address IS NULL -- no verified abi
AND r.contract_address NOT IN (
SELECT
contract_address
FROM
{{ source(
'arbitrum_bronze_api',
'contract_abis'
) }}
WHERE
_inserted_timestamp >= CURRENT_DATE - INTERVAL '30 days' -- this won't let us retry the same contract within 30 days
AND abi_data :data :result :: STRING <> 'Max rate limit reached'
)
ORDER BY
total_interaction_count DESC
LIMIT
25
), FINAL AS (
SELECT
proxy_address AS contract_address,
start_block AS block_number
FROM
{{ ref("silver__proxies") }}
p
JOIN retry r USING (contract_address)
LEFT JOIN {{ source(
'arbitrum_silver',
'verified_abis'
) }}
v
ON v.contract_address = p.proxy_address
WHERE
v.contract_address IS NULL
AND p.contract_address NOT IN (
SELECT
contract_address
FROM
{{ source(
'arbitrum_bronze_api',
'contract_abis'
) }}
WHERE
_inserted_timestamp >= CURRENT_DATE - INTERVAL '30 days' -- this won't let us retry the same contract within 30 days
AND abi_data :data :result :: STRING <> 'Max rate limit reached'
)
UNION ALL
SELECT
contract_address,
block_number
FROM
retry
)
SELECT
*
FROM
FINAL qualify ROW_NUMBER() over (
PARTITION BY contract_address
ORDER BY
block_number DESC
) = 1

View File

@ -1,79 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = "contract_address",
full_refresh = false,
tags = ['curated']
) }}
WITH base AS (
SELECT
contract_address
FROM
{{ ref('silver__relevant_contracts') }}
WHERE
total_interaction_count >= 100
{% if is_incremental() %}
and contract_address not in (
SELECT
contract_address
FROM
{{ this }}
WHERE
abi_data :data :result :: STRING <> 'Max rate limit reached'
)
{% endif %}
order by total_interaction_count desc
LIMIT
100
), all_contracts AS (
SELECT
contract_address
FROM
base
UNION
SELECT
contract_address
FROM
{{ ref('_retry_abis') }}
),
row_nos AS (
SELECT
contract_address,
ROW_NUMBER() over (
ORDER BY
contract_address
) AS row_no
FROM
all_contracts
),
batched AS ({% for item in range(151) %}
SELECT
rn.contract_address,
live.udf_api(
'GET',
CONCAT('https://api.arbiscan.io/api?module=contract&action=getabi&address=', rn.contract_address, '&apikey={key}'),
OBJECT_CONSTRUCT(
'Content-Type', 'application/json',
'fsc-quantum-state', 'livequery'
),
NULL,
'Vault/prod/block_explorers/arbitrum_scan'
)AS abi_data,
SYSDATE() AS _inserted_timestamp
FROM
row_nos rn
WHERE
row_no = {{ item }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %})
SELECT
contract_address,
abi_data,
_inserted_timestamp
FROM
batched

View File

@ -1,22 +0,0 @@
version: 2
models:
- name: bronze_api__contract_abis
columns:
- name: _INSERTED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: CONTRACT_ADDRESS
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- VARCHAR
- dbt_expectations.expect_column_values_to_match_regex:
regex: "^(0x)[0-9a-fA-F]{40}$"

View File

@ -1,130 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = "contract_address",
full_refresh = false,
tags = ['non_realtime']
) }}
WITH base AS (
SELECT
contract_address,
latest_event_block AS latest_block
FROM
{{ ref('silver__relevant_contracts') }}
WHERE
total_event_count >= 25
{% if is_incremental() %}
AND contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
{% endif %}
ORDER BY
total_event_count DESC
LIMIT
200
), function_sigs AS (
SELECT
'0x313ce567' AS function_sig,
'decimals' AS function_name
UNION
SELECT
'0x06fdde03',
'name'
UNION
SELECT
'0x95d89b41',
'symbol'
),
all_reads AS (
SELECT
*
FROM
base
JOIN function_sigs
ON 1 = 1
),
ready_reads AS (
SELECT
contract_address,
latest_block,
function_sig,
RPAD(
function_sig,
64,
'0'
) AS input,
utils.udf_json_rpc_call(
'eth_call',
[{'to': contract_address, 'from': null, 'data': input}, utils.udf_int_to_hex(latest_block)],
concat_ws(
'-',
contract_address,
input,
latest_block
)
) AS rpc_request
FROM
all_reads
),
batch_reads AS (
SELECT
ARRAY_AGG(rpc_request) AS batch_rpc_request
FROM
ready_reads
),
node_call AS (
SELECT
*,
live.udf_api(
'POST',
CONCAT(
'{service}',
'/',
'{Authentication}'
),{},
batch_rpc_request,
'Vault/prod/arbitrum/quicknode/mainnet'
) AS response
FROM
batch_reads
WHERE
EXISTS (
SELECT
1
FROM
ready_reads
LIMIT
1
)
), flat_responses AS (
SELECT
VALUE :id :: STRING AS call_id,
VALUE :result :: STRING AS read_result
FROM
node_call,
LATERAL FLATTEN (
input => response :data
)
)
SELECT
SPLIT_PART(
call_id,
'-',
1
) AS contract_address,
SPLIT_PART(
call_id,
'-',
3
) AS block_number,
LEFT(SPLIT_PART(call_id, '-', 2), 10) AS function_sig,
NULL AS function_input,
read_result,
SYSDATE() :: TIMESTAMP AS _inserted_timestamp
FROM
flat_responses

View File

@ -1,18 +0,0 @@
version: 2
models:
- name: bronze_api__token_reads
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- CONTRACT_ADDRESS
- FUNCTION_SIG
columns:
- name: _INSERTED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ

View File

@ -1,25 +0,0 @@
{{ config(
materialized = 'view'
) }}
SELECT
system_created_at,
insert_date,
blockchain,
address,
creator,
label_type,
label_subtype,
address_name,
project_name,
_is_deleted,
modified_timestamp,
labels_combined_id
FROM
{{ source(
'crosschain_silver',
'labels_combined'
) }}
WHERE
blockchain = 'arbitrum'
AND address LIKE '0x%'

View File

@ -1,26 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
asset_id,
symbol,
NAME,
decimals,
blockchain,
is_deprecated,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_native_asset_metadata_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_native_asset_metadata'
) }}
WHERE
blockchain = 'ethereum'
AND symbol = 'ETH'

View File

@ -1,29 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
HOUR,
asset_id,
symbol,
NAME,
decimals,
price,
blockchain,
is_imputed,
is_deprecated,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_native_prices_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_native_prices'
) }}
WHERE
blockchain = 'ethereum'
AND symbol = 'ETH'

View File

@ -1,26 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
asset_id,
token_address,
NAME,
symbol,
platform,
platform_id,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_provider_asset_metadata_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_provider_asset_metadata'
) }}
WHERE
platform = 'Arbitrum'
-- platforms specific to Arbitrum

View File

@ -1,24 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
asset_id,
recorded_hour,
OPEN,
high,
low,
CLOSE,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_provider_prices_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_provider_prices'
) }}
-- prices for all ids

View File

@ -1,28 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
blockchain_name,
blockchain_id,
is_deprecated,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_token_asset_metadata_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_token_asset_metadata'
) }}
WHERE
blockchain = 'arbitrum'

View File

@ -1,31 +0,0 @@
{{ config (
materialized = 'view'
) }}
SELECT
HOUR,
token_address,
asset_id,
symbol,
NAME,
decimals,
price,
blockchain,
blockchain_name,
blockchain_id,
is_imputed,
is_deprecated,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_token_prices_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_token_prices'
) }}
WHERE
blockchain = 'arbitrum'

View File

@ -1,6 +0,0 @@
{{ config(
materialized = 'view',
tags = ['gha_tasks']
) }}
{{ fsc_utils.gha_task_current_status_view() }}

View File

@ -1,18 +0,0 @@
version: 2
models:
- name: github_actions__current_task_status
columns:
- name: PIPELINE_ACTIVE
tests:
- dbt_expectations.expect_column_values_to_be_in_set:
value_set:
- TRUE
config:
severity: warn
- name: SUCCESSES
tests:
- dbt_expectations.expect_column_values_to_be_in_set:
value_set:
- 2
config:
severity: warn

View File

@ -1,5 +0,0 @@
{{ config(
materialized = 'view'
) }}
{{ fsc_utils.gha_task_history_view() }}

View File

@ -1,5 +0,0 @@
{{ config(
materialized = 'view'
) }}
{{ fsc_utils.gha_task_performance_view() }}

View File

@ -1,5 +0,0 @@
{{ config(
materialized = 'view'
) }}
{{ fsc_utils.gha_task_schedule_view() }}

View File

@ -1,5 +0,0 @@
{{ config(
materialized = 'view'
) }}
{{ fsc_utils.gha_tasks_view() }}

View File

@ -1,16 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
contract_address,
DATA AS abi,
abi_source,
bytecode,
abis_id AS dim_contract_abis_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__abis') }}

View File

@ -1,19 +0,0 @@
version: 2
models:
- name: core__dim_contract_abis
description: >
'This table contains the contract ABIs that we have sourced from Arbiscan, the community, or bytecode matched. This table is the source of ABIs used in the `core__ez_decoded_event_logs` and `core__fact_decoded_event_logs` tables.
We first try to source ABIs from Arbiscan. If we cannot find an ABI on Arbiscan, we will rely on user submissions. To add a contract to this table, please visit [here](https://science.flipsidecrypto.xyz/abi-requestor/).
If we are unable to locate an ABI for a contract from Arbiscan or the community, we will try to find an ABI to use by matching the contract bytecode to a known contract bytecode we do have an ABI for.'
columns:
- name: CONTRACT_ADDRESS
description: 'The address of the contract.'
- name: ABI
description: 'The JSON ABI for the contract.'
- name: ABI_SOURCE
description: 'The source of the ABI. This can be `Arbiscan`, `user_submitted`, or `bytecode_matched`.'
- name: BYTECODE
description: 'The deployed bytecode of the contract.'

View File

@ -1,33 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
c0.created_contract_address AS address,
c1.token_symbol AS symbol,
c1.token_name AS NAME,
c1.token_decimals AS decimals,
c0.block_number AS created_block_number,
c0.block_timestamp AS created_block_timestamp,
c0.tx_hash AS created_tx_hash,
c0.creator_address AS creator_address,
COALESCE (
c0.created_contracts_id,
{{ dbt_utils.generate_surrogate_key(
['c0.created_contract_address']
) }}
) AS dim_contracts_id,
GREATEST(COALESCE(c0.inserted_timestamp, '2000-01-01'), COALESCE(c1.inserted_timestamp, '2000-01-01')) AS inserted_timestamp,
GREATEST(COALESCE(c0.modified_timestamp, '2000-01-01'), COALESCE(c1.modified_timestamp, '2000-01-01')) AS modified_timestamp
FROM
{{ ref('silver__created_contracts') }}
c0
LEFT JOIN {{ ref('silver__contracts') }}
c1
ON LOWER(
c0.created_contract_address
) = LOWER(
c1.contract_address
)

View File

@ -1,28 +0,0 @@
version: 2
models:
- name: core__dim_contracts
description: This table contains all the contracts that are deployed on the Arbitrum One blockchain along with their on-chain metadata.
columns:
- name: ADDRESS
description: 'The address of the contract.'
- name: SYMBOL
description: 'The symbol of the contract.'
- name: NAME
description: 'The name of the contract.'
- name: DECIMALS
description: 'The number of decimals used to adjust amount for this contract.'
- name: CREATED_BLOCK_NUMBER
description: 'The block number when the contract was created'
- name: CREATED_BLOCK_TIMESTAMP
description: 'The block timestamp when the contract was created'
- name: CREATED_TX_HASH
description: 'The transaction hash when the contract was created'
- name: CREATOR_ADDRESS
description: 'The address of the creator of the contract'
- name: DIM_CONTRACTS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,19 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
blockchain,
creator,
address,
address_name,
label_type,
label_subtype,
project_name,
labels_combined_id AS dim_labels_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__labels') }}

View File

@ -1,60 +0,0 @@
version: 2
models:
- name: core__dim_labels
description: '{{ doc("table_dim_labels") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCKCHAIN
- CREATOR
- ADDRESS
columns:
- name: BLOCKCHAIN
description: '{{ doc("arb_label_blockchain") }}'
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_set:
value_set: ['arbitrum']
- name: CREATOR
description: '{{ doc("arb_label_creator") }}'
tests:
- not_null
- name: ADDRESS
description: '{{ doc("arb_label_address") }}'
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: ADDRESS_NAME
description: '{{ doc("arb_labels_table") }}'
tests:
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: LABEL_TYPE
description: '{{ doc("arb_label_type") }}'
tests:
- not_null
- name: LABEL_SUBTYPE
description: '{{ doc("arb_label_subtype") }}'
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: PROJECT_NAME
description: '{{ doc("arb_project_name") }}'
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: DIM_LABELS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,70 +0,0 @@
{{ config (
materialized = "incremental",
unique_key = "ez_decoded_event_logs_id",
incremental_strategy = 'delete+insert',
cluster_by = "block_timestamp::date",
incremental_predicates = [standard_predicate()],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(ez_decoded_event_logs_id, contract_name, contract_address)",
tags = ['decoded_logs']
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
{# tx_position, #} -- new column
event_index,
contract_address,
topics,
topics [0] :: STRING AS topic_0,
--new column
topics [1] :: STRING AS topic_1,
--new column
topics [2] :: STRING AS topic_2,
--new column
topics [3] :: STRING AS topic_3,
--new column
DATA,
event_removed,
origin_from_address,
origin_to_address,
origin_function_signature,
CASE
WHEN tx_status = 'SUCCESS' THEN TRUE
ELSE FALSE
END AS tx_succeeded,
event_name,
decoded_data AS full_decoded_log,
decoded_flat AS decoded_log,
token_name AS contract_name,
COALESCE (
decoded_logs_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }}
) AS ez_decoded_event_logs_id,
{% if is_incremental() %}
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
{% else %}
GREATEST(block_timestamp, dateadd('day', -10, SYSDATE())) AS inserted_timestamp,
GREATEST(block_timestamp, dateadd('day', -10, SYSDATE())) AS modified_timestamp,
{% endif %}
tx_status --deprecate
FROM
{{ ref('silver__decoded_logs') }}
l
LEFT JOIN {{ ref('silver__contracts') }} C USING (contract_address)
WHERE 1=1
{% if is_incremental() %}
AND l.modified_timestamp > (
SELECT
COALESCE(
MAX(modified_timestamp),
'2000-01-01'::TIMESTAMP
)
FROM
{{ this }}
)
{% endif %}

View File

@ -1,75 +0,0 @@
version: 2
models:
- name: core__ez_decoded_event_logs
description: >
'For information on how to submit a contract for decoding, as well as how ABIs are sourced, please visit [here](https://science.flipsidecrypto.xyz/abi-requestor/).
This model contains decoded event logs for contracts that we have an ABI for. Please note, this table does not include all event logs, only those that we have an ABI for.
The `decoded_log` column is the easiest place to query decoded data. It is a JSON object, where the keys are the names of the event parameters, and the values are the values of the event parameters.
You can select from this column using the following sample format, `decoded_log:from::string` or more generally, `decoded_log:<event_param>::datatype`. See below for a full sample query.
The `full_decoded_logs` column contains the same information, as well as additional fields such as the datatype of the decoded data. You may need to laterally flatten this column to query the data.
Sample query for USDC Transfer events:
```sql
select
tx_hash,
block_number,
contract_address,
decoded_log:from::string as from_address,
decoded_log:to::string as to_address,
decoded_log:value::integer as value
from ethereum.core.fact_decoded_event_logs
where contract_address = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')
and block_number between 16400000 and 16405000
and event_name = 'Transfer'
limit 50```'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: CONTRACT_NAME
description: "The name of the contract, if the contract has a name() function."
- name: EVENT_NAME
description: "The name of the event, as defined in the contract ABI."
- name: DECODED_LOG
description: "The flattened decoded log, where the keys are the names of the event parameters, and the values are the values of the event parameters."
- name: FULL_DECODED_LOG
description: "The full decoded log, including the event name, the event parameters, and the data type of the event parameters."
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("arb_tx_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: TOPICS
description: '{{ doc("arb_topics") }}'
- name: TOPIC_0
description: '{{ doc("evm_topic_0") }}'
- name: TOPIC_1
description: '{{ doc("evm_topic_1") }}'
- name: TOPIC_2
description: '{{ doc("evm_topic_2") }}'
- name: TOPIC_3
description: '{{ doc("evm_topic_3") }}'
- name: DATA
description: '{{ doc("arb_logs_data") }}'
- name: EVENT_REMOVED
description: '{{ doc("arb_event_removed") }}'
- name: TX_STATUS
description: '{{ doc("evm_column_deprecation_notice") }}'
- name: TX_SUCCEEDED
description: '{{ doc("arb_tx_status") }}'
- name: EZ_DECODED_EVENT_LOGS_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,27 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
tx_position,
trace_index,
from_address,
to_address,
amount,
amount_precise_raw,
amount_precise,
amount_usd,
origin_from_address,
origin_to_address,
origin_function_signature,
native_transfers_id AS ez_native_transfers_id,
inserted_timestamp,
modified_timestamp,
identifier -- deprecate
FROM
{{ ref('silver__native_transfers') }}

View File

@ -1,42 +0,0 @@
version: 2
models:
- name: core__ez_native_transfers
description: '{{ doc("evm_ez_native_transfers_table_doc") }}'
columns:
- name: TX_HASH
description: '{{ doc("arb_transfer_tx_hash") }}'
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_POSITION
description: '{{ doc("arb_tx_position") }}'
- name: TRACE_INDEX
description: '{{ doc("arb_trace_index") }}'
- name: IDENTIFIER
description: '{{ doc("evm_column_deprecation_notice_identifier") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("arb_origin_sig") }}'
- name: FROM_ADDRESS
description: '{{ doc("arb_transfer_from_address") }}'
- name: TO_ADDRESS
description: '{{ doc("arb_transfer_to_address") }}'
- name: AMOUNT
description: '{{ doc("arb_eth_amount") }}'
- name: AMOUNT_PRECISE_RAW
description: '{{ doc("precise_amount_unadjusted") }}'
- name: AMOUNT_PRECISE
description: '{{ doc("precise_amount_adjusted") }}'
- name: AMOUNT_USD
description: '{{ doc("arb_eth_amount_usd") }}'
- name: EZ_NATIVE_TRANSFERS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,49 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
contract_address,
from_address,
to_address,
raw_amount_precise,
raw_amount,
amount_precise,
amount,
amount_usd,
decimals,
symbol,
COALESCE (
transfers_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }}
) AS ez_token_transfers_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp,
token_price,
-- deprecate
has_decimal,
-- deprecate
has_price,
-- deprecate
_log_id,
-- deprecate
_inserted_timestamp -- deprecate
FROM
{{ ref('silver__transfers') }}

View File

@ -1,58 +0,0 @@
version: 2
models:
- name: core__ez_token_transfers
description: '{{ doc("evm_ez_token_transfers_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_transfer_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("arb_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_transfer_contract_address") }}'
- name: FROM_ADDRESS
description: '{{ doc("arb_transfer_from_address") }}'
- name: TO_ADDRESS
description: '{{ doc("arb_transfer_to_address") }}'
- name: RAW_AMOUNT_PRECISE
description: '{{ doc("arb_transfer_raw_amount_precise") }}'
- name: RAW_AMOUNT
description: '{{ doc("arb_transfer_raw_amount") }}'
- name: AMOUNT_PRECISE
description: '{{ doc("arb_transfer_amount_precise") }}'
- name: TOKEN_PRICE
description: '{{ doc("arb_transfer_token_price") }}'
- name: AMOUNT
description: '{{ doc("arb_transfer_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("arb_transfer_amount_usd") }}'
- name: DECIMALS
description: '{{ doc("arb_decimals") }}'
- name: SYMBOL
description: '{{ doc("arb_symbol") }}'
- name: TOKEN_PRICE
description: '{{ doc("evm_column_deprecation_notice_token_price") }}'
- name: HAS_DECIMAL
description: '{{ doc("evm_column_deprecation_notice_has_decimal") }}'
- name: HAS_PRICE
description: '{{ doc("evm_column_deprecation_notice_has_price") }}'
- name: _LOG_ID
description: '{{ doc("evm_column_deprecation_notice_log_id") }}'
- name: _INSERTED_TIMESTAMP
description: '{{ doc("evm_column_deprecation_notice_inserted_timestamp") }}'
- name: EZ_TOKEN_TRANSFERS_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -1,101 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
HASH AS block_hash, --new column
block_timestamp,
'mainnet' AS network,
tx_count,
SIZE,
miner, --new
extra_data,
parent_hash,
gas_used,
gas_limit,
base_fee_per_gas, --new column
difficulty,
total_difficulty,
sha3_uncles,
uncles AS uncle_blocks,
nonce,-- new column
receipts_root,
state_root, -- new column
transactions_root, -- new column
logs_bloom, -- new column
COALESCE (
blocks_id,
{{ dbt_utils.generate_surrogate_key(
['a.block_number']
) }}
) AS fact_blocks_id,
GREATEST(
COALESCE(
A.inserted_timestamp,
'2000-01-01'
),
COALESCE(
d.inserted_timestamp,
'2000-01-01'
)
) AS inserted_timestamp,
GREATEST(
COALESCE(
A.modified_timestamp,
'2000-01-01'
),
COALESCE(
d.modified_timestamp,
'2000-01-01'
)
) AS modified_timestamp,
'arbitrum' AS blockchain, -- deprecate
hash, --deprecate
OBJECT_CONSTRUCT(
'baseFeePerGas',
base_fee_per_gas,
'difficulty',
difficulty,
'extraData',
extra_data,
'gasLimit',
gas_limit,
'gasUsed',
gas_used,
'hash',
HASH,
'logsBloom',
logs_bloom,
'miner',
miner,
'nonce',
nonce,
'number',
NUMBER,
'parentHash',
parent_hash,
'receiptsRoot',
receipts_root,
'sha3Uncles',
sha3_uncles,
'size',
SIZE,
'stateRoot',
state_root,
'timestamp',
block_timestamp,
'totalDifficulty',
total_difficulty,
'transactionsRoot',
transactions_root,
'uncles',
uncles
) AS block_header_json -- deprecate
FROM
{{ ref('silver__blocks') }} A
LEFT JOIN {{ ref('silver__tx_count') }}
d USING (block_number)

View File

@ -1,62 +0,0 @@
version: 2
models:
- name: core__fact_blocks
description: '{{ doc("evm_blocks_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("evm_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("evm_block_timestamp") }}'
- name: NETWORK
description: '{{ doc("evm_network") }}'
- name: BLOCKCHAIN
description: '{{ doc("evm_column_deprecation_notice_blockchain") }}'
- name: MINER
description: '{{ doc("evm_miner") }}'
- name: NONCE
description: '{{ doc("evm_blocks_nonce") }}'
- name: TX_COUNT
description: '{{ doc("evm_tx_count") }}'
- name: DIFFICULTY
description: '{{ doc("evm_difficulty") }}'
- name: TOTAL_DIFFICULTY
description: '{{ doc("evm_total_difficulty") }}'
- name: EXTRA_DATA
description: '{{ doc("evm_extra_data") }}'
- name: GAS_LIMIT
description: '{{ doc("evm_gas_limit") }}'
- name: GAS_USED
description: '{{ doc("evm_gas_used") }}'
- name: BASE_FEE_PER_GAS
description: '{{ doc("evm_base_fee_per_gas") }}'
- name: BLOCK_HASH
description: '{{ doc("evm_blocks_hash") }}'
- name: HASH
description: '{{ doc("evm_column_deprecation_notice_hash") }}'
- name: PARENT_HASH
description: '{{ doc("evm_parent_hash") }}'
- name: RECEIPTS_ROOT
description: '{{ doc("evm_receipts_root") }}'
- name: SHA3_UNCLES
description: '{{ doc("evm_sha3_uncles") }}'
- name: SIZE
description: '{{ doc("evm_size") }}'
- name: UNCLE_BLOCKS
description: '{{ doc("evm_uncle_blocks") }}'
- name: STATE_ROOT
description: '{{ doc("evm_state_root") }}'
- name: TRANSACTIONS_ROOT
description: '{{ doc("evm_transactions_root") }}'
- name: LOGS_BLOOM
description: '{{ doc("evm_logs_bloom") }}'
- name: BLOCK_HEADER_JSON
description: '{{ doc("evm_column_deprecation_notice_block_header_json") }}'
- name: BASE_FEE_PER_GAS
description: '{{ doc("evm_base_fee_per_gas") }}'
- name: FACT_BLOCKS_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -1,31 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
event_index,
contract_address,
event_name,
decoded_flat AS decoded_log,
decoded_data AS full_decoded_log,
COALESCE (
decoded_logs_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }}
) AS fact_decoded_event_logs_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
FROM
{{ ref('silver__decoded_logs') }}

View File

@ -1,28 +0,0 @@
version: 2
models:
- name: core__fact_decoded_event_logs
description: '{{ doc("evm_table_deprecation_notice_fact_decoded_event_logs") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: EVENT_NAME
description: "The name of the event, as defined in the contract ABI."
- name: DECODED_LOG
description: "The flattened decoded log, where the keys are the names of the event parameters, and the values are the values of the event parameters."
- name: FULL_DECODED_LOG
description: "The full decoded log, including the event name, the event parameters, and the data type of the event parameters."
- name: FACT_DECODED_EVENT_LOGS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,51 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
{# tx_position, -- new column #}
event_index,
contract_address,
topics,
topics [0] :: STRING AS topic_0,
--new column
topics [1] :: STRING AS topic_1,
--new column
topics [2] :: STRING AS topic_2,
--new column
topics [3] :: STRING AS topic_3,
--new column
DATA,
event_removed,
origin_from_address,
origin_to_address,
origin_function_signature,
CASE
WHEN tx_status = 'SUCCESS' THEN TRUE
ELSE FALSE
END AS tx_succeeded,
-- new column
COALESCE (
logs_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }}
) AS fact_event_logs_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp,
tx_status,
-- deprecate
_log_id -- deprecate
FROM
{{ ref('silver__logs') }}

View File

@ -1,48 +0,0 @@
version: 2
models:
- name: core__fact_event_logs
description: '{{ doc("evm_logs_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("evm_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("evm_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("evm_logs_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("evm_event_index") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("evm_logs_contract_address") }}'
- name: TOPICS
description: '{{ doc("evm_topics") }}'
- name: TOPIC_0
description: '{{ doc("evm_topic_0") }}'
- name: TOPIC_1
description: '{{ doc("evm_topic_1") }}'
- name: TOPIC_2
description: '{{ doc("evm_topic_2") }}'
- name: TOPIC_3
description: '{{ doc("evm_topic_3") }}'
- name: DATA
description: '{{ doc("evm_logs_data") }}'
- name: EVENT_REMOVED
description: '{{ doc("evm_event_removed") }}'
- name: _LOG_ID
description: '{{ doc("evm_column_deprecation_notice_log_id") }}'
- name: TX_STATUS
description: '{{ doc("evm_column_deprecation_notice_tx_status") }}'
- name: TX_SUCCEEDED
description: '{{ doc("evm_tx_succeeded") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("evm_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("evm_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("evm_origin_to") }}'
- name: FACT_EVENT_LOGS_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -1,36 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
contract_address,
from_address,
to_address,
raw_amount,
raw_amount_precise,
_log_id,
COALESCE (
transfers_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }}
) AS fact_token_transfers_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
FROM
{{ ref('silver__transfers') }}

View File

@ -1,38 +0,0 @@
version: 2
models:
- name: core__fact_token_transfers
description: '{{ doc("evm_table_deprecation_notice_fact_token_transfers") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_transfer_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("arb_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_transfer_contract_address") }}'
- name: FROM_ADDRESS
description: '{{ doc("arb_transfer_from_address") }}'
- name: TO_ADDRESS
description: '{{ doc("arb_transfer_to_address") }}'
- name: RAW_AMOUNT
description: '{{ doc("arb_transfer_raw_amount") }}'
- name: RAW_AMOUNT_PRECISE
description: '{{ doc("arb_transfer_raw_amount_precise") }}'
- name: _LOG_ID
description: '{{ doc("internal_column") }}'
- name: FACT_TOKEN_TRANSFERS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,628 +0,0 @@
{{ config (
materialized = "incremental",
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = "block_timestamp::date",
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
tags = ['core','non_realtime'],
incremental_predicates = [fsc_evm.standard_predicate()],
full_refresh = false
) }}
{# {{ fsc_evm.gold_traces_v1(
full_reload_start_block = 30000000,
full_reload_blocks = 10000000,
arb_traces_mode = TRUE
) }}
#}
WITH silver_traces AS (
SELECT
block_number,
tx_position,
trace_address,
parent_trace_address,
trace_address_array,
trace_json,
traces_id,
'regular' AS source
FROM
{{ ref('silver__traces') }}
WHERE
1 = 1
{% if is_incremental() and not full_reload_mode %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
) {% elif is_incremental() and full_reload_mode %}
AND block_number BETWEEN (
SELECT
MAX(
block_number
)
FROM
{{ this }}
)
AND (
SELECT
MAX(
block_number
) + 10000000
FROM
{{ this }}
)
{% else %}
AND block_number <= 30000000
{% endif %}
UNION ALL
SELECT
block_number,
tx_position,
trace_address,
parent_trace_address,
IFF(
trace_address = 'ORIGIN',
ARRAY_CONSTRUCT('ORIGIN'),
trace_address_array
) AS trace_address_array,
trace_json,
traces_id,
'arb_traces' AS source
FROM
{{ ref('silver__arb_traces') }}
WHERE
1 = 1
{% if is_incremental() and not full_reload_mode %}
AND modified_timestamp > (
SELECT
DATEADD('hour', -2, MAX(modified_timestamp))
FROM
{{ this }}) {% elif is_incremental() and full_reload_mode %}
AND block_number BETWEEN (
SELECT
MAX(
block_number
)
FROM
{{ this }}
)
AND (
SELECT
MAX(
block_number
) + 10000000
FROM
{{ this }}
)
{% else %}
AND block_number <= 30000000
{% endif %}
),
sub_traces AS (
SELECT
block_number,
tx_position,
parent_trace_address,
COUNT(*) AS sub_traces
FROM
silver_traces
GROUP BY
block_number,
tx_position,
parent_trace_address
),
trace_index_array AS (
SELECT
block_number,
tx_position,
trace_address,
ARRAY_AGG(flat_value) AS number_array
FROM
(
SELECT
block_number,
tx_position,
trace_address,
IFF(
VALUE :: STRING = 'ORIGIN',
-1,
VALUE :: INT
) AS flat_value
FROM
silver_traces,
LATERAL FLATTEN (
input => trace_address_array
)
)
GROUP BY
block_number,
tx_position,
trace_address
),
trace_index_sub_traces AS (
SELECT
b.block_number,
b.tx_position,
b.trace_address,
IFNULL(
sub_traces,
0
) AS sub_traces,
number_array,
ROW_NUMBER() over (
PARTITION BY b.block_number,
b.tx_position
ORDER BY
number_array ASC
) - 1 AS trace_index,
b.trace_json,
b.traces_id,
b.source
FROM
silver_traces b
LEFT JOIN sub_traces s
ON b.block_number = s.block_number
AND b.tx_position = s.tx_position
AND b.trace_address = s.parent_trace_address
JOIN trace_index_array n
ON b.block_number = n.block_number
AND b.tx_position = n.tx_position
AND b.trace_address = n.trace_address
),
errored_traces AS (
SELECT
block_number,
tx_position,
trace_address,
trace_json
FROM
trace_index_sub_traces
WHERE
trace_json :error :: STRING IS NOT NULL
),
error_logic AS (
SELECT
b0.block_number,
b0.tx_position,
b0.trace_address,
b0.trace_json :error :: STRING AS error,
b1.trace_json :error :: STRING AS any_error,
b2.trace_json :error :: STRING AS origin_error
FROM
trace_index_sub_traces b0
LEFT JOIN errored_traces b1
ON b0.block_number = b1.block_number
AND b0.tx_position = b1.tx_position
AND b0.trace_address RLIKE CONCAT(
'^',
b1.trace_address,
'(_[0-9]+)*$'
)
LEFT JOIN errored_traces b2
ON b0.block_number = b2.block_number
AND b0.tx_position = b2.tx_position
AND b2.trace_address = 'ORIGIN'
),
aggregated_errors AS (
SELECT
block_number,
tx_position,
trace_address,
error,
IFF(MAX(any_error) IS NULL
AND error IS NULL
AND origin_error IS NULL, TRUE, FALSE) AS trace_succeeded
FROM
error_logic
GROUP BY
block_number,
tx_position,
trace_address,
error,
origin_error),
json_traces AS (
SELECT
block_number,
tx_position,
trace_address,
sub_traces,
number_array,
trace_index,
trace_json AS DATA,
trace_succeeded,
trace_json :error :: STRING AS error_reason,
trace_json :revertReason :: STRING AS revert_reason,
trace_json :from :: STRING AS from_address,
trace_json :to :: STRING AS to_address,
IFNULL(
trace_json :value :: STRING,
'0x0'
) AS value_hex,
IFNULL(
utils.udf_hex_to_int(
trace_json :value :: STRING
),
'0'
) AS value_precise_raw,
utils.udf_decimal_adjust(
value_precise_raw,
18
) AS value_precise,
value_precise :: FLOAT AS VALUE,
utils.udf_hex_to_int(
trace_json :gas :: STRING
) :: INT AS gas,
utils.udf_hex_to_int(
trace_json :gasUsed :: STRING
) :: INT AS gas_used,
trace_json :input :: STRING AS input,
trace_json :output :: STRING AS output,
trace_json :type :: STRING AS TYPE,
concat_ws(
'_',
TYPE,
trace_address
) AS identifier,
IFF(
trace_succeeded,
'SUCCESS',
'FAIL'
) AS trace_status,
traces_id,
trace_json :afterEVMTransfers AS after_evm_transfers,
trace_json :beforeEVMTransfers AS before_evm_transfers
FROM
trace_index_sub_traces t0
JOIN aggregated_errors USING (
block_number,
tx_position,
trace_address
)
WHERE
t0.source <> 'arb_traces'
UNION ALL
SELECT
block_number,
tx_position,
trace_address,
sub_traces,
number_array,
trace_index,
trace_json AS DATA,
trace_succeeded,
trace_json :error :: STRING AS error_reason,
NULL AS revert_reason,
trace_json :action :from :: STRING AS from_address,
COALESCE(
trace_json :action :to :: STRING,
trace_json :result :address :: STRING
) AS to_address,
IFNULL(
trace_json :action :value :: STRING,
'0x0'
) AS value_hex,
IFNULL(
utils.udf_hex_to_int(
trace_json :action :value :: STRING
),
'0'
) AS value_precise_raw,
utils.udf_decimal_adjust(
value_precise_raw,
18
) AS value_precise,
value_precise :: FLOAT AS VALUE,
utils.udf_hex_to_int(
trace_json :action :gas :: STRING
) :: INT AS gas,
IFNULL(
utils.udf_hex_to_int(
trace_json :result :gasUsed :: STRING
),
0
) :: INT AS gas_used,
COALESCE(
trace_json :action :input :: STRING,
trace_json :action :init :: STRING
) AS input,
COALESCE(
trace_json :result :output :: STRING,
trace_json :result :code :: STRING
) AS output,
UPPER(
COALESCE(
trace_json :action :callType :: STRING,
trace_json :type :: STRING
)
) AS TYPE,
concat_ws(
'_',
TYPE,
trace_address
) AS identifier,
IFF(
trace_succeeded,
'SUCCESS',
'FAIL'
) AS trace_status,
traces_id,
NULL AS after_evm_transfers,
NULL AS before_evm_transfers
FROM
trace_index_sub_traces t0
JOIN aggregated_errors USING (
block_number,
tx_position,
trace_address
)
WHERE
t0.source = 'arb_traces'
),
incremental_traces AS (
SELECT
f.block_number,
t.tx_hash,
t.block_timestamp,
t.origin_function_signature,
t.from_address AS origin_from_address,
t.to_address AS origin_to_address,
t.tx_status,
f.tx_position,
f.trace_index,
f.from_address AS from_address,
f.to_address AS to_address,
f.value_hex,
f.value_precise_raw,
f.value_precise,
f.value,
f.gas,
f.gas_used,
f.input,
f.output,
f.type,
f.identifier,
f.sub_traces,
f.error_reason,
f.revert_reason,
f.trace_status,
f.data,
f.traces_id,
f.trace_succeeded,
f.trace_address,
IFF(
t.tx_status = 'SUCCESS',
TRUE,
FALSE
) AS tx_succeeded,
f.before_evm_transfers,
f.after_evm_transfers
FROM
json_traces f
LEFT OUTER JOIN {{ ref('silver__transactions') }}
t
ON f.tx_position = t.position
AND f.block_number = t.block_number
{% if is_incremental() and not full_reload_mode %}
AND t.modified_timestamp >= (
SELECT
DATEADD('hour', -24, MAX(modified_timestamp))
FROM
{{ this }})
{% endif %}
)
{% if is_incremental() %},
overflow_blocks AS (
SELECT
DISTINCT block_number
FROM
silver_traces
WHERE
source = 'overflow'
),
heal_missing_data AS (
SELECT
t.block_number,
txs.tx_hash,
txs.block_timestamp,
txs.origin_function_signature,
txs.from_address AS origin_from_address,
txs.to_address AS origin_to_address,
txs.tx_status,
t.tx_position,
t.trace_index,
t.from_address,
t.to_address,
t.value_hex,
t.value_precise_raw,
t.value_precise,
t.value,
t.gas,
t.gas_used,
t.input,
t.output,
t.type,
t.identifier,
t.sub_traces,
t.error_reason,
t.revert_reason,
t.trace_status,
t.data,
t.fact_traces_id AS traces_id,
t.trace_succeeded,
t.trace_address,
IFF(
txs.tx_status = 'SUCCESS',
TRUE,
FALSE
) AS tx_succeeded,
t.before_evm_transfers,
t.after_evm_transfers
FROM
{{ this }}
t
JOIN {{ ref('silver__transactions') }}
txs
ON t.tx_position = txs.position
AND t.block_number = txs.block_number
WHERE
t.tx_hash IS NULL
OR t.block_timestamp IS NULL
OR t.tx_status IS NULL
)
{% endif %},
all_traces AS (
SELECT
block_number,
tx_hash,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
tx_status,
tx_position,
trace_index,
from_address,
to_address,
value_hex,
value_precise_raw,
value_precise,
VALUE,
gas,
gas_used,
input,
output,
TYPE,
identifier,
sub_traces,
error_reason,
revert_reason,
trace_status,
DATA,
trace_succeeded,
trace_address,
tx_succeeded,
before_evm_transfers,
after_evm_transfers
FROM
incremental_traces
UNION ALL
SELECT
block_number,
tx_hash,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
tx_status,
tx_position,
trace_index,
from_address,
to_address,
value_hex,
value_precise_raw,
value_precise,
VALUE,
gas,
gas_used,
input,
output,
TYPE,
identifier,
sub_traces,
error_reason,
revert_reason,
trace_status,
DATA,
trace_succeeded,
trace_address,
tx_succeeded,
before_evm_transfers,
after_evm_transfers
FROM
heal_missing_data
UNION ALL
SELECT
block_number,
tx_hash,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
tx_status,
tx_position,
trace_index,
from_address,
to_address,
value_hex,
value_precise_raw,
value_precise,
VALUE,
gas,
gas_used,
input,
output,
TYPE,
identifier,
sub_traces,
error_reason,
revert_reason,
trace_status,
DATA,
trace_succeeded,
trace_address,
tx_succeeded,
before_evm_transfers,
after_evm_transfers
FROM
{{ this }}
JOIN overflow_blocks USING (block_number)
)
SELECT
block_number,
block_timestamp,
tx_hash,
tx_position,
trace_index,
from_address,
to_address,
input,
output,
TYPE,
trace_address,
sub_traces,
VALUE,
value_precise_raw,
value_precise,
value_hex,
gas,
gas_used,
origin_from_address,
origin_to_address,
origin_function_signature,
before_evm_transfers,
after_evm_transfers,
trace_succeeded,
error_reason,
revert_reason,
tx_succeeded,
identifier,
--deprecate
DATA,
--deprecate
tx_status,
--deprecate
trace_status, --deprecate
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'trace_index']
) }} AS fact_traces_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp
FROM
all_traces qualify(ROW_NUMBER() over(PARTITION BY block_number, tx_position, trace_index
ORDER BY
modified_timestamp DESC, block_timestamp DESC nulls last)) = 1

View File

@ -1,68 +0,0 @@
version: 2
models:
- name: core__fact_traces
description: '{{ doc("evm_traces_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("evm_traces_block_no") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("evm_traces_blocktime") }}'
- name: TX_HASH
description: '{{ doc("evm_traces_tx_hash") }}'
- name: TX_POSITION
description: '{{ doc("evm_tx_position") }}'
- name: FROM_ADDRESS
description: '{{ doc("evm_traces_from") }}'
- name: TO_ADDRESS
description: '{{ doc("evm_traces_to") }}'
- name: VALUE
description: '{{ doc("evm_traces_value") }}'
- name: VALUE_PRECISE_RAW
description: '{{ doc("evm_precise_amount_unadjusted") }}'
- name: VALUE_PRECISE
description: '{{ doc("evm_precise_amount_adjusted") }}'
- name: VALUE_HEX
description: '{{ doc("evm_value_hex") }}'
- name: GAS
description: '{{ doc("evm_traces_gas") }}'
- name: GAS_USED
description: '{{ doc("evm_traces_gas_used") }}'
- name: INPUT
description: '{{ doc("evm_traces_input") }}'
- name: OUTPUT
description: '{{ doc("evm_traces_output") }}'
- name: TYPE
description: '{{ doc("evm_traces_type") }}'
- name: IDENTIFIER
description: '{{ doc("evm_column_deprecation_notice_identifier") }}'
- name: TRACE_ADDRESS
description: '{{ doc("evm_trace_address") }}'
- name: DATA
description: '{{ doc("evm_column_deprecation_notice_data") }}'
- name: TX_STATUS
description: '{{ doc("evm_column_deprecation_notice_tx_status") }}'
- name: TX_SUCCEEDED
description: '{{ doc("evm_tx_succeeded") }}'
- name: TRACE_SUCCEEDED
description: '{{ doc("evm_trace_succeeded") }}'
- name: SUB_TRACES
description: '{{ doc("evm_sub_traces") }}'
- name: TRACE_STATUS
description: '{{ doc("evm_column_deprecation_notice_trace_status") }}'
- name: ERROR_REASON
description: '{{ doc("evm_trace_error_reason") }}'
- name: REVERT_REASON
description: '{{ doc("evm_revert_reason") }}'
- name: TRACE_INDEX
description: The index of the trace within the transaction.
- name: BEFORE_EVM_TRANSFERS
description: The state of all ETH transfers to be executed for a given transaction.
- name: AFTER_EVM_TRANSFERS
description: The state of all ETH transfers executed for a given transaction.
- name: FACT_TRACES_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -1,61 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
from_address,
to_address,
origin_function_signature,
VALUE,
value_precise_raw,
value_precise,
tx_fee,
tx_fee_precise,
CASE
WHEN tx_status = 'SUCCESS' THEN TRUE
ELSE FALSE
END AS tx_succeeded,
-- new column
tx_type,
nonce,
POSITION AS tx_position,
-- new
input_data,
gas_price AS gas_price_bid,
effective_gas_price AS gas_price_paid,
gas AS gas_limit,
gas_used,
cumulative_gas_used,
max_fee_per_gas,
max_priority_fee_per_gas,
l1_block_number,
gas_used_for_l1,
r,
s,
v,
COALESCE (
transactions_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash']
) }}
) AS fact_transactions_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp,
block_hash,
-- deprecate
tx_status AS status,
-- deprecate
POSITION -- deprecate
FROM
{{ ref('silver__transactions') }}

View File

@ -1,74 +0,0 @@
version: 2
models:
- name: core__fact_transactions
description: '{{ doc("evm_tx_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("evm_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("evm_block_timestamp") }}'
- name: BLOCK_HASH
description: '{{ doc("evm_column_deprecation_notice_block_hash") }}'
- name: TX_HASH
description: '{{ doc("evm_tx_hash") }}'
- name: NONCE
description: '{{ doc("evm_tx_nonce") }}'
- name: POSITION
description: '{{ doc("evm_column_deprecation_notice_position") }}'
- name: TX_POSITION
description: '{{ doc("evm_tx_position") }}'
- name: FROM_ADDRESS
description: '{{ doc("evm_from_address") }}'
- name: TO_ADDRESS
description: '{{ doc("evm_to_address") }}'
- name: VALUE
description: '{{ doc("evm_value") }}'
- name: VALUE_PRECISE_RAW
description: '{{ doc("precise_amount_unadjusted") }}'
- name: VALUE_PRECISE
description: '{{ doc("precise_amount_adjusted") }}'
- name: TX_FEE
description: '{{ doc("evm_tx_fee") }}'
- name: TX_FEE_PRECISE
description: '{{ doc("tx_fee_precise") }}'
- name: GAS_PRICE_BID
description: '{{ doc("arb_tx_gas_bid") }}'
- name: GAS_PRICE_PAID
description: '{{ doc("arb_tx_gas_paid") }}'
- name: GAS_LIMIT
description: '{{ doc("arb_tx_gas_limit") }}'
- name: GAS_USED
description: '{{ doc("arb_tx_gas_used") }}'
- name: CUMULATIVE_GAS_USED
description: '{{ doc("arb_cumulative_gas_used") }}'
- name: MAX_FEE_PER_GAS
description: The maximum fee per gas of the transaction, in Gwei.
- name: MAX_PRIORITY_FEE_PER_GAS
description: The maximum priority fee per gas of the transaction, in Gwei.
- name: STATUS
description: '{{ doc("evm_column_deprecation_notice_tx_status") }}'
- name: TX_SUCCEEDED
description: '{{ doc("evm_tx_succeeded") }}'
- name: INPUT_DATA
description: '{{ doc("evm_tx_input_data") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("evm_tx_origin_sig") }}'
- name: TX_TYPE
description: The type of the transaction, 2 for EIP-1559 transactions and 0 for legacy transactions.
- name: r
description: The r value of the transaction signature.
- name: s
description: The s value of the transaction signature.
- name: v
description: The v value of the transaction signature.
- name: L1_BLOCK_NUMBER
description: The block number of the transaction on Ethereum Mainnet.
- name: GAS_USED_FOR_L1
description: The gas used by the transaction on Ethereum Mainnet.
- name: FACT_TRANSACTIONS_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -1,9 +0,0 @@
{{ config (
materialized = "view",
tags = ['full_test']
) }}
SELECT
*
FROM
{{ ref('core__fact_traces') }}

View File

@ -1,120 +0,0 @@
version: 2
models:
- name: test_gold__fact_traces_full
description: "This is a view used to test all of the gold fact traces model."
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- TX_HASH
- TRACE_INDEX
- fsc_utils.sequence_gaps:
partition_by:
- TX_HASH
column_name: TRACE_INDEX
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1 AND TX_HASH IS NOT NULL
columns:
- name: BLOCK_NUMBER
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: BLOCK_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_LTZ
- TIMESTAMP_NTZ
- name: TX_HASH
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TX_POSITION
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: TRACE_INDEX
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: FROM_ADDRESS
tests:
- not_null:
where: TYPE <> 'SELFDESTRUCT'
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TO_ADDRESS
tests:
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
where: TO_ADDRESS IS NOT NULL
- name: INPUT
tests:
- not_null
- name: TYPE
tests:
- not_null
- name: TRACE_ADDRESS
tests:
- not_null
- name: SUB_TRACES
tests:
- not_null
- name: VALUE
tests:
- not_null
- name: VALUE_PRECISE_RAW
tests:
- not_null
- name: VALUE_PRECISE
tests:
- not_null
- name: VALUE_HEX
tests:
- not_null
- name: GAS
tests:
- not_null
- name: GAS_USED
tests:
- not_null
- name: ORIGIN_FROM_ADDRESS
tests:
- not_null
- name: ORIGIN_FUNCTION_SIGNATURE
tests:
- not_null
- name: TRACE_SUCCEEDED
tests:
- not_null
- name: TX_SUCCEEDED
tests:
- not_null
- name: FACT_TRACES_ID
tests:
- not_null
- name: INSERTED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2
- name: MODIFIED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2

View File

@ -1,16 +0,0 @@
{{ config (
materialized = "view",
tags = ['recent_test']
) }}
SELECT
*
FROM
{{ ref('core__fact_traces') }}
WHERE
block_number > (
SELECT
block_number
FROM
{{ ref('_block_lookback') }}
)

View File

@ -1,120 +0,0 @@
version: 2
models:
- name: test_gold__fact_traces_recent
description: "This is a view used to test the last three days of fact traces."
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- TX_HASH
- TRACE_INDEX
- fsc_utils.sequence_gaps:
partition_by:
- TX_HASH
column_name: TRACE_INDEX
where: TX_HASH IS NOT NULL
columns:
- name: BLOCK_NUMBER
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: BLOCK_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_LTZ
- TIMESTAMP_NTZ
- name: TX_HASH
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TX_POSITION
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: TRACE_INDEX
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: FROM_ADDRESS
tests:
- not_null:
where: TYPE <> 'SELFDESTRUCT'
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TO_ADDRESS
tests:
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
where: TO_ADDRESS IS NOT NULL
- name: INPUT
tests:
- not_null
- name: TYPE
tests:
- not_null
- name: TRACE_ADDRESS
tests:
- not_null
- name: SUB_TRACES
tests:
- not_null
- name: VALUE
tests:
- not_null
- name: VALUE_PRECISE_RAW
tests:
- not_null
- name: VALUE_PRECISE
tests:
- not_null
- name: VALUE_HEX
tests:
- not_null
- name: GAS
tests:
- not_null
- name: GAS_USED
tests:
- not_null
- name: ORIGIN_FROM_ADDRESS
tests:
- not_null
- name: ORIGIN_FUNCTION_SIGNATURE
tests:
- not_null
- name: TRACE_SUCCEEDED
tests:
- not_null
- name: TX_SUCCEEDED
tests:
- not_null
- name: FACT_TRACES_ID
tests:
- not_null
- name: INSERTED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2
- name: MODIFIED_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: hour
interval: 2

View File

@ -1,60 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'NFT'
}
}
}
) }}
SELECT
block_timestamp,
block_number,
tx_hash,
{#tx_position, -- new #}
event_index,
intra_event_index,
token_transfer_type,
iff(from_address = '0x0000000000000000000000000000000000000000', TRUE, FALSE) AS is_mint, -- new
from_address, --new
to_address, --new
contract_address, --new
tokenId as token_id, --new
COALESCE(
erc1155_value,
'1'
) :: STRING AS quantity, --new
CASE
WHEN token_transfer_type = 'erc721_Transfer' THEN 'erc721'
WHEN token_transfer_type = 'erc1155_TransferSingle' THEN 'erc1155'
WHEN token_transfer_type = 'erc1155_TransferBatch' THEN 'erc1155'
END AS token_standard, --new
project_name as name, --new
{#origin_function_signature, --new
origin_from_address, --new
origin_to_address, #} -- new
COALESCE (
nft_transfers_id,
{{ dbt_utils.generate_surrogate_key(
['tx_hash','event_index','intra_event_index']
) }}
) AS ez_nft_transfers_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp,
event_type, -- deprecate
from_address AS nft_from_address, -- deprecate
to_address AS nft_to_address, -- deprecate
contract_address AS nft_address, --deprecate
tokenId, -- deprecate
erc1155_value, --deprecate
project_name --deprecate
FROM
{{ ref('silver__nft_transfers') }}

View File

@ -1,50 +0,0 @@
version: 2
models:
- name: nft__ez_nft_transfers
description: '{{ doc("evm_ez_nft_transfer_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("nft_block_no") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("nft_blocktime") }}'
- name: TX_HASH
description: '{{ doc("nft_tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("nft_event_index") }}'
- name: INTRA_EVENT_INDEX
description: '{{ doc("nft_intra_event_index") }}'
- name: EVENT_TYPE
description: '{{ doc("evm_column_deprecation_notice_event_type") }}'
- name: NFT_ADDRESS
description: '{{ doc("evm_column_deprecation_notice_nft_address") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("nft_nft_address") }}'
- name: NAME
description: '{{ doc("evm_nft_project_name") }}'
- name: PROJECT_NAME
description: '{{ doc("evm_column_deprecation_notice_project_name") }}'
- name: NFT_FROM_ADDRESS
description: '{{ doc("evm_column_deprecation_notice_nft_from_address") }}'
- name: FROM_ADDRESS
description: '{{ doc("nft_nft_from_address") }}'
- name: NFT_TO_ADDRESS
description: '{{ doc("evm_column_deprecation_notice_nft_to_address") }}'
- name: TO_ADDRESS
description: '{{ doc("nft_nft_to_address") }}'
- name: TOKENID
description: '{{ doc("evm_column_deprecation_notice_tokenid") }}'
- name: TOKEN_ID
description: '{{ doc("nft_tokenid") }}'
- name: ERC1155_VALUE
description: '{{ doc("evm_column_deprecation_notice_erc1155_value") }}'
- name: QUANTITY
description: '{{ doc("evm_nft_quantity") }}'
- name: TOKEN_STANDARD
description: '{{ doc("evm_nft_token_standard") }}'
- name: EZ_NFT_TRANSFERS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,19 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
token_address,
asset_id,
symbol,
name,
platform AS blockchain,
platform_id AS blockchain_id,
provider,
inserted_timestamp,
modified_timestamp,
complete_provider_asset_metadata_id AS dim_asset_metadata_id
FROM
{{ ref('silver__complete_provider_asset_metadata') }}

View File

@ -1,26 +0,0 @@
version: 2
models:
- name: price__dim_asset_metadata
description: '{{ doc("prices_dim_asset_metadata_table_doc") }}'
columns:
- name: PROVIDER
description: '{{ doc("prices_provider")}}'
- name: ASSET_ID
description: '{{ doc("prices_asset_id") }}'
- name: NAME
description: '{{ doc("prices_name") }}'
- name: SYMBOL
description: '{{ doc("prices_symbol") }}'
- name: TOKEN_ADDRESS
description: '{{ doc("prices_token_address_evm") }}'
- name: BLOCKCHAIN
description: '{{ doc("prices_blockchain") }}'
- name: BLOCKCHAIN_ID
description: '{{ doc("prices_blockchain_id") }}'
- name: DIM_ASSET_METADATA_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,35 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
FALSE AS is_native,
is_deprecated,
inserted_timestamp,
modified_timestamp,
complete_token_asset_metadata_id AS ez_asset_metadata_id
FROM
{{ ref('silver__complete_token_asset_metadata') }}
UNION ALL
SELECT
NULL AS token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
TRUE AS is_native,
is_deprecated,
inserted_timestamp,
modified_timestamp,
complete_native_asset_metadata_id AS ez_asset_metadata_id
FROM
{{ ref('silver__complete_native_asset_metadata') }}

View File

@ -1,29 +0,0 @@
version: 2
models:
- name: price__ez_asset_metadata
description: '{{ doc("prices_ez_asset_metadata_table_doc") }}'
columns:
- name: ASSET_ID
description: '{{ doc("prices_asset_id") }}'
- name: NAME
description: '{{ doc("prices_name") }}'
- name: SYMBOL
description: '{{ doc("prices_symbol") }}'
- name: TOKEN_ADDRESS
description: '{{ doc("prices_token_address_evm") }}'
- name: BLOCKCHAIN
description: '{{ doc("prices_blockchain") }}'
- name: DECIMALS
description: '{{ doc("prices_decimals") }}'
- name: IS_NATIVE
description: '{{ doc("prices_is_native") }}'
- name: IS_DEPRECATED
description: '{{ doc("prices_is_deprecated") }}'
- name: EZ_ASSET_METADATA_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,39 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
HOUR,
token_address,
symbol,
NAME,
decimals,
price,
blockchain,
FALSE AS is_native,
is_imputed,
is_deprecated,
inserted_timestamp,
modified_timestamp,
complete_token_prices_id AS ez_prices_hourly_id
FROM
{{ ref('silver__complete_token_prices') }}
UNION ALL
SELECT
HOUR,
NULL AS token_address,
symbol,
NAME,
decimals,
price,
blockchain,
TRUE AS is_native,
is_imputed,
is_deprecated,
inserted_timestamp,
modified_timestamp,
complete_native_prices_id AS ez_prices_hourly_id
FROM
{{ ref('silver__complete_native_prices') }}

View File

@ -1,30 +0,0 @@
version: 2
models:
- name: price__ez_prices_hourly
description: '{{ doc("prices_ez_prices_hourly_table_doc") }}'
columns:
- name: HOUR
description: '{{ doc("prices_hour")}}'
- name: TOKEN_ADDRESS
description: '{{ doc("prices_token_address_evm") }}'
- name: SYMBOL
description: '{{ doc("prices_symbol") }}'
- name: BLOCKCHAIN
description: '{{ doc("prices_blockchain") }}'
- name: DECIMALS
description: '{{ doc("prices_decimals") }}'
- name: PRICE
description: '{{ doc("prices_price") }}'
- name: IS_NATIVE
description: '{{ doc("prices_is_native") }}'
- name: IS_IMPUTED
description: '{{ doc("prices_is_imputed") }}'
- name: IS_DEPRECATED
description: '{{ doc("prices_is_deprecated") }}'
- name: EZ_PRICES_HOURLY_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,19 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
asset_id,
recorded_hour AS HOUR,
OPEN,
high,
low,
CLOSE,
provider,
inserted_timestamp,
modified_timestamp,
complete_provider_prices_id AS fact_prices_ohlc_hourly_id
FROM
{{ ref('silver__complete_provider_prices') }}

View File

@ -1,24 +0,0 @@
version: 2
models:
- name: price__fact_prices_ohlc_hourly
description: '{{ doc("prices_fact_prices_ohlc_hourly_table_doc") }}'
columns:
- name: HOUR
description: '{{ doc("prices_hour")}}'
- name: ASSET_ID
description: '{{ doc("prices_asset_id") }}'
- name: OPEN
description: '{{ doc("prices_open") }}'
- name: HIGH
description: '{{ doc("prices_high") }}'
- name: LOW
description: '{{ doc("prices_low") }}'
- name: CLOSE
description: '{{ doc("prices_close") }}'
- name: FACT_PRICES_OHLC_HOURLY_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,31 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, PRODUCTS'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
product_id,
book_address,
product_type,
ticker_id,
symbol,
name,
version,
vertex_products_id AS dim_products_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_dim_products') }}
ORDER BY product_id

View File

@ -1,32 +0,0 @@
version: 2
models:
- name: vertex__dim_products
description: '{{ doc("vertex_dim_products") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: BOOK_ADDRESS
description: '{{ doc("vertex_book_address") }}'
- name: PRODUCT_ID
description: '{{ doc("vertex_product_id") }}'
- name: PRODUCT_TYPE
description: '{{ doc("vertex_product_type") }}'
- name: TICKER_ID
description: '{{ doc("vertex_ticker_id") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: NAME
description: '{{ doc("vertex_name") }}'
- name: VERSION
description: '{{ doc("vertex_version") }}'
- name: DIM_PRODUCTS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,57 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta ={
'database_tags':{
'table':{
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, STATS'
}
}
}
) }}
SELECT
subaccount,
trader,
first_trade_timestamp,
last_trade_timestamp,
account_age,
trade_count,
DENSE_RANK() over (
ORDER BY
trade_count DESC
) AS trade_count_rank,
trade_count_24h,
DENSE_RANK() over (
ORDER BY
trade_count_24h DESC
) AS trade_count_rank_24h,
perp_trade_count,
spot_trade_count,
long_count,
short_count,
total_usd_volume,
DENSE_RANK() over (
ORDER BY
total_usd_volume DESC
) AS total_usd_volume_rank,
total_usd_volume_24h,
DENSE_RANK() over (
ORDER BY
total_usd_volume_24h DESC
) AS total_usd_volume_rank_24h,
avg_usd_trade_size,
total_fee_amount,
total_base_delta_amount,
total_quote_delta_amount,
total_liquidation_amount,
total_liquidation_amount_quote,
total_liquidation_count,
vertex_account_id as ez_account_stats_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_account_stats') }}
ORDER BY total_usd_volume_rank DESC

View File

@ -1,60 +0,0 @@
version: 2
models:
- name: vertex__ez_account_stats
description: '{{ doc("vertex_ez_account_stats") }}'
columns:
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: FIRST_TRADE_TIMESTAMP
description: '{{ doc("vertex_first_trade_timestamp") }}'
- name: LAST_TRADE_TIMESTAMP
description: '{{ doc("vertex_last_trade_timestamp") }}'
- name: ACCOUNT_AGE
description: '{{ doc("vertex_account_age") }}'
- name: TRADE_COUNT
description: '{{ doc("vertex_trade_count") }}'
- name: TRADE_COUNT_RANK
description: '{{ doc("vertex_trade_count_rank") }}'
- name: TRADE_COUNT_24H
description: '{{ doc("vertex_trade_count_24h") }}'
- name: TRADE_COUNT_RANK_24H
description: '{{ doc("vertex_trade_count_rank_24h") }}'
- name: PERP_TRADE_COUNT
description: '{{ doc("vertex_perp_trade_count") }}'
- name: SPOT_TRADE_COUNT
description: '{{ doc("vertex_spot_trade_count") }}'
- name: LONG_COUNT
description: '{{ doc("vertex_long_count") }}'
- name: SHORT_COUNT
description: '{{ doc("vertex_short_count") }}'
- name: TOTAL_USD_VOLUME
description: '{{ doc("vertex_total_usd_volume") }}'
- name: TOTAL_USD_VOLUME_RANK
description: '{{ doc("vertex_total_usd_volume_rank") }}'
- name: TOTAL_USD_VOLUME_24H
description: '{{ doc("vertex_total_usd_volume_24h") }}'
- name: TOTAL_USD_VOLUME_RANK_24H
description: '{{ doc("vertex_total_usd_volume_rank_24h") }}'
- name: AVG_USD_TRADE_SIZE
description: '{{ doc("vertex_avg_usd_trade_size") }}'
- name: TOTAL_FEE_AMOUNT
description: '{{ doc("vertex_total_fee_amount") }}'
- name: TOTAL_BASE_DELTA_AMOUNT
description: '{{ doc("vertex_total_base_delta_amount") }}'
- name: TOTAL_QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_total_quote_delta_amount") }}'
- name: TOTAL_LIQUIDATION_AMOUNT
description: '{{ doc("vertex_total_liquidation_amount") }}'
- name: TOTAL_LIQUIDATION_AMOUNT_QUOTE
description: '{{ doc("vertex_amount_quote_unadj") }}'
- name: TOTAL_LIQUIDATION_COUNT
description: '{{ doc("vertex_total_liquidation_count") }}'
- name: EZ_ACCOUNT_STATS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,37 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, CLEARINGHOUSE'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
contract_address,
event_name,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
modification_type,
symbol,
trader,
subaccount,
token_address,
amount_unadj,
amount,
amount_usd,
vertex_collateral_id AS ez_clearing_house_events_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_collateral') }}

View File

@ -1,46 +0,0 @@
version: 2
models:
- name: vertex__ez_clearing_house_events
description: '{{ doc("vertex_ez_clearing_house_events") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: EVENT_NAME
description: '{{ doc("arb_event_name") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: DIGEST
description: '{{ doc("vertex_digest") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: TOKEN_ADDRESS
description: '{{ doc("vertex_token_address") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("vertex_amount_usd_ch") }}'
- name: EZ_CLEARING_HOUSE_EVENTS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,58 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
edge_event_index,
user_event_index,
edge_digest,
user_digest,
trader,
subaccount,
symbol,
edge_order_type,
user_order_type,
edge_trade_type,
user_trade_type,
edge_is_taker,
user_is_taker,
edge_price_amount_unadj,
user_price_amount_unadj,
edge_price_amount,
user_price_amount,
edge_amount_unadj,
user_amount_unadj,
edge_amount,
user_amount,
edge_amount_usd,
user_amount_usd,
edge_fee_amount_unadj,
user_fee_amount_unadj,
edge_fee_amount,
user_fee_amount,
edge_base_delta_amount_unadj,
user_base_delta_amount_unadj,
edge_base_delta_amount,
user_base_delta_amount,
edge_quote_delta_amount_unadj,
user_quote_delta_amount_unadj,
edge_quote_delta_amount,
user_quote_delta_amount,
vertex_edge_trade_id as ez_edge_trades_id,
inserted_timestamp,
modified_timestamp,
FROM
{{ ref('silver__vertex_edge_trades') }}

View File

@ -1,88 +0,0 @@
version: 2
models:
- name: vertex__ez_edge_trades
description: '{{ doc("vertex_ez_edge_trades") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: EDGE_EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: USER_EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: EDGE_DIGEST
description: '{{ doc("vertex_digest") }}'
- name: USER_DIGEST
description: '{{ doc("vertex_digest") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: EDGE_ORDER_TYPE
description: '{{ doc("vertex_order_type") }}'
- name: USER_ORDER_TYPE
description: '{{ doc("vertex_order_type") }}'
- name: EDGE_TRADE_TYPE
description: '{{ doc("vertex_trade_type") }}'
- name: USER_TRADE_TYPE
description: '{{ doc("vertex_trade_type") }}'
- name: EDGE_IS_TAKER
description: '{{ doc("vertex_is_taker") }}'
- name: USER_IS_TAKER
description: '{{ doc("vertex_is_taker") }}'
- name: EDGE_PRICE_AMOUNT_UNADJ
description: '{{ doc("vertex_price_amount_unadj") }}'
- name: USER_PRICE_AMOUNT_UNADJ
description: '{{ doc("vertex_price_amount_unadj") }}'
- name: EDGE_PRICE_AMOUNT
description: '{{ doc("vertex_price_amount") }}'
- name: USER_PRICE_AMOUNT
description: '{{ doc("vertex_price_amount") }}'
- name: EDGE_AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: USER_AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: EDGE_AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: USER_AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: EDGE_AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: USER_AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: EDGE_FEE_AMOUNT_UNADJ
description: '{{ doc("vertex_fee_amount_unadj") }}'
- name: USER_FEE_AMOUNT_UNADJ
description: '{{ doc("vertex_fee_amount_unadj") }}'
- name: EDGE_FEE_AMOUNT
description: '{{ doc("vertex_fee_amount") }}'
- name: USER_FEE_AMOUNT
description: '{{ doc("vertex_fee_amount") }}'
- name: EDGE_BASE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
- name: USER_BASE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
- name: EDGE_BASE_DELTA_AMOUNT
description: '{{ doc("vertex_base_delta_amount") }}'
- name: USER_BASE_DELTA_AMOUNT
description: '{{ doc("vertex_base_delta_amount") }}'
- name: EDGE_QUOTE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
- name: USER_QUOTE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
- name: EDGE_QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_quote_delta_amount") }}'
- name: USER_QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_quote_delta_amount") }}'
- name: EZ_EDGE_TRADES_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,45 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, LIQUIDATION'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
contract_address,
event_name,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
digest,
trader,
subaccount,
version,
MODE,
product_id,
health_group,
health_group_symbol,
amount_unadj,
amount,
amount_quote_unadj,
amount_quote,
insurance_cover_unadj,
insurance_cover,
is_encoded_spread,
spread_product_ids,
vertex_liquidation_id AS ez_liquidations_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_liquidations') }}

View File

@ -1,62 +0,0 @@
version: 2
models:
- name: vertex__ez_liquidations
description: '{{ doc("vertex_ez_liquidations") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: EVENT_NAME
description: '{{ doc("arb_event_name") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: DIGEST
description: '{{ doc("vertex_digest") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: VERSION
description: '{{ doc("vertex_version") }}'
- name: MODE
description: '{{ doc("vertex_mode") }}'
- name: PRODUCT_ID
description: '{{ doc("vertex_product_id_liq") }}'
- name: HEALTH_GROUP
description: '{{ doc("vertex_health_group") }}'
- name: HEALTH_GROUP_SYMBOL
description: '{{ doc("vertex_health_group_symbol") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: AMOUNT_QUOTE_UNADJ
description: '{{ doc("vertex_amount_quote_unadj") }}'
- name: AMOUNT_QUOTE
description: '{{ doc("vertex_amount_quote") }}'
- name: INSURANCE_COVER_UNADJ
description: '{{ doc("vertex_insurance_cover_unadj") }}'
- name: INSURANCE_COVER
description: '{{ doc("vertex_insurance_cover") }}'
- name: IS_ENCODE_SPREAD
description: '{{ doc("vertex_is_encode_spread") }}'
- name: SPREAD_PRODUCT_IDS
description: '{{ doc("vertex_decoded_spread_product_ids") }}'
- name: EZ_LIQUIDATIONS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,31 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, STATS'
}
}
}
) }}
SELECT
hour,
ticker_id,
product_id,
orderbook_side,
volume,
price,
round_price_0_01,
round_price_0_1,
round_price_1,
round_price_10,
round_price_100,
vertex_market_depth_id as ez_market_depth_stats_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_market_depth') }}

View File

@ -1,34 +0,0 @@
version: 2
models:
- name: vertex__ez_market_depth_stats
description: '{{ doc("vertex_ez_market_depth") }}'
columns:
- name: HOUR
description: '{{ doc("vertex_hour") }}'
- name: TICKER_ID
description: '{{ doc("vertex_ticker_id") }}'
- name: PRODUCT_ID
description: '{{ doc("vertex_product_id") }}'
- name: ORDERBOOK_SIDE
description: '{{ doc("vertex_orderbook_side") }}'
- name: VOLUME
description: '{{ doc("vertex_orderbook_volume") }}'
- name: PRICE
description: '{{ doc("vertex_orderbook_price") }}'
- name: ROUND_PRICE_0_01
description: '{{ doc("vertex_orderbook_round_price_0_01") }}'
- name: ROUND_PRICE_0_1
description: '{{ doc("vertex_orderbook_round_price_0_1") }}'
- name: ROUND_PRICE_1
description: '{{ doc("vertex_orderbook_round_price_1") }}'
- name: ROUND_PRICE_10
description: '{{ doc("vertex_orderbook_round_price_10") }}'
- name: ROUND_PRICE_100
description: '{{ doc("vertex_orderbook_round_price_100") }}'
- name: EZ_MARKET_DEPTH_STATS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,45 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, STATS'
}
}
}
) }}
SELECT
hour,
ticker_id,
product_id,
symbol,
distinct_sequencer_batches,
distinct_trader_count,
distinct_subaccount_count,
trade_count,
amount_usd,
fee_amount,
base_delta_amount,
quote_delta_amount,
base_volume_24h,
quote_volume_24h,
funding_rate,
index_price,
last_price,
mark_price,
next_funding_rate_timestamp,
open_interest,
open_interest_usd,
price_change_percent_24h,
product_type,
quote_currency,
quote_volume,
vertex_market_stats_id as ez_market_stats_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_market_stats') }}

View File

@ -1,58 +0,0 @@
version: 2
models:
- name: vertex__ez_market_stats
description: '{{ doc("vertex_ez_market_stats") }}'
columns:
- name: HOUR
description: '{{ doc("vertex_hour") }}'
- name: TICKER_ID
description: '{{ doc("vertex_ticker_id") }}'
- name: PRODUCT_ID
description: '{{ doc("vertex_product_id") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: DISTINCT_SEQUENCER_BATCHES
description: '{{ doc("vertex_distinct_sequencer_batches") }}'
- name: DISTINCT_TRADER_COUNT
description: '{{ doc("vertex_trader_count") }}'
- name: DISTINCT_SUBACCOUNT_COUNT
description: '{{ doc("vertex_subaccount_count") }}'
- name: TRADE_COUNT
description: '{{ doc("vertex_total_trade_count") }}'
- name: AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: FEE_AMOUNT
description: '{{ doc("vertex_fee_amount") }}'
- name: BASE_DELTA_AMOUNT
description: '{{ doc("vertex_base_delta_amount") }}'
- name: QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_quote_delta_amount") }}'
- name: BASE_VOLUME_24H
description: '{{ doc("vertex_base_volume_24h") }}'
- name: QUOTE_VOLUME_24H
description: '{{ doc("vertex_quote_volume_24h") }}'
- name: FUNDING_RATE
description: '{{ doc("vertex_funding_rate") }}'
- name: INDEX_PRICE
description: '{{ doc("vertex_index_price") }}'
- name: LAST_PRICE
description: '{{ doc("vertex_last_price") }}'
- name: MARK_PRICE
description: '{{ doc("vertex_mark_price") }}'
- name: NEXT_FUNDING_RATE_TIMESTAMP
description: '{{ doc("vertex_next_funding_rate") }}'
- name: OPEN_INTEREST
description: '{{ doc("vertex_open_interest") }}'
- name: OPEN_INTEREST_USD
description: '{{ doc("vertex_open_interest_usd") }}'
- name: PRODUCT_TYPE
description: '{{ doc("vertex_product_type") }}'
- name: QUOTE_CURRENCY
description: '{{ doc("vertex_quote_currency") }}'
- name: EZ_MARKET_STATS_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,28 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, STATS'
}
}
}
) }}
SELECT
hour,
ticker_id,
symbol,
product_id,
deposit_apr,
borrow_apr,
tvl,
vertex_money_markets_id as ez_money_markets_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_money_markets') }}

View File

@ -1,26 +0,0 @@
version: 2
models:
- name: vertex__ez_money_markets
description: '{{ doc("vertex_money_markets") }}'
columns:
- name: HOUR
description: '{{ doc("vertex_hour") }}'
- name: TICKER_ID
description: '{{ doc("vertex_ticker_id") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: PRODUCT_ID
description: '{{ doc("vertex_product_id") }}'
- name: DEPOSIT_APR
description: '{{ doc("vertex_deposit_apr") }}'
- name: BORROW_APR
description: '{{ doc("vertex_borrow_apr") }}'
- name: TVL
description: '{{ doc("vertex_tvl") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'
- name: VERTEX_MONEY_MARKETS_ID
description: '{{ doc("pk") }}'

View File

@ -1,51 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, PERPS'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
contract_address,
event_name,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
symbol,
digest,
trader,
subaccount,
version,
trade_type,
order_type,
market_reduce_flag,
expiration,
nonce,
is_taker,
price_amount_unadj,
price_amount,
amount_unadj,
amount,
amount_usd,
fee_amount_unadj,
fee_amount,
base_delta_amount_unadj,
base_delta_amount,
quote_delta_amount_unadj,
quote_delta_amount,
vertex_perps_id AS ez_perp_trades_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_perps') }}

View File

@ -1,74 +0,0 @@
version: 2
models:
- name: vertex__ez_perp_trades
description: '{{ doc("vertex_ez_perp_trades") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: EVENT_NAME
description: '{{ doc("arb_event_name") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: DIGEST
description: '{{ doc("vertex_digest") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: VERSION
description: '{{ doc("vertex_version") }}'
- name: TRADE_TYPE
description: '{{ doc("vertex_trade_type") }}'
- name: ORDER_TYPE
description: '{{ doc("vertex_order_type") }}'
- name: MARKET_REDUCE_FLAG
description: '{{ doc("vertex_market_reduce_flag") }}'
- name: EXPIRATION
description: '{{ doc("vertex_expiration") }}'
- name: NONCE
description: '{{ doc("vertex_nonce") }}'
- name: IS_TAKER
description: '{{ doc("vertex_is_taker") }}'
- name: PRICE_AMOUNT_UNADJ
description: '{{ doc("vertex_price_amount_unadj") }}'
- name: PRICE_AMOUNT
description: '{{ doc("vertex_price_amount") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: FEE_AMOUNT_UNADJ
description: '{{ doc("vertex_fee_amount_unadj") }}'
- name: FEE_AMOUNT
description: '{{ doc("vertex_fee_amount") }}'
- name: BASE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
- name: BASE_DELTA_AMOUNT
description: '{{ doc("vertex_base_delta_amount") }}'
- name: QUOTE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
- name: QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_quote_delta_amount") }}'
- name: EZ_PERP_TRADES_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,51 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, SPOT'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
contract_address,
event_name,
event_index,
origin_function_signature,
origin_from_address,
origin_to_address,
symbol,
digest,
trader,
subaccount,
version,
trade_type,
order_type,
market_reduce_flag,
expiration,
nonce,
is_taker,
price_amount_unadj,
price_amount,
amount_unadj,
amount,
amount_usd,
fee_amount_unadj,
fee_amount,
base_delta_amount_unadj,
base_delta_amount,
quote_delta_amount_unadj,
quote_delta_amount,
vertex_spot_id AS ez_spot_trades_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_spot') }}

View File

@ -1,74 +0,0 @@
version: 2
models:
- name: vertex__ez_spot_trades
description: '{{ doc("vertex_ez_spot_trades") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: EVENT_NAME
description: '{{ doc("arb_event_name") }}'
- name: EVENT_INDEX
description: '{{ doc("arb_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: DIGEST
description: '{{ doc("vertex_digest") }}'
- name: TRADER
description: '{{ doc("vertex_trader") }}'
- name: SUBACCOUNT
description: '{{ doc("vertex_subaccount") }}'
- name: VERSION
description: '{{ doc("vertex_version") }}'
- name: TRADE_TYPE
description: '{{ doc("vertex_trade_type") }}'
- name: ORDER_TYPE
description: '{{ doc("vertex_order_type") }}'
- name: MARKET_REDUCE_FLAG
description: '{{ doc("vertex_market_reduce_flag") }}'
- name: EXPIRATION
description: '{{ doc("vertex_expiration") }}'
- name: NONCE
description: '{{ doc("vertex_nonce") }}'
- name: IS_TAKER
description: '{{ doc("vertex_is_taker") }}'
- name: PRICE_AMOUNT_UNADJ
description: '{{ doc("vertex_price_amount_unadj") }}'
- name: PRICE_AMOUNT
description: '{{ doc("vertex_price_amount") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: FEE_AMOUNT_UNADJ
description: '{{ doc("vertex_fee_amount_unadj") }}'
- name: FEE_AMOUNT
description: '{{ doc("vertex_fee_amount") }}'
- name: BASE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
- name: BASE_DELTA_AMOUNT
description: '{{ doc("vertex_base_delta_amount") }}'
- name: QUOTE_DELTA_AMOUNT_UNADJ
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
- name: QUOTE_DELTA_AMOUNT
description: '{{ doc("vertex_quote_delta_amount") }}'
- name: EZ_SPOT_TRADES_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,34 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta={
'database_tags':{
'table': {
'PROTOCOL': 'VERTEX',
'PURPOSE': 'CLOB, DEX, STAKING'
}
}
}
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
origin_function_signature,
origin_from_address,
origin_to_address,
contract_address,
to_address,
from_address,
stake_action,
symbol,
amount_unadj,
amount,
amount_usd,
vertex_staking_id as ez_staking_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__vertex_staking') }}

View File

@ -1,36 +0,0 @@
version: 2
models:
- name: vertex__ez_staking_actions
description: '{{ doc("vertex_ez_staking") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("arb_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("arb_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("arb_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("arb_logs_contract_address") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_to") }}'
- name: STAKE_ACTION
description: '{{ doc("vertex_stake_action") }}'
- name: SYMBOL
description: '{{ doc("vertex_symbol") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("vertex_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("vertex_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("vertex_amount_usd") }}'
- name: EZ_STAKING_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,38 +0,0 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STATS, METRICS, CORE, HOURLY',
} } }
) }}
SELECT
block_timestamp_hour,
block_number_min,
block_number_max,
block_count,
transaction_count,
transaction_count_success,
transaction_count_failed,
unique_from_count,
unique_to_count,
total_fees AS total_fees_native,
ROUND(
total_fees * LAST_VALUE(
p.price ignore nulls
) over (
ORDER BY
block_timestamp_hour rows unbounded preceding
),
2
) AS total_fees_usd,
core_metrics_hourly_id AS ez_core_metrics_hourly_id,
s.inserted_timestamp AS inserted_timestamp,
s.modified_timestamp AS modified_timestamp
FROM
{{ ref('silver_stats__core_metrics_hourly') }}
s
LEFT JOIN {{ ref('silver__complete_token_prices') }}
p
ON s.block_timestamp_hour = p.hour
AND p.token_address = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'

View File

@ -1,34 +0,0 @@
version: 2
models:
- name: stats__ez_core_metrics_hourly
description: '{{ doc("evm_ez_core_metrics_hourly_table_doc") }}'
columns:
- name: BLOCK_TIMESTAMP_HOUR
description: '{{ doc("evm_block_timestamp_hour") }}'
- name: BLOCK_NUMBER_MIN
description: '{{ doc("evm_block_number_min") }}'
- name: BLOCK_NUMBER_MAX
description: '{{ doc("evm_block_number_max") }}'
- name: BLOCK_COUNT
description: '{{ doc("evm_block_count") }}'
- name: TRANSACTION_COUNT
description: '{{ doc("evm_transaction_count") }}'
- name: TRANSACTION_COUNT_SUCCESS
description: '{{ doc("evm_transaction_count_success") }}'
- name: TRANSACTION_COUNT_FAILED
description: '{{ doc("evm_transaction_count_failed") }}'
- name: UNIQUE_FROM_COUNT
description: '{{ doc("evm_unique_from_count") }}'
- name: UNIQUE_TO_COUNT
description: '{{ doc("evm_unique_to_count") }}'
- name: TOTAL_FEES_NATIVE
description: '{{ doc("evm_total_fees_native") }}'
- name: TOTAL_FEES_USD
description: '{{ doc("evm_total_fees_usd") }}'
- name: EZ_CORE_METRICS_HOURLY_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -1,161 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'test_timestamp',
full_refresh = false,
tags = ['observability']
) }}
WITH summary_stats AS (
SELECT
MIN(block_number) AS min_block,
MAX(block_number) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS blocks_tested
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp <= DATEADD('hour', -12, CURRENT_TIMESTAMP())
{% if is_incremental() %}
AND (
block_number >= (
SELECT
MIN(block_number)
FROM
(
SELECT
MIN(block_number) AS block_number
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp BETWEEN DATEADD('hour', -96, CURRENT_TIMESTAMP())
AND DATEADD('hour', -95, CURRENT_TIMESTAMP())
UNION
SELECT
MIN(VALUE) - 1 AS block_number
FROM
(
SELECT
blocks_impacted_array
FROM
{{ this }}
qualify ROW_NUMBER() over (
ORDER BY
test_timestamp DESC
) = 1
),
LATERAL FLATTEN(
input => blocks_impacted_array
)
)
) {% if var('OBSERV_FULL_TEST') %}
OR block_number >= 0
{% endif %}
)
{% endif %}
),
block_range AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
min_block
FROM
summary_stats
)
AND (
SELECT
max_block
FROM
summary_stats
)
),
blocks AS (
SELECT
l.block_number,
block_timestamp,
LAG(
l.block_number,
1
) over (
ORDER BY
l.block_number ASC
) AS prev_BLOCK_NUMBER
FROM
{{ ref("silver__blocks") }}
l
INNER JOIN block_range b
ON l.block_number = b.block_number
AND l.block_number >= (
SELECT
MIN(block_number)
FROM
block_range
)
),
block_gen AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
MIN(block_number)
FROM
blocks
)
AND (
SELECT
MAX(block_number)
FROM
blocks
)
)
SELECT
'blocks' AS test_name,
MIN(
b.block_number
) AS min_block,
MAX(
b.block_number
) AS max_block,
MIN(
b.block_timestamp
) AS min_block_timestamp,
MAX(
b.block_timestamp
) AS max_block_timestamp,
COUNT(1) AS blocks_tested,
COUNT(
CASE
WHEN C.block_number IS NOT NULL THEN A.block_number
END
) AS blocks_impacted_count,
ARRAY_AGG(
CASE
WHEN C.block_number IS NOT NULL THEN A.block_number
END
) within GROUP (
ORDER BY
A.block_number
) AS blocks_impacted_array,
CURRENT_TIMESTAMP AS test_timestamp
FROM
block_gen A
LEFT JOIN blocks b
ON A.block_number = b.block_number
LEFT JOIN blocks C
ON A.block_number > C.prev_block_number
AND A.block_number < C.block_number
AND C.block_number - C.prev_block_number <> 1
WHERE
COALESCE(
b.block_number,
C.block_number
) IS NOT NULL

View File

@ -1,119 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'test_timestamp',
full_refresh = false,
tags = ['observability']
) }}
WITH summary_stats AS (
SELECT
MIN(block_number) AS min_block,
MAX(block_number) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS blocks_tested
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp <= DATEADD('hour', -12, CURRENT_TIMESTAMP())
{% if is_incremental() %}
AND (
block_number >= (
SELECT
MIN(block_number)
FROM
(
SELECT
MIN(block_number) AS block_number
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp BETWEEN DATEADD('hour', -96, CURRENT_TIMESTAMP())
AND DATEADD('hour', -95, CURRENT_TIMESTAMP())
UNION
SELECT
MIN(VALUE) - 1 AS block_number
FROM
(
SELECT
blocks_impacted_array
FROM
{{ this }}
qualify ROW_NUMBER() over (
ORDER BY
test_timestamp DESC
) = 1
),
LATERAL FLATTEN(
input => blocks_impacted_array
)
)
) {% if var('OBSERV_FULL_TEST') %}
OR block_number >= 0
{% endif %}
)
{% endif %}
),
block_range AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
min_block
FROM
summary_stats
)
AND (
SELECT
max_block
FROM
summary_stats
)
),
broken_blocks AS (
SELECT
DISTINCT block_number
FROM
{{ ref("silver__receipts") }}
r
LEFT JOIN {{ ref("silver__logs") }}
l USING (
block_number,
tx_hash
)
JOIN block_range USING (block_number)
WHERE
l.tx_hash IS NULL
AND ARRAY_SIZE(
r.logs
) > 0
),
impacted_blocks AS (
SELECT
COUNT(1) AS blocks_impacted_count,
ARRAY_AGG(block_number) within GROUP (
ORDER BY
block_number
) AS blocks_impacted_array
FROM
broken_blocks
)
SELECT
'event_logs' AS test_name,
min_block,
max_block,
min_block_timestamp,
max_block_timestamp,
blocks_tested,
blocks_impacted_count,
blocks_impacted_array,
CURRENT_TIMESTAMP() AS test_timestamp
FROM
summary_stats
JOIN impacted_blocks
ON 1 = 1

View File

@ -1,124 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'test_timestamp',
full_refresh = false,
tags = ['observability']
) }}
WITH summary_stats AS (
SELECT
MIN(block_number) AS min_block,
MAX(block_number) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS blocks_tested
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp <= DATEADD('hour', -12, CURRENT_TIMESTAMP())
{% if is_incremental() %}
AND (
block_number >= (
SELECT
MIN(block_number)
FROM
(
SELECT
MIN(block_number) AS block_number
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp BETWEEN DATEADD('hour', -96, CURRENT_TIMESTAMP())
AND DATEADD('hour', -95, CURRENT_TIMESTAMP())
UNION
SELECT
MIN(VALUE) - 1 AS block_number
FROM
(
SELECT
blocks_impacted_array
FROM
{{ this }}
qualify ROW_NUMBER() over (
ORDER BY
test_timestamp DESC
) = 1
),
LATERAL FLATTEN(
input => blocks_impacted_array
)
)
) {% if var('OBSERV_FULL_TEST') %}
OR block_number >= 0
{% endif %}
)
{% endif %}
),
block_range AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
min_block
FROM
summary_stats
)
AND (
SELECT
max_block
FROM
summary_stats
)
),
broken_blocks AS (
SELECT
DISTINCT block_number
FROM
{{ ref("silver__transactions") }}
t
LEFT JOIN {{ ref("silver__receipts") }}
r USING (
block_number,
tx_hash,
block_hash
)
JOIN block_range USING (block_number)
WHERE
r.tx_hash IS NULL
),
impacted_blocks AS (
SELECT
COUNT(1) AS blocks_impacted_count,
ARRAY_AGG(block_number) within GROUP (
ORDER BY
block_number
) AS blocks_impacted_array
FROM
broken_blocks
WHERE
block_number NOT IN (
SELECT
block_number
FROM
{{ ref('silver_observability__excluded_receipt_blocks') }}
)
)
SELECT
'receipts' AS test_name,
min_block,
max_block,
min_block_timestamp,
max_block_timestamp,
blocks_tested,
blocks_impacted_count,
blocks_impacted_array,
CURRENT_TIMESTAMP() AS test_timestamp
FROM
summary_stats
JOIN impacted_blocks
ON 1 = 1

View File

@ -1,121 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'test_timestamp',
full_refresh = false,
tags = ['observability']
) }}
WITH summary_stats AS (
SELECT
MIN(block_number) AS min_block,
MAX(block_number) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS blocks_tested
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp <= DATEADD('hour', -12, CURRENT_TIMESTAMP())
{% if is_incremental() %}
AND (
block_number >= (
SELECT
MIN(block_number)
FROM
(
SELECT
MIN(block_number) AS block_number
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp BETWEEN DATEADD('hour', -96, CURRENT_TIMESTAMP())
AND DATEADD('hour', -95, CURRENT_TIMESTAMP())
UNION
SELECT
MIN(VALUE) - 1 AS block_number
FROM
(
SELECT
blocks_impacted_array
FROM
{{ this }}
qualify ROW_NUMBER() over (
ORDER BY
test_timestamp DESC
) = 1
),
LATERAL FLATTEN(
input => blocks_impacted_array
)
)
) {% if var('OBSERV_FULL_TEST') %}
OR block_number >= 0
{% endif %}
)
{% endif %}
),
block_range AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
min_block
FROM
summary_stats
)
AND (
SELECT
max_block
FROM
summary_stats
)
),
broken_blocks AS (
SELECT
DISTINCT block_number
FROM
{{ ref("silver__transactions") }}
tx
LEFT JOIN {{ source(
'arbitrum_gold',
'fact_traces'
) }}
tr USING (
block_number,
tx_hash
)
JOIN block_range USING (block_number)
WHERE
tr.tx_hash IS NULL
AND tx.to_address <> '0x000000000000000000000000000000000000006e'
AND tr.to_address <> '0x000000000000000000000000000000000000006e'
),
impacted_blocks AS (
SELECT
COUNT(1) AS blocks_impacted_count,
ARRAY_AGG(block_number) within GROUP (
ORDER BY
block_number
) AS blocks_impacted_array
FROM
broken_blocks
)
SELECT
'traces' AS test_name,
min_block,
max_block,
min_block_timestamp,
max_block_timestamp,
blocks_tested,
blocks_impacted_count,
blocks_impacted_array,
CURRENT_TIMESTAMP() AS test_timestamp
FROM
summary_stats
JOIN impacted_blocks
ON 1 = 1

View File

@ -1,117 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'test_timestamp',
full_refresh = false,
tags = ['observability']
) }}
WITH summary_stats AS (
SELECT
MIN(block_number) AS min_block,
MAX(block_number) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS blocks_tested
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp <= DATEADD('hour', -12, CURRENT_TIMESTAMP())
{% if is_incremental() %}
AND (
block_number >= (
SELECT
MIN(block_number)
FROM
(
SELECT
MIN(block_number) AS block_number
FROM
{{ ref('silver__blocks') }}
WHERE
block_timestamp BETWEEN DATEADD('hour', -96, CURRENT_TIMESTAMP())
AND DATEADD('hour', -95, CURRENT_TIMESTAMP())
UNION
SELECT
MIN(VALUE) - 1 AS block_number
FROM
(
SELECT
blocks_impacted_array
FROM
{{ this }}
qualify ROW_NUMBER() over (
ORDER BY
test_timestamp DESC
) = 1
),
LATERAL FLATTEN(
input => blocks_impacted_array
)
)
) {% if var('OBSERV_FULL_TEST') %}
OR block_number >= 0
{% endif %}
)
{% endif %}
),
block_range AS (
SELECT
_id AS block_number
FROM
{{ ref('silver__number_sequence') }}
WHERE
_id BETWEEN (
SELECT
min_block
FROM
summary_stats
)
AND (
SELECT
max_block
FROM
summary_stats
)
),
broken_blocks AS (
SELECT
DISTINCT block_number
FROM
{{ ref("silver__confirmed_blocks") }}
b
LEFT JOIN {{ ref("silver__transactions") }}
t USING (
block_number,
tx_hash,
block_hash
)
JOIN block_range USING (block_number)
WHERE
t.tx_hash IS NULL
),
impacted_blocks AS (
SELECT
COUNT(1) AS blocks_impacted_count,
ARRAY_AGG(block_number) within GROUP (
ORDER BY
block_number
) AS blocks_impacted_array
FROM
broken_blocks
)
SELECT
'transactions' AS test_name,
min_block,
max_block,
min_block_timestamp,
max_block_timestamp,
blocks_tested,
blocks_impacted_count,
blocks_impacted_array,
CURRENT_TIMESTAMP() AS test_timestamp
FROM
summary_stats
JOIN impacted_blocks
ON 1 = 1

View File

@ -1,181 +0,0 @@
{{ config (
materialized = "incremental",
unique_key = "contract_address",
merge_exclude_columns = ["inserted_timestamp"],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(contract_address,abi_hash,bytecode), SUBSTRING(contract_address,abi_hash,bytecode)",
tags = ['abis']
) }}
WITH override_abis AS (
SELECT
contract_address,
PARSE_JSON(DATA) AS abi,
TO_TIMESTAMP_LTZ(SYSDATE()) AS _inserted_timestamp,
'flipside' AS abi_source,
'flipside' AS discord_username,
SHA2(abi) AS abi_hash,
1 AS priority
FROM
{{ ref('silver__override_abis') }}
WHERE
contract_address IS NOT NULL
),
verified_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
2 AS priority
FROM
{{ ref('silver__verified_abis') }}
WHERE
abi_source = 'arbscan'
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
WHERE
abi_source = 'arbscan'
)
{% endif %}
),
user_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
2 AS priority
FROM
{{ ref('silver__verified_abis') }}
WHERE
abi_source = 'user'
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
WHERE
abi_source = 'user'
)
{% endif %}
),
bytecode_abis AS (
SELECT
contract_address,
abi,
abi_hash,
'bytecode_matched' AS abi_source,
NULL AS discord_username,
_inserted_timestamp,
3 AS priority
FROM
{{ ref('silver__bytecode_abis') }}
WHERE
1 = 1
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
WHERE
abi_source = 'bytecode_matched'
)
{% endif %}
),
all_abis AS (
SELECT
contract_address,
abi AS DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
priority
FROM
override_abis
UNION
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
priority
FROM
verified_abis
UNION
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
priority
FROM
user_abis
UNION
SELECT
contract_address,
abi AS DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
priority
FROM
bytecode_abis
),
priority_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash,
priority
FROM
all_abis qualify(ROW_NUMBER() over(PARTITION BY contract_address
ORDER BY
priority ASC)) = 1
)
SELECT
p.contract_address,
p.data,
p._inserted_timestamp,
p.abi_source,
p.discord_username,
p.abi_hash,
created_contract_input AS bytecode,
{{ dbt_utils.generate_surrogate_key(
['contract_address']
) }} AS abis_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
priority_abis p
LEFT JOIN {{ ref('silver__created_contracts') }}
ON p.contract_address = created_contract_address

View File

@ -1,8 +0,0 @@
version: 2
models:
- name: silver__abis
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- CONTRACT_ADDRESS

View File

@ -1,76 +0,0 @@
{{ config (
materialized = "incremental",
unique_key = "contract_address",
tags = ['abis']
) }}
WITH contracts_with_abis AS (
-- Identifying contracts with verified ABIs
SELECT
created_contract_address AS contract_address
FROM
{{ ref('silver__created_contracts') }}
JOIN {{ ref('silver__verified_abis') }} A
ON A.contract_address = created_contract_address
),
contracts_without_abis AS (
-- Contracts that are missing ABIs
SELECT
created_contract_address AS contract_address,
created_contract_input AS bytecode
FROM
{{ ref('silver__created_contracts') }}
WHERE
created_contract_address NOT IN (
SELECT
contract_address
FROM
contracts_with_abis
)
{% if is_incremental() %}
AND created_contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
{% endif %}
),
unique_bytecode_abis AS (
-- Bytecodes from created_contracts with a unique ABI
SELECT
cc.created_contract_input AS bytecode,
va.data AS abi,
va.abi_hash
FROM
{{ ref('silver__created_contracts') }}
cc
JOIN {{ ref('silver__verified_abis') }}
va
ON cc.created_contract_address = va.contract_address
GROUP BY
cc.created_contract_input,
va.data,
va.abi_hash
HAVING
COUNT(
DISTINCT va.data
) = 1 -- Ensuring there's only one ABI per bytecode
) -- Final matching
SELECT
contract_address,
abi,
abi_hash,
{% if is_incremental() %}
SYSDATE()
{% else %}
TO_TIMESTAMP_NTZ('2000-01-01 00:00:00')
{% endif %}
AS _inserted_timestamp
FROM
contracts_without_abis
JOIN unique_bytecode_abis USING (bytecode)

View File

@ -1,8 +0,0 @@
version: 2
models:
- name: silver__bytecode_abis
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- CONTRACT_ADDRESS
- ABI_HASH

View File

@ -1,216 +0,0 @@
{{ config (
materialized = 'incremental',
unique_key = ['parent_contract_address','event_signature','start_block'],
merge_exclude_columns = ["inserted_timestamp"],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
tags = ['abis']
) }}
WITH new_abis AS (
SELECT
DISTINCT contract_address
FROM
{{ ref('silver__flat_event_abis') }}
{% if is_incremental() %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
{% endif %}
),
proxies AS (
SELECT
p0.created_block,
p0.proxy_created_block,
p0.contract_address,
p0.proxy_address,
p0.start_block,
p0._id,
p0._inserted_timestamp
FROM
{{ ref('silver__proxies') }}
p0
JOIN new_abis na0
ON p0.contract_address = na0.contract_address
UNION
SELECT
p1.created_block,
p1.proxy_created_block,
p1.contract_address,
p1.proxy_address,
p1.start_block,
p1._id,
p1._inserted_timestamp
FROM
{{ ref('silver__proxies') }}
p1
JOIN new_abis na1
ON p1.proxy_address = na1.contract_address
),
all_relevant_contracts AS (
SELECT
DISTINCT contract_address
FROM
proxies
UNION
SELECT
DISTINCT proxy_address AS contract_address
FROM
proxies
UNION
SELECT
contract_address
FROM
new_abis
),
flat_abis AS (
SELECT
contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp
FROM
{{ ref('silver__flat_event_abis') }}
JOIN all_relevant_contracts USING (contract_address)
),
base AS (
SELECT
ea.contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
ea._inserted_timestamp,
pb._inserted_timestamp AS proxy_inserted_timestamp,
pb.start_block,
pb.proxy_created_block,
pb.contract_address AS base_contract_address,
1 AS priority
FROM
flat_abis ea
JOIN proxies pb
ON ea.contract_address = pb.proxy_address
UNION ALL
SELECT
eab.contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
eab._inserted_timestamp,
pbb._inserted_timestamp AS proxy_inserted_timestamp,
pbb.created_block AS start_block,
pbb.proxy_created_block,
pbb.contract_address AS base_contract_address,
2 AS priority
FROM
flat_abis eab
JOIN (
SELECT
DISTINCT contract_address,
created_block,
proxy_created_block,
_inserted_timestamp
FROM
proxies
) pbb
ON eab.contract_address = pbb.contract_address
UNION ALL
SELECT
contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp,
NULL AS proxy_inserted_timestamp,
0 AS start_block,
NULL AS proxy_created_block,
contract_address AS base_contract_address,
3 AS priority
FROM
flat_abis eac
WHERE
contract_address NOT IN (
SELECT
DISTINCT contract_address
FROM
proxies
)
),
new_records AS (
SELECT
base_contract_address AS parent_contract_address,
event_name,
abi,
start_block,
proxy_created_block,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp,
proxy_inserted_timestamp
FROM
base qualify ROW_NUMBER() over (
PARTITION BY parent_contract_address,
NAME,
event_type,
event_signature,
start_block
ORDER BY
priority ASC,
_inserted_timestamp DESC,
proxy_created_block DESC nulls last,
proxy_inserted_timestamp DESC nulls last
) = 1
)
SELECT
parent_contract_address,
event_name,
abi,
start_block,
proxy_created_block,
simple_event_name,
event_signature,
IFNULL(LEAD(start_block) over (PARTITION BY parent_contract_address, event_signature
ORDER BY
start_block) -1, 1e18) AS end_block,
_inserted_timestamp,
proxy_inserted_timestamp,
SYSDATE() AS _updated_timestamp,
{{ dbt_utils.generate_surrogate_key(
['parent_contract_address','event_signature','start_block']
) }} AS complete_event_abis_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
new_records qualify ROW_NUMBER() over (
PARTITION BY parent_contract_address,
event_name,
event_signature,
start_block
ORDER BY
_inserted_timestamp DESC
) = 1

View File

@ -1,9 +0,0 @@
version: 2
models:
- name: silver__complete_event_abis
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- PARENT_CONTRACT_ADDRESS
- EVENT_SIGNATURE
- START_BLOCK

View File

@ -1,112 +0,0 @@
{{ config (
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'contract_address',
cluster_by = '_inserted_timestamp::date',
tags = ['abis'],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY (contract_address)"
) }}
WITH abi_base AS (
SELECT
contract_address,
DATA,
_inserted_timestamp
FROM
{{ ref('silver__abis') }}
{% if is_incremental() %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '24 hours'
FROM
{{ this }}
)
{% endif %}
),
flat_abi AS (
SELECT
contract_address,
_inserted_timestamp,
DATA,
VALUE :inputs AS inputs,
VALUE :payable :: BOOLEAN AS payable,
VALUE :stateMutability :: STRING AS stateMutability,
VALUE :type :: STRING AS TYPE,
VALUE :anonymous :: BOOLEAN AS anonymous,
VALUE :name :: STRING AS NAME
FROM
abi_base,
LATERAL FLATTEN (
input => DATA
)
WHERE
TYPE = 'event' qualify ROW_NUMBER() over (
PARTITION BY contract_address,
NAME,
inputs
ORDER BY
LENGTH(inputs)
) = 1
),
event_types AS (
SELECT
contract_address,
_inserted_timestamp,
inputs,
anonymous,
NAME,
ARRAY_AGG(
VALUE :type :: STRING
) AS event_type
FROM
flat_abi,
LATERAL FLATTEN (
input => inputs
)
GROUP BY
contract_address,
_inserted_timestamp,
inputs,
anonymous,
NAME
),
apply_udfs AS (
SELECT
contract_address,
NAME AS event_name,
PARSE_JSON(
OBJECT_CONSTRUCT(
'anonymous',
anonymous,
'inputs',
inputs,
'name',
NAME,
'type',
'event'
) :: STRING
) AS abi,
utils.udf_evm_text_signature(abi) AS simple_event_name,
utils.udf_keccak256(simple_event_name) AS event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp
FROM
event_types
)
SELECT
contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp
FROM
apply_udfs

View File

@ -1,8 +0,0 @@
{{ config(
materialized = 'view',
tags = ['abis']
) }}
SELECT
NULL AS contract_address,
NULL AS DATA

View File

@ -1,104 +0,0 @@
{{ config (
materialized = 'incremental',
unique_key = ['contract_address','proxy_address'],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
tags = ['abis']
) }}
WITH base AS (
SELECT
from_address,
to_address,
MIN(block_number) AS start_block,
MAX(modified_timestamp) AS _inserted_timestamp
FROM
{{ ref('core__fact_traces') }}
WHERE
TYPE = 'DELEGATECALL'
AND trace_succeeded
AND tx_succeeded
AND from_address != to_address -- exclude self-calls
{% if is_incremental() %}
AND modified_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '24 hours'
FROM
{{ this }}
)
{% endif %}
GROUP BY
from_address,
to_address
),
create_id AS (
SELECT
from_address AS contract_address,
to_address AS proxy_address,
start_block,
CONCAT(
from_address,
'-',
to_address
) AS _id,
_inserted_timestamp
FROM
base
),
heal AS (
SELECT
contract_address,
proxy_address,
start_block,
_id,
_inserted_timestamp
FROM
create_id
{% if is_incremental() %}
UNION ALL
SELECT
contract_address,
proxy_address,
start_block,
_id,
_inserted_timestamp
FROM
{{ this }}
JOIN create_id USING (
contract_address,
proxy_address
)
{% endif %}
),
FINAL AS (
SELECT
contract_address,
proxy_address,
start_block,
_id,
_inserted_timestamp
FROM
heal qualify ROW_NUMBER() over (
PARTITION BY contract_address,
proxy_address
ORDER BY
start_block ASC
) = 1
)
SELECT
f.contract_address,
f.proxy_address,
f.start_block,
f._id,
f._inserted_timestamp,
C.block_number AS created_block,
p.block_number AS proxy_created_block
FROM
FINAL f
JOIN {{ ref('silver__created_contracts') }} C
ON f.contract_address = C.created_contract_address
JOIN {{ ref('silver__created_contracts') }}
p
ON f.proxy_address = p.created_contract_address

View File

@ -1,7 +0,0 @@
version: 2
models:
- name: silver__proxies
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _ID

View File

@ -1,550 +0,0 @@
{{ config (
materialized = "incremental",
unique_key = "id",
tags = ['abis']
) }}
WITH base AS (
SELECT
contract_address,
abi,
PARSE_JSON(abi) AS DATA,
SHA2(PARSE_JSON(abi)) AS abi_hash,
discord_username,
_inserted_timestamp
FROM
{{ source(
"crosschain_public",
"user_abis"
) }}
WHERE
blockchain = 'arbitrum'
AND NOT duplicate_abi
{% if is_incremental() %}
AND contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
AND _inserted_timestamp > (
SELECT
COALESCE(
MAX(
_inserted_timestamp
),
'1970-01-01'
)
FROM
{{ this }}
)
{% endif %}
ORDER BY
_inserted_timestamp ASC
LIMIT
10
), flat_event_abi AS (
SELECT
contract_address,
_inserted_timestamp,
DATA,
VALUE :inputs AS inputs,
VALUE :payable :: BOOLEAN AS payable,
VALUE :stateMutability :: STRING AS stateMutability,
VALUE :type :: STRING AS TYPE,
VALUE :anonymous :: BOOLEAN AS anonymous,
VALUE :name :: STRING AS NAME
FROM
base,
LATERAL FLATTEN (
input => DATA
)
WHERE
TYPE = 'event' qualify ROW_NUMBER() over (
PARTITION BY contract_address,
NAME,
inputs
ORDER BY
LENGTH(inputs)
) = 1
),
event_types AS (
SELECT
contract_address,
_inserted_timestamp,
inputs,
anonymous,
NAME,
ARRAY_AGG(
VALUE :type :: STRING
) AS event_type
FROM
flat_event_abi,
LATERAL FLATTEN (
input => inputs
)
GROUP BY
contract_address,
_inserted_timestamp,
inputs,
anonymous,
NAME
),
apply_event_udfs AS (
SELECT
contract_address,
NAME AS event_name,
PARSE_JSON(
OBJECT_CONSTRUCT(
'anonymous',
anonymous,
'inputs',
inputs,
'name',
NAME,
'type',
'event'
) :: STRING
) AS abi,
utils.udf_evm_text_signature(abi) AS simple_event_name,
utils.udf_keccak256(simple_event_name) AS event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp
FROM
event_types
),
final_flat_event_abis AS (
SELECT
contract_address,
event_name,
abi,
simple_event_name,
event_signature,
NAME,
inputs,
event_type,
_inserted_timestamp
FROM
apply_event_udfs
),
flat_function_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
VALUE :inputs AS inputs,
VALUE :outputs AS outputs,
VALUE :payable :: BOOLEAN AS payable,
VALUE :stateMutability :: STRING AS stateMutability,
VALUE :type :: STRING AS TYPE,
VALUE :name :: STRING AS NAME
FROM
base,
LATERAL FLATTEN (
input => DATA
)
WHERE
TYPE = 'function'
),
udf_function_abis AS (
SELECT
*,
PARSE_JSON(
object_construct_keep_null(
'inputs',
IFNULL(
inputs,
[]
),
'outputs',
IFNULL(
outputs,
[]
),
'name',
NAME,
'type',
'function'
) :: STRING
) AS abi,
utils.udf_evm_text_signature(abi) AS simple_function_name,
utils.udf_keccak256(simple_function_name) AS function_signature
FROM
flat_function_abis qualify ROW_NUMBER() over (
PARTITION BY contract_address,
function_signature
ORDER BY
_inserted_timestamp DESC
) = 1
),
flat_inputs AS (
SELECT
contract_address,
inputs,
NAME,
simple_function_name,
function_signature,
ARRAY_AGG(
VALUE :type :: STRING
) AS inputs_type
FROM
udf_function_abis,
LATERAL FLATTEN (
input => inputs
)
GROUP BY
ALL
),
fill_missing_input_names AS (
SELECT
contract_address,
NAME,
inputs_type,
simple_function_name,
function_signature,
VALUE :internalType :: STRING AS internalType,
VALUE :type :: STRING AS TYPE,
CASE
WHEN VALUE :name :: STRING = '' THEN CONCAT('input_', ROW_NUMBER() over (PARTITION BY contract_address, function_signature
ORDER BY
INDEX ASC) :: STRING)
ELSE VALUE :name :: STRING
END AS name_fixed,
inputs,
INDEX,
VALUE :components AS components
FROM
flat_inputs,
LATERAL FLATTEN (
input => inputs
)
),
final_flat_inputs AS (
SELECT
contract_address,
NAME,
inputs_type,
simple_function_name,
function_signature,
ARRAY_AGG(
OBJECT_CONSTRUCT(
'internalType',
internalType,
'name',
name_fixed,
'type',
TYPE,
'components',
components
)
) within GROUP (
ORDER BY
INDEX
) AS inputs
FROM
fill_missing_input_names
GROUP BY
ALL
),
flat_outputs AS (
SELECT
contract_address,
outputs,
simple_function_name,
function_signature,
NAME,
ARRAY_AGG(
VALUE :type :: STRING
) AS outputs_type
FROM
udf_function_abis,
LATERAL FLATTEN (
input => outputs
)
GROUP BY
ALL
),
fill_missing_output_names AS (
SELECT
contract_address,
NAME,
outputs_type,
simple_function_name,
function_signature,
VALUE :internalType :: STRING AS internalType,
VALUE :type :: STRING AS TYPE,
CASE
WHEN VALUE :name :: STRING = '' THEN CONCAT('output_', ROW_NUMBER() over (PARTITION BY contract_address, function_signature
ORDER BY
INDEX ASC) :: STRING)
ELSE VALUE :name :: STRING
END AS name_fixed,
outputs,
INDEX,
VALUE :components AS components
FROM
flat_outputs,
LATERAL FLATTEN (
input => outputs
)
),
final_flat_outputs AS (
SELECT
contract_address,
NAME,
outputs_type,
simple_function_name,
function_signature,
ARRAY_AGG(
OBJECT_CONSTRUCT(
'internalType',
internalType,
'name',
name_fixed,
'type',
TYPE,
'components',
components
)
) within GROUP (
ORDER BY
INDEX
) AS outputs
FROM
fill_missing_output_names
GROUP BY
ALL
),
all_contracts AS (
SELECT
A.contract_address,
A.name AS function_name,
i.inputs,
o.outputs,
i.inputs_type,
o.outputs_type,
A._inserted_timestamp,
A.function_signature,
A.simple_function_name
FROM
udf_function_abis A
LEFT JOIN final_flat_inputs i
ON A.contract_address = i.contract_address
AND A.function_signature = i.function_signature
LEFT JOIN final_flat_outputs o
ON A.contract_address = o.contract_address
AND A.function_signature = o.function_signature
),
apply_function_udfs AS (
SELECT
contract_address,
function_name,
PARSE_JSON(
object_construct_keep_null(
'inputs',
IFNULL(
inputs,
[]
),
'outputs',
IFNULL(
outputs,
[]
),
'name',
function_name,
'type',
'function'
) :: STRING
) AS abi,
simple_function_name,
function_signature,
inputs,
outputs,
inputs_type,
outputs_type,
_inserted_timestamp
FROM
all_contracts
),
final_function_abis AS (
SELECT
contract_address,
function_name,
abi,
simple_function_name,
function_signature,
inputs,
outputs,
inputs_type,
outputs_type,
_inserted_timestamp
FROM
apply_function_udfs
),
new_abis AS (
SELECT
DISTINCT contract_address
FROM
base
),
contracts AS (
SELECT
contract_address
FROM
{{ ref('silver__proxies') }}
JOIN new_abis USING (contract_address)
),
proxies AS (
SELECT
p.proxy_address,
p.contract_address
FROM
{{ ref('silver__proxies') }}
p
JOIN new_abis n
ON p.proxy_address = n.contract_address
),
final_groupings AS (
SELECT
b.contract_address AS address,
C.contract_address,
proxy_address,
CASE
WHEN C.contract_address IS NOT NULL
AND proxy_address IS NOT NULL THEN 'contract'
WHEN C.contract_address IS NOT NULL THEN 'contract'
WHEN proxy_address IS NOT NULL THEN 'proxy'
WHEN C.contract_address IS NULL
AND proxy_address IS NULL THEN 'contract'
END AS TYPE,
p.contract_address AS proxy_parent,
CASE
WHEN TYPE = 'contract' THEN address
ELSE proxy_parent
END AS final_address
FROM
base b
LEFT JOIN (
SELECT
DISTINCT contract_address
FROM
contracts
) C
ON b.contract_address = C.contract_address
LEFT JOIN (
SELECT
DISTINCT proxy_address,
contract_address
FROM
proxies
) p
ON b.contract_address = proxy_address
),
identified_addresses AS (
SELECT
DISTINCT address AS base_address,
final_address AS contract_address
FROM
final_groupings
),
function_mapping AS (
SELECT
ia.base_address,
ia.contract_address,
LEFT(
function_signature,
10
) AS function_sig
FROM
identified_addresses ia
JOIN final_function_abis ffa
ON ia.base_address = ffa.contract_address
),
valid_traces AS (
SELECT
DISTINCT base_address
FROM
(
SELECT
base_address
FROM
{{ ref('core__fact_traces') }}
JOIN function_mapping
ON function_sig = LEFT(
input,
10
)
AND IFF(
TYPE = 'DELEGATECALL',
from_address,
to_address
) = contract_address
WHERE
block_timestamp > DATEADD('month', -12, SYSDATE())
LIMIT
50000)
), event_mapping AS (
SELECT
ia.base_address,
ia.contract_address,
event_signature
FROM
identified_addresses ia
JOIN final_flat_event_abis fea
ON ia.base_address = fea.contract_address
),
valid_logs AS (
SELECT
DISTINCT base_address
FROM
(
SELECT
base_address
FROM
{{ ref('core__fact_event_logs') }}
l
JOIN event_mapping ia
ON ia.contract_address = l.contract_address
AND event_signature = topics [0] :: STRING
WHERE
block_timestamp > DATEADD('month', -12, SYSDATE())
LIMIT
50000)
), all_valid_addresses AS (
SELECT
base_address
FROM
valid_traces
UNION
SELECT
base_address
FROM
valid_logs
)
SELECT
contract_address,
abi,
discord_username,
_inserted_timestamp,
abi_hash,
CONCAT(
contract_address,
'-',
abi_hash
) AS id
FROM
base
WHERE
contract_address IN (
SELECT
base_address
FROM
all_valid_addresses
) qualify(ROW_NUMBER() over(PARTITION BY contract_address
ORDER BY
_inserted_timestamp DESC)) = 1

View File

@ -1,7 +0,0 @@
version: 2
models:
- name: silver__user_verified_abis
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- ID

View File

@ -1,108 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = "contract_address",
tags = ['abis']
) }}
WITH base AS (
SELECT
contract_address,
PARSE_JSON(
abi_data :data :result
) AS DATA,
_inserted_timestamp
FROM
{{ ref('bronze_api__contract_abis') }}
WHERE
abi_data :data :message :: STRING = 'OK'
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
COALESCE(
MAX(
_inserted_timestamp
),
'1970-01-01'
)
FROM
{{ this }}
)
{% endif %}
),
arbscan_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
'arbscan' AS abi_source
FROM
base
),
user_abis AS (
SELECT
contract_address,
abi,
discord_username,
_inserted_timestamp,
'user' AS abi_source,
abi_hash
FROM
{{ ref('silver__user_verified_abis') }}
{% if is_incremental() %}
WHERE
_inserted_timestamp >= (
SELECT
COALESCE(
MAX(
_inserted_timestamp
),
'1970-01-01'
)
FROM
{{ this }}
WHERE
abi_source = 'user'
)
AND contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
{% endif %}
),
all_abis AS (
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
NULL AS discord_username,
SHA2(DATA) AS abi_hash
FROM
arbscan_abis
UNION
SELECT
contract_address,
PARSE_JSON(abi) AS DATA,
_inserted_timestamp,
'user' AS abi_source,
discord_username,
abi_hash
FROM
user_abis
)
SELECT
contract_address,
DATA,
_inserted_timestamp,
abi_source,
discord_username,
abi_hash
FROM
all_abis qualify(ROW_NUMBER() over(PARTITION BY contract_address
ORDER BY
_INSERTED_TIMESTAMP DESC)) = 1

Some files were not shown because too many files have changed in this diff Show More