Skip to main content
Schema: near.intents Table: fact_swaps Type: Base Table

What

Description

The intents__fact_swaps table tracks swap transactions executed through the NEAR Protocol intents system (intents.near contract). This table captures token exchanges facilitated by the DIP4 (Decentralized Intent Protocol 4) standard, which enables intent-based trading where users specify desired outcomes rather than explicit execution paths. The table aggregates token_diff events from intent executions to identify swap pairs (token in/token out) and their corresponding amounts. Data is sourced from intents__fact_transactions and enriched with action and log data to provide complete context for each swap. The table applies sophisticated logic to identify swap transactions from multi-token transfer events, determining input and output tokens based on balance changes recorded in DIP4 token_diff events.

Key Use Cases

  • Intent-Based Swap Analytics: Track swap volume, frequency, and patterns for intent-driven trading on NEAR
  • Token Pair Analysis: Analyze which token pairs are most commonly swapped through the intents protocol
  • User Behavior Analysis: Understand how users interact with intent-based swap execution
  • Referral Tracking: Monitor referral activity and attribution for intent-based swaps
  • Protocol Metrics: Calculate swap success rates, gas costs, and execution patterns for intent transactions

Important Relationships

This table is part of the intents schema and relates to:
  • intents.fact_transactions: Source table providing base intent transaction data with NEP245 and DIP4 events
  • intents.ez_transactions: Enriched view of intent transactions with token metadata and pricing
  • core.ez_actions: Provides transaction-level context including signer and action details
  • silver.logs_s3: Source of raw log data for parsing DIP4 token_diff events

Commonly-used Fields

  • intent_hash: Unique identifier for the intent execution, used to track related transactions
  • token_in / token_out: Token identifiers (with nep141/nep245 prefixes) showing what was received/sent
  • amount_in_raw / amount_out_raw: Unadjusted token amounts (before decimal conversion) for in/out tokens
  • account_id: The account that initiated or owns the intent execution
  • referral: Optional referral account that facilitated the swap
  • swap_index: Index for multiple swaps within a single transaction
  • swap_input_data: JSON object containing detailed swap execution parameters and token_diff data

Columns

Column NameData TypeDescription
TX_HASHTEXTUnique identifier (hash) of this transaction.
RECEIPT_IDTEXTThe identifying hash for a receipt.
BLOCK_IDNUMBERThe height of the chain this block corresponds with.
BLOCK_TIMESTAMPTIMESTAMP_NTZThe date and time at which the block began.
RECEIVER_IDTEXTAccount reacting to the receipt from predecessorid, can be relay, a contract, or a user of a relay, etc. This field identifies the account that is processing the receipt and executing the associated action. In most cases, this is a smart contract that is being called, but it can also be a user account in relay transactions or the system account for certain operations. This differs from txreceiver and is specific to the receipt being processed.
SIGNER_IDTEXTSigner of the receipt, often same as tx_signer, sometimes system in the case of systemic gas refunds. This field identifies the account that has the authority to execute the receipt. In most cases, this is the same as the transaction signer, but in system operations like gas refunds, this may be the system account. The signer is the account that originally signed the transaction that began the blockchain activity, which may or may not include cross-contract calls.
INTENT_HASHTEXTUnique hash identifier for the intent, extracted from the DIP4 event log. This hash uniquely identifies the specific intent execution and can be used to track and correlate all activities related to a particular intent across different tables and events. The intent hash is generated by the intent protocol and serves as the primary reference for linking intent-related data including fees, transfers, and execution details.
ACCOUNT_IDTEXTNEAR account ID that initiated the intent execution. This field identifies the user or contract account that created and submitted the intent to the protocol. In intent-based systems, this represents the account whose desired outcome is being fulfilled by the intent execution, and who typically pays fees for the service.
REFERRALTEXTID of the referring protocol, as extracted from the Receipt log.
SWAP_INDEXNUMBERThe positon index for the record in question, if it was stored in a particular order.
AMOUNT_OUT_RAWTEXTAmount out, in a swap or transfer, in adjusted form.
TOKEN_OUTTEXTThe address of the token being swapped to.
AMOUNT_IN_RAWTEXTAmount in, in a swap or transfer, in adjusted form.
TOKEN_INTEXTThe address of the token sent for swap.
SWAP_INPUT_DATAOBJECTJSON of input data for the swap, taken from the FunctionCall JSON. Note, directional keys such as in and out are determined by the pool.
LOGTEXTA single log extracted from a receipt.
_PARTITION_BY_BLOCK_NUMBERNUMBERBlock number grouping for ingestion partition
FACT_SWAPS_IDTEXTA unique identifier for the record.
INSERTED_TIMESTAMPTIMESTAMP_NTZThe timestamp at which the record was initially created and inserted into this table.
MODIFIED_TIMESTAMPTIMESTAMP_NTZThe timestamp at which this record was last modified by an internal process.
_INVOCATION_IDTEXTA job ID to identify the run that last modified a record.