Merge pull request #507 from FlipsideCrypto/DAT2-141-docs
Some checks failed
docs_update / docs_update (push) Has been cancelled
docs_update / notify-failure (push) Has been cancelled
dbt_run_streamline_non_core_weekly / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_non_core_weekly / notify-failure (push) Has been cancelled
dbt_test_scheduled / run_dbt_jobs (push) Has been cancelled
dbt_run_observability / run_dbt_jobs (push) Has been cancelled
dbt_run_scheduled_non_core / run_dbt_jobs (push) Has been cancelled
dbt_run_dev_refresh / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_blocks_realtime / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_chunks_realtime / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_transactions_realtime / run_dbt_jobs (push) Has been cancelled
dbt_run_scheduled_core / run_dbt_jobs (push) Has been cancelled
dbt_run_observability / notify-failure (push) Has been cancelled
dbt_run_scheduled_non_core / notify-failure (push) Has been cancelled
dbt_run_dev_refresh / notify-failure (push) Has been cancelled
dbt_run_streamline_blocks_realtime / notify-failure (push) Has been cancelled
dbt_run_streamline_chunks_realtime / notify-failure (push) Has been cancelled
dbt_run_streamline_transactions_realtime / notify-failure (push) Has been cancelled
dbt_run_scheduled_core / notify-failure (push) Has been cancelled
dbt_run_full_observability / run_dbt_jobs (push) Has been cancelled
dbt_run_full_observability / notify-failure (push) Has been cancelled

DAT2-141/upd intents table doc
This commit is contained in:
Jack Forgash 2025-11-13 15:35:43 -07:00 committed by GitHub
commit bc4dea274f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,16 +1,100 @@
{% docs defi__ez_intents %} {% docs defi__ez_intents %}
## Description ## Description
This table provides an enhanced view of all intent-based transactions on the NEAR Protocol blockchain, combining raw intent data with token metadata, pricing information, and cross-chain mapping details. The table includes both NEP-245 and DIP-4 standard intents with decimal adjustments, USD values, and comprehensive token context. This easy view eliminates the need for complex joins and calculations, providing ready-to-use data for intent-based trading analysis and MEV protection mechanism evaluation. This table provides an enhanced view of all intent-based transactions on the NEAR Protocol blockchain, combining raw intent data with token metadata, pricing information, and cross-chain mapping details. The table includes both NEP-245 and DIP-4 standard intents with decimal adjustments, USD values, and comprehensive token context.
**CRITICAL**: Each intent consists of multiple transaction steps (rows) representing the complete transfer flow: input (user → solver), output (solver → user), fees, and optional routing. Each unique intent is identified by `tx_hash` + `log_index`. Summing all `amount_usd` values will overcount volume by 2-3x because it counts input + output + fees separately.
## How to Use This Table
### Volume Calculation (Recommended Method)
**Use MAX per intent** to avoid 2-3x overcounting:
```sql
WITH intent_volumes AS (
SELECT
tx_hash,
log_index,
MAX(amount_usd) as intent_volume
FROM near.defi.ez_intents
WHERE amount_usd > 0.01 -- Exclude dust/fees
GROUP BY tx_hash, log_index -- BOTH fields required
)
SELECT SUM(intent_volume) as total_volume
FROM intent_volumes;
```
**Why MAX works**: Input ≈ output amounts (differ only by small fees). MAX captures the true swap size while ignoring dust.
### Common Query Patterns
**Daily volume by token:**
```sql
WITH intent_volumes AS (
SELECT
DATE_TRUNC('day', block_timestamp) as date,
tx_hash, log_index, symbol,
MAX(amount_usd) as volume
FROM near.defi.ez_intents
WHERE amount_usd > 0.01
GROUP BY date, tx_hash, log_index, symbol
)
SELECT date, symbol, SUM(volume) as daily_volume
FROM intent_volumes
GROUP BY date, symbol;
```
**Cross-chain flows:**
```sql
WITH flows AS (
SELECT
tx_hash, log_index,
MIN(blockchain) as source_chain,
MAX(blockchain) as dest_chain,
MAX(amount_usd) as volume
FROM near.defi.ez_intents
WHERE amount_usd > 0.01
GROUP BY tx_hash, log_index
)
SELECT source_chain, dest_chain, SUM(volume) as total_volume
FROM flows
GROUP BY source_chain, dest_chain;
```
**Top users:**
```sql
WITH users AS (
SELECT
old_owner_id as user,
tx_hash, log_index,
MAX(amount_usd) as volume
FROM near.defi.ez_intents
WHERE amount_usd > 0.01
GROUP BY user, tx_hash, log_index
)
SELECT user, SUM(volume) as total_volume
FROM users
GROUP BY user;
```
### Validation
Check if you're calculating correctly:
```sql
SELECT
AVG(SUM(amount_usd) / NULLIF(MAX(amount_usd), 0)) as avg_ratio
FROM near.defi.ez_intents
WHERE amount_usd > 0.01
GROUP BY tx_hash, log_index;
```
**Expected**: ~1.5-2.0. If higher, you're likely overcounting.
## Key Use Cases ## Key Use Cases
- Intent-based trading analysis with accurate decimal-adjusted amounts and USD values - Intent-based trading volume analysis with accurate calculations
- MEV protection mechanism effectiveness analysis with economic impact - Cross-chain swap tracking and flow analysis
- User behavior analysis in intent-driven protocols with value context - User behavior analysis in intent-driven protocols
- Cross-protocol intent execution tracking and performance comparison - Referral program effectiveness measurement
- Intent fulfillment rate analysis and optimization with value calculations - Intent fulfillment rate analysis (use `receipt_succeeded`)
- Referral program analysis and user acquisition tracking - MEV protection mechanism evaluation
- Intent-based DeFi protocol performance monitoring and benchmarking
## Important Relationships ## Important Relationships
- Enhances `defi.fact_intents` with pricing and metadata from `price.ez_prices_hourly` - Enhances `defi.fact_intents` with pricing and metadata from `price.ez_prices_hourly`
@ -20,12 +104,15 @@ This table provides an enhanced view of all intent-based transactions on the NEA
- Powers cross-protocol analysis with other DeFi activities - Powers cross-protocol analysis with other DeFi activities
## Commonly-used Fields ## Commonly-used Fields
- `amount` and `amount_usd`: Essential for accurate intent value analysis - `tx_hash` + `log_index`: **Unique intent identifier** - MUST group by both for accurate volume calculations
- `block_timestamp`: Primary field for time-series analysis and trend detection - `amount_usd`: Intent value in USD - use with MAX() per intent to avoid overcounting
- `log_event`: Critical for intent type classification and analysis - `symbol`: Token symbol for token-specific analysis (USDT, NEAR, ETH, etc.)
- `owner_id`: Important for user behavior analysis and intent tracking - `blockchain`: Source/destination chain (near, eth, bsc, sol, etc.) for cross-chain flow analysis
- `token_id` and `symbol`: Essential for token-specific intent analysis - `old_owner_id` / `new_owner_id`: Sender/recipient addresses - use `old_owner_id` to identify intent initiator
- `referral`: Important for referral program analysis and user acquisition - `log_event_index`: Step order within intent - useful for understanding transaction flow
- `receipt_succeeded`: Critical for intent fulfillment rate analysis - `block_timestamp`: Time of transaction - use for time-series analysis and filtering
- `receipt_succeeded`: Transaction success status - filter to TRUE for successful intents only
- `referral`: Referral address for referral program analysis
- `fee_amount_usd`: Fee collected in USD - separate from main intent volume
{% enddocs %} {% enddocs %}