Skip to main content
Schema: solana.defi Table: ez_lending_borrows Type: Base Table

What

Description

This table captures borrow events across Solana DeFi lending protocols including Kamino and MarginFi. Each row represents a single borrowing transaction where users take loans against their deposited collateral. The data includes enriched transaction details with USD pricing, token metadata, and protocol identification, supporting comprehensive analytics on lending market demand-side activity and borrowing behavior patterns.

Key Use Cases

  • Track borrowing activity and capital utilization across lending protocols
  • Analyze user borrowing patterns and leverage strategies
  • Monitor borrowed asset composition and demand trends
  • Study protocol usage and borrowing preference analysis
  • Calculate borrowing costs and interest rate analysis
  • Support credit risk assessment and loan performance tracking

Important Relationships

  • Related to defi.ez_lending_deposits for analyzing collateral backing borrowed amounts
  • Related to defi.ez_lending_repayments for tracking loan lifecycle and repayment behavior
  • Related to defi.ez_lending_liquidations for analyzing defaults and risk events
  • Connects to core.ez_transfers for underlying asset movement verification
  • Links to price.ez_prices_hourly for USD valuation and loan-to-value calculations

Commonly-used Fields

  • block_timestamp: For time-series analysis and borrowing timing patterns
  • platform, protocol: For protocol-specific analysis and borrowing market share
  • borrower: For user behavior analysis and borrowing pattern identification
  • token_address, token_symbol: For asset-specific borrowing demand analysis
  • amount, amount_usd: For borrowing volume analysis and market size metrics
  • protocol_market: For market-specific borrowing rates and utilization tracking

Sample Queries

Daily borrowing volume by protocol

-- Daily borrowing volume by protocol
SELECT 
    DATE_TRUNC('day', block_timestamp) AS date,
    platform,
    COUNT(DISTINCT tx_id) AS borrow_txns,
    COUNT(DISTINCT borrower) AS unique_borrowers,
    SUM(amount_usd) AS volume_usd
FROM solana.defi.ez_lending_borrows
WHERE block_timestamp >= CURRENT_DATE - 30
    AND amount_usd IS NOT NULL
GROUP BY 1, 2
ORDER BY 1 DESC, 5 DESC;

Top borrowed assets analysis

-- Top borrowed assets analysis
SELECT 
    token_symbol,
    token_address,
    COUNT(*) AS borrow_count,
    SUM(amount) AS total_borrowed,
    SUM(amount_usd) AS total_borrowed_usd,
    AVG(amount_usd) AS avg_borrow_size_usd
FROM solana.defi.ez_lending_borrows
WHERE block_timestamp >= CURRENT_DATE - 7
    AND token_symbol IS NOT NULL
GROUP BY 1, 2
ORDER BY 5 DESC
LIMIT 20;

Wallet specific borrow analysis

-- Wallet Specific Borrow Analysis
SELECT 
    b.borrower,
    b.token_address AS borrowed_token_address,
    b.token_symbol AS borrowed_token_symbol,
    DATE_TRUNC('week', b.block_timestamp) AS weekly_block_timestamp,
    SUM(b.amount) AS total_borrow_amount,
    SUM(b.amount_usd) AS total_borrow_usd,
    SUM(r.amount) AS total_repayment_amount,
    SUM(r.amount_usd) AS total_repayment_usd,
    SUM(b.amount) - COALESCE(SUM(r.amount), 0) AS net_borrowed_amount,
    SUM(b.amount_usd) - COALESCE(SUM(r.amount_usd), 0) AS net_borrowed_usd
FROM 
    solana.defi.ez_lending_borrows b
LEFT JOIN solana.defi.ez_lending_repayments r
    ON b.borrower = r.payer
    AND b.token_address = r.token_address
WHERE 
    b.borrower = LOWER('<user_address>')
GROUP BY 1, 2, 3, 4
ORDER BY 4 DESC;

User borrowing patterns

