Skip to main content
Schema: near.defi Table: fact_dex_swaps Type: Base Table

Description

This table contains all decentralized exchange (DEX) swap transactions on the NEAR Protocol blockchain, capturing token swaps across various DEX protocols including Ref Finance, Orderly Network, and other automated market makers. The data includes swap details such as input/output tokens, amounts, prices, and protocol-specific metadata. This table provides the foundation for DeFi analytics, trading volume analysis, and liquidity pool performance tracking across the NEAR ecosystem.

Key Use Cases

  • DEX trading volume analysis and market activity monitoring
  • Token pair liquidity analysis and trading pattern identification
  • Price impact analysis and slippage calculation
  • DEX protocol comparison and performance benchmarking
  • Arbitrage opportunity detection and analysis
  • Trading bot activity monitoring and pattern recognition
  • DeFi protocol integration analysis and cross-protocol flows

Important Relationships

  • Links to core.fact_transactions through tx_hash for transaction context
  • Connects to core.fact_blocks through block_id for temporal context
  • Provides swap data for defi.ez_dex_swaps with enhanced metadata and pricing
  • Supports defi.ez_intents with swap execution analysis
  • Enables analysis in stats.ez_core_metrics_hourly for DeFi metrics
  • Powers cross-protocol analysis with other DeFi activities

Commonly-used Fields

  • tx_hash: Essential for linking to transaction details and verification
  • block_timestamp: Primary field for time-series analysis and trend detection
  • token_in and token_out: Critical for token pair analysis and trading patterns
  • amount_in_raw and amount_out_raw: Important for swap size analysis and volume calculations
  • receiver_id and signer_id: Essential for user behavior analysis and trader identification
  • swap_index: Important for multi-swap transaction analysis
  • swap_input_data: Useful for detailed swap parameter analysis

Columns

Column NameData TypeDescription
TX_HASHTEXTUnique identifier (hash) of this transaction.
RECEIPT_IDTEXT
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 predecessor_id, 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 tx_receiver 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.
SWAP_INDEXNUMBERThe positon index for the record in question, if it was stored in a particular order.
AMOUNT_OUT_RAWNUMBERAmount out, in a swap or transfer, in adjusted form.
TOKEN_OUTTEXTThe address of the token being swapped to.
AMOUNT_IN_RAWNUMBERAmount in, in a swap or transfer, in adjusted form.
TOKEN_INTEXTThe address of the token sent for swap.
SWAP_INPUT_DATAVARIANTJSON of input data for the swap, taken from the FunctionCall JSON.
Note, directional keys such as in and out are determined by the pool.
LOGTEXTThe logs linked to the transaction.
FACT_DEX_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.