diff --git a/models/descriptions/amount_usd.md b/models/descriptions/amount_usd.md new file mode 100644 index 00000000..7e2378ec --- /dev/null +++ b/models/descriptions/amount_usd.md @@ -0,0 +1,13 @@ +{% docs amount_usd %} + +The USD value of the transferred amount, calculated using the token price at the time of the transfer. This field enables value-based analytics and comparisons across different tokens. + +**Data type:** Numeric (decimal) +**Example:** +- 123.45 (represents $123.45 USD) + +**Business Context:** +- Used for tracking transaction volumes, wallet activity, and payment flows in USD terms. +- Supports analytics on large value transfers, protocol revenue, and user behavior. + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/symbol.md b/models/descriptions/symbol.md new file mode 100644 index 00000000..ea12b058 --- /dev/null +++ b/models/descriptions/symbol.md @@ -0,0 +1,14 @@ +{% docs symbol %} + +The symbol of the token involved in the transfer (e.g., SOL, USDC, RAY). Used to identify the asset type in analytics and reporting. + +**Data type:** String +**Example:** +- SOL +- USDC + +**Business Context:** +- Enables grouping and filtering of transfers by token. +- Supports analytics on asset flows, protocol usage, and user preferences. + +{% enddocs %} \ No newline at end of file diff --git a/models/gold/core/core__ez_transfers.sql b/models/gold/core/core__ez_transfers.sql new file mode 100644 index 00000000..8315090e --- /dev/null +++ b/models/gold/core/core__ez_transfers.sql @@ -0,0 +1,37 @@ +{{ config( + materialized = 'view', + tags = ['scheduled_core', 'exclude_change_tracking'] +) }} + +SELECT + a.block_timestamp, + a.block_id, + a.tx_id, + COALESCE(SPLIT_PART(a.INDEX :: text, '.', 1) :: INT, a.INDEX :: INT) AS index, + NULLIF(SPLIT_PART(a.INDEX :: text, '.', 2), '') :: INT AS inner_index, + a.tx_from, + a.tx_to, + a.amount, + a.amount * p.price AS amount_usd, + a.mint, + COALESCE( + p.symbol, + b.symbol + ) AS symbol, + COALESCE( + p.is_verified, + FALSE + ) AS token_is_verified, + a.fact_transfers_id AS ez_transfers_id, + a.inserted_timestamp, + a.modified_timestamp +FROM + {{ ref('core__fact_transfers') }} a + LEFT JOIN {{ ref('price__ez_asset_metadata') }} b + ON a.mint = b.token_address + LEFT JOIN {{ ref('price__ez_prices_hourly') }} p + ON a.mint = p.token_address + AND DATE_TRUNC( + 'hour', + a.block_timestamp + ) = p.hour diff --git a/models/gold/core/core__ez_transfers.yml b/models/gold/core/core__ez_transfers.yml new file mode 100644 index 00000000..bce4feb0 --- /dev/null +++ b/models/gold/core/core__ez_transfers.yml @@ -0,0 +1,36 @@ +version: 2 +models: + - name: core__ez_transfers + description: |- + Contains transfer events for Solana and SPL tokens, including pre-parsed transfer amounts, USD value, token symbol, and verification status. This table is best for analytics on asset movement, wallet activity, payment flows, and large value transfers. + columns: + - name: BLOCK_TIMESTAMP + description: "{{ doc('block_timestamp') }}" + - name: BLOCK_ID + description: "{{ doc('block_id') }}" + - name: TX_ID + description: "{{ doc('tx_id') }}" + - name: INDEX + description: "{{ doc('index') }}" + - name: INNER_INDEX + description: "{{ doc('inner_index') }}" + - name: TX_FROM + description: "{{ doc('tx_from') }}" + - name: TX_TO + description: "{{ doc('tx_to') }}" + - name: AMOUNT + description: "{{ doc('amount') }}" + - name: AMOUNT_USD + description: "{{ doc('amount_usd') }}" + - name: MINT + description: "{{ doc('mint') }}" + - name: SYMBOL + description: "{{ doc('symbol') }}" + - name: TOKEN_IS_VERIFIED + description: '{{ doc("prices_is_verified") }}' + - name: EZ_TRANSFERS_ID + description: '{{ doc("pk") }}' + - name: INSERTED_TIMESTAMP + description: '{{ doc("inserted_timestamp") }}' + - name: MODIFIED_TIMESTAMP + description: '{{ doc("modified_timestamp") }}'