-- User borrowing patterns
WITH user_stats AS (
    SELECT 
        borrower,
        COUNT(DISTINCT DATE_TRUNC('day', block_timestamp)) AS active_days,
        COUNT(DISTINCT platform) AS platforms_used,
        COUNT(DISTINCT token_address) AS assets_borrowed,
        SUM(amount_usd) AS total_borrowed_usd,
        AVG(amount_usd) AS avg_borrow_size
    FROM solana.defi.ez_lending_borrows
    WHERE block_timestamp >= CURRENT_DATE - 30
        AND amount_usd IS NOT NULL
    GROUP BY 1
)
SELECT 
    CASE 
        WHEN total_borrowed_usd < 1000 THEN '< $1K'
        WHEN total_borrowed_usd < 10000 THEN '$1K - $10K'
        WHEN total_borrowed_usd < 100000 THEN '$10K - $100K'
        ELSE '> $100K'
    END AS borrower_tier,
    COUNT(*) AS user_count,
    AVG(active_days) AS avg_active_days,
    AVG(platforms_used) AS avg_platforms,
    AVG(total_borrowed_usd) AS avg_total_borrowed
FROM user_stats
GROUP BY 1
ORDER BY 5 DESC;

Protocol market share

-- Protocol market share
WITH protocol_volume AS (
    SELECT 
        platform,
        SUM(amount_usd) AS total_volume,
        COUNT(DISTINCT borrower) AS unique_users,
        COUNT(*) AS transaction_count
    FROM solana.defi.ez_lending_borrows
    WHERE block_timestamp >= CURRENT_DATE - 30
        AND amount_usd IS NOT NULL
    GROUP BY 1
)
SELECT 
    platform,
    total_volume,
    total_volume * 100.0 / SUM(total_volume) OVER () AS market_share_pct,
    unique_users,
    transaction_count,
    total_volume / transaction_count AS avg_borrow_size
FROM protocol_volume
ORDER BY total_volume DESC;

Columns

