From 94276815410fe3c824af0ed3c9c7f6ac72f219c9 Mon Sep 17 00:00:00 2001 From: Eric Laurello Date: Mon, 3 Nov 2025 16:45:17 -0500 Subject: [PATCH] . --- models/gold/core/core__ez_cex_flows.sql | 41 ++++++++++++++++ models/gold/core/core__ez_cex_flows.yml | 62 +++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 models/gold/core/core__ez_cex_flows.sql create mode 100644 models/gold/core/core__ez_cex_flows.yml diff --git a/models/gold/core/core__ez_cex_flows.sql b/models/gold/core/core__ez_cex_flows.sql new file mode 100644 index 0000000..9c87777 --- /dev/null +++ b/models/gold/core/core__ez_cex_flows.sql @@ -0,0 +1,41 @@ +{{ config( + materialized = 'view', + tags = ['scheduled_non_core'] +) }} + +WITH labels AS ( + + SELECT + address, + label_subtype, + project_name AS exchange_name + FROM + {{ ref('core__dim_address_labels') }} + WHERE + label_type = 'cex' +) +SELECT + A.*, + COALESCE( + from_label.exchange_name, + to_label.exchange_name + ) AS exchange_name, + CASE + WHEN from_label.address IS NOT NULL + AND to_label.address IS NULL THEN 'withdrawal' + WHEN to_label.address IS NOT NULL + AND from_label.address IS NULL THEN 'deposit' + WHEN from_label.address IS NOT NULL + AND to_label.address IS NOT NULL THEN 'internal_transfer' + END AS direction +FROM + {{ ref('core__ez_token_transfers') }} A + LEFT JOIN labels from_label + ON A.from_address = from_label.address + LEFT JOIN labels to_label + ON A.to_address = to_label.address +WHERE + COALESCE( + to_label.address, + from_label.address + ) IS NOT NULL diff --git a/models/gold/core/core__ez_cex_flows.yml b/models/gold/core/core__ez_cex_flows.yml new file mode 100644 index 0000000..b739913 --- /dev/null +++ b/models/gold/core/core__ez_cex_flows.yml @@ -0,0 +1,62 @@ +version: 2 + +models: + - name: core__ez_cex_flows + description: "An EZ view that filters down to transfers involving centralized exchanges -- full ez_token_transfers continued here: {{ doc('core__ez_token_transfers') }}" + + columns: + - name: BLOCK_ID + description: "{{ doc('block_id')}}" + + - name: BLOCK_TIMESTAMP + description: "{{ doc('block_timestamp')}}" + - name: TX_HASH + description: "{{ doc('tx_hash')}}" + + - name: CONTRACT_ADDRESS + description: "{{ doc('contract_address')}}" + + - name: FROM_ADDRESS + description: "{{ doc('from_address')}}" + + - name: TO_ADDRESS + description: "{{ doc('to_address')}}" + + - name: MEMO + description: "{{ doc('memo')}}" + + - name: AMOUNT_RAW + description: "{{ doc('amount_raw')}}" + + - name: AMOUNT_RAW_PRECISE + description: "{{ doc('amount_adj')}}" + + - name: TRANSFER_TYPE + description: "{{ doc('transfer_type')}}" + + - name: HAS_PRICE + description: "Boolean value indicating if the token has a price" + + - name: TRANSFER_ACTION + description: "{{ doc('transfer_action')}}" + + - name: RECEIPT_SUCCEEDED + description: "{{ doc('receipt_succeeded')}}" + + - name: EZ_TOKEN_TRANSFERS_ID + description: "{{doc('id')}}" + + - name: INSERTED_TIMESTAMP + description: "{{doc('inserted_timestamp')}}" + + - name: MODIFIED_TIMESTAMP + description: "{{doc('modified_timestamp')}}" + + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" + + - name: EXCHANGE_NAME + description: "The name of the centralized exchange associated with the address label" + + - name: DIRECTION + description: "The direction of the transfer relative to the exchange (withdrawal or deposit or internal_transfer)"