Column NameData TypeDescription
PLATFORMTEXTThe name of the lending platform or protocol where the transaction occurred. This identifies the specific DeFi lending service provider. Data type: STRING Business context: Used to categorize lending activity by platform, analyze platform-specific metrics, and compare lending volumes across different protocols. Analytics use cases: Platform performance analysis, market share tracking, and cross-platform lending behavior studies. Example: ‘kamino’, ‘marginfi v2’
PROTOCOLTEXTThe core protocol name that powers the lending platform. This provides a standardized identifier for the underlying lending technology. Data type: STRING Business context: Used to group related platforms by their underlying protocol technology, enabling analysis of protocol adoption and usage. Analytics use cases: Protocol ecosystem analysis, technology adoption tracking, and protocol performance comparisons. Example: ‘kamino’, ‘marginfi’
VERSIONTEXTThe version identifier of the lending protocol being used. This helps track different iterations and upgrades of lending protocols. Data type: STRING Business context: Used to analyze adoption of protocol upgrades, compare performance across versions, and track protocol evolution. Analytics use cases: Version adoption analysis, upgrade impact assessment, and historical protocol development tracking. Example: ‘v1’, ‘v2’
BLOCK_TIMESTAMPTIMESTAMP_NTZThe timestamp (UTC) at which the block was produced on the Solana blockchain. This field is recorded as a TIMESTAMP data type and represents the precise moment the block was finalized and added to the chain. It is essential for time-series analysis, block production monitoring, and aligning transaction and event data to specific points in time. Used extensively for analytics involving block intervals, network activity trends, and historical lookups. Format: YYYY-MM-DD HH:MI:SS (UTC).
BLOCK_IDNUMBERA unique identifier for the block in which this transaction was included on the Solana blockchain. Typically a sequential integer or hash, depending on the data source. Used to group transactions by block and analyze block-level activity. Example: 123456789 Business Context: Supports block-level analytics, such as block production rate and transaction throughput. Useful for tracing transaction inclusion and block explorer integrations. Relationships: All transactions with the same ‘blockid’ s…
TX_IDTEXTThe unique transaction signature (hash) for each transaction on the Solana blockchain. This field is a base58-encoded string, typically 88 characters in length, and serves as the primary identifier for transactions across all Solana data models. Used to join transaction data with related tables (blocks, events, transfers, logs, decoded instructions) and to trace the full lifecycle and effects of a transaction. Essential for transaction-level analytics, debugging, and cross-referencing with bl…
INDEXNUMBERThe position of the transfer event within the list of events for a given Solana transaction. Used to order and reference transfers within a transaction. Indexing starts at 0 for the first event. Data type: Integer Example: 0 (first transfer in the transaction) 2 (third transfer in the transaction) Business Context: Enables reconstruction of transfer order and analysis of intra-transaction asset movement. Used to join, filter, or segment data for protocol analytics, error tracing, and event se…
INNER_INDEXNUMBERThe position of the inner instruction or event within the list of inner instructions for a given Solana transaction. Used to order and reference nested (CPI) instructions. Indexing starts at 0 for the first inner instruction. Example: 0 2 Business Context: Enables precise identification and ordering of nested program calls (Cross-Program Invocations) within a transaction. Critical for analyzing composability, protocol integrations, and the full execution path of complex transactions.
PROGRAM_IDTEXTThe unique public key (base58-encoded address) of a Solana program. This field identifies the on-chain program (smart contract) responsible for processing instructions, emitting events, or managing accounts. Used throughout Solana analytics models—including events, transactions, IDLs, and program activity tables—to join, filter, and analyze program-level data. Example: “4Nd1mY…” “TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA” Business Context: Used as a join key for program activity, deployme…
EVENT_TYPETEXTA string categorizing the type of event or instruction, such as ‘transfer’, ‘mint’, ‘burn’, or protocol-specific actions. Example: ‘transfer’ ‘mint’ ‘burn’ Business Context: Enables segmentation and filtering of on-chain activity for analytics and dashboards. Used to group and analyze protocol-specific actions and user behaviors. Relationships: May be derived from decoded instruction data or protocol-specific logic.
BORROWERTEXTThe wallet address of the user who is borrowing assets from the lending protocol. This is the recipient of the borrowed funds who becomes responsible for repayment. Data type: STRING (base58 Solana address) Business context: Used to track borrowing behavior, analyze user borrowing patterns, and identify active borrowers in the lending ecosystem. Analytics use cases: Borrower behavior analysis, loan tracking, credit risk assessment, and user segmentation. Example: ‘4Nd1mYw4r…’
PROTOCOL_MARKETTEXTThe protocol-specific token or market identifier that represents the lending pool or reserve. This is typically a wrapped version of the underlying asset used by the protocol for accounting. Data type: STRING (base58 Solana address) Business context: Used to identify specific lending markets within protocols, track market-specific metrics, and analyze asset utilization rates. Analytics use cases: Market performance analysis, asset utilization tracking, and protocol-specific lending pool analy…
TOKEN_ADDRESSTEXTUnique address representing a specific token
TOKEN_SYMBOLTEXTThe symbol of the token involved in the action (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.
TOKEN_IS_VERIFIEDBOOLEANA flag indicating if the asset has been verified by the Flipside team.
AMOUNT_RAWNUMBERUnadjusted amount of tokens as it appears on-chain before decimal precision adjustments are applied. This preserves the exact on-chain representation of the token amount for precise calculations and verification. Data type: NUMBER Business context: Used for precise calculations, audit trails, and verification against on-chain data. Essential for maintaining data integrity and performing exact mathematical operations without rounding errors. Analytics use cases: Precision calculations, data va…
AMOUNTFLOATThe amount of the asset transferred in the event. For native SOL, this is decimal adjusted and is not in Lamports. For SPL tokens, this is decimal adjusted according to the token’s mint. Represents the value moved from sender to recipient in a single transfer event. Data type: Numeric (integer for lamports, decimal for tokens) Example: USDC: 50.00 (represents 50 USDC tokens) Business Context: Used to analyze transaction volumes, user activity, and protocol flows. Supports aggregation of asset…
AMOUNT_USDFLOATThe 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.
EZ_LENDING_BORROWS_IDTEXTA unique, stable identifier for each record in this table. The primary key (PK) ensures that every row is uniquely identifiable and supports efficient joins, lookups, and data integrity across models. The PK may be a natural key (such as a blockchain transaction hash) or a surrogate key generated from one or more fields, depending on the table’s structure and requirements.
INSERTED_TIMESTAMPTIMESTAMP_NTZINSERTED_TIMESTAMP column
MODIFIED_TIMESTAMPTIMESTAMP_NTZMODIFIED_TIMESTAMP column