> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allium.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana Lending Schema Migration (defi → lending)

> solana.defi.lending, solana.defi.lending_tvl, and solana.defi.lending_tvl_daily are being removed. Migrate to the new solana.lending.* tables, which split activity by event type and add richer per-event fields.

<Warning>
  **Important**: `solana.defi.lending`, `solana.defi.lending_tvl`, and `solana.defi.lending_tvl_daily` will be removed on **November 30, 2026**. The replacement `solana.lending.*` tables are available now — migrate your queries before the cutover date.
</Warning>

## Overview

Allium is replacing the legacy `solana.defi.lending*` tables with a new `solana.lending.*` schema. The new schema splits the monolithic `lending_tvl` event table (which used an `ACTION` column to distinguish event types) into dedicated per-action tables — `deposits`, `withdrawals`, `loans`, `repayments`, `liquidations` — for simpler querying and better performance. It also adds richer per-event fields and replaces the single daily TVL rollup with multiple purpose-specific aggregates.

## Table mapping

| Legacy table | Replacement table(s) |
| - | - |
| `solana.defi.lending` | `solana.lending.markets_daily` (market/reserve state by day) |
| `solana.defi.lending_tvl` where `action = 'deposit'` | `solana.lending.deposits` |
| `solana.defi.lending_tvl` where `action = 'withdraw'` | `solana.lending.withdrawals` |
| `solana.defi.lending_tvl` where `action = 'borrow'` | `solana.lending.loans` |
| `solana.defi.lending_tvl` where `action = 'repay'` | `solana.lending.repayments` |
| `solana.defi.lending_tvl` where `action = 'liquidate'` | `solana.lending.liquidations` |
| `solana.defi.lending_tvl_daily` | `solana.lending.tvl_daily` |

Additional new tables with no legacy equivalent:

| New table | Description |
| - | - |
| `solana.lending.metrics_daily` | Aggregated daily protocol metrics — volume, active users, transaction counts by action type |
| `solana.lending.position_holdings` | Current wallet positions (supply and borrow balances) per market |
| `solana.lending.position_holdings_daily` | Historical daily snapshot of wallet positions |
| `solana.lending.vault_tvl_daily` | TVL by vault, where applicable |

## Schema changes

<AccordionGroup>
  <Accordion title="solana.defi.lending_tvl → per-action tables">
    The legacy `lending_tvl` table used a single `ACTION` column (deposit / withdraw / borrow / repay / liquidate) to distinguish event types. The new tables split this into dedicated tables.

    *Common columns across all new action tables* (`deposits`, `withdrawals`, `loans`, `repayments`, `liquidations`):

    | Column | Type | Notes |
    | - | - | - |
    | `PROJECT` | TEXT | |
    | `PROTOCOL` | TEXT | |
    | `LENDING_EVENT` | TEXT | New: category label (e.g. `lending`, `vault`) |
    | `EVENT_NAME` | TEXT | New: specific event name from the program |
    | `PROGRAM_ID` | TEXT | New: replaces `LIQUIDITY_VAULT` from old `lending` table |
    | `MINT` | TEXT | |
    | `TOKEN_NAME` | TEXT | |
    | `TOKEN_SYMBOL` | TEXT | Renamed from `SYMBOL` in legacy |
    | `TOKEN_DECIMALS` | NUMBER | Renamed from `DECIMALS` in legacy |
    | `RAW_AMOUNT_STR` | TEXT | New: raw amount as string |
    | `AMOUNT_STR` | TEXT | New: decimal-adjusted amount as string |
    | `AMOUNT` | FLOAT | Equivalent to legacy `AMOUNT` |
    | `USD_AMOUNT` | FLOAT | Equivalent to legacy `USD_AMOUNT` |
    | `USD_EXCHANGE_RATE` | FLOAT | New |
    | `EXTRA_FIELDS` | VARIANT | New: protocol-specific extra data |
    | `TXN_ID` | TEXT | |
    | `TXN_INDEX` | NUMBER | |
    | `SIGNER` | TEXT | |
    | `INSTRUCTION_INDEX` | NUMBER | |
    | `INNER_INSTRUCTION_INDEX` | NUMBER | |
    | `PSEUDO_INSTRUCTION_ORDER` | NUMBER | |
    | `BLOCK_SLOT` | NUMBER | |
    | `BLOCK_HEIGHT` | NUMBER | |
    | `BLOCK_TIMESTAMP` | TIMESTAMP\_NTZ | |
    | `BLOCK_HASH` | TEXT | |
    | `UNIQUE_ID` | TEXT | |

    *Party address columns differ by action type:*

    | Table | Address columns |
    | - | - |
    | `deposits` | `DEPOSITOR_ADDRESS`, `TARGET_ADDRESS` |
    | `withdrawals` | `WITHDRAWER_ADDRESS`, `TARGET_ADDRESS` |
    | `loans` | `BORROWER_ADDRESS`, `TARGET_ADDRESS` |
    | `repayments` | `BORROWER_ADDRESS`, `REPAYER_ADDRESS` |
    | `liquidations` | `BORROWER_ADDRESS`, `LIQUIDATOR_ADDRESS` + repay asset columns (`REPAY_MINT`, `REPAY_AMOUNT`, etc.) |

    *Columns removed from legacy `lending_tvl` (no equivalent in new tables):*

    * `ACTION` — replaced by the table name
    * `FROM_ADDRESS`, `TOKEN_ACC_FROM`, `TO_ADDRESS`, `TOKEN_ACC_TO` — replaced by role-specific address columns
    * `RAW_AMOUNT` — replaced by `RAW_AMOUNT_STR`
    * `LENDING_ID`, `LENDING_RESERVE_ID` — use `PROGRAM_ID` + `EXTRA_FIELDS` instead
    * `LIQUIDITY_VAULT` — use `PROGRAM_ID` from the `markets_daily` table
    * `PSEUDO_GLOBAL_ORDER` — removed
  </Accordion>

  <Accordion title="solana.defi.lending_tvl_daily → solana.lending.tvl_daily">
    The new `tvl_daily` table covers per-market, per-token daily TVL. Key column changes:

    | Legacy column | New column | Notes |
    | - | - | - |
    | `LENDING_ID` | — | Removed |
    | `LENDING_RESERVE_ID` | `MARKET_ID` | Renamed |
    | `TOKEN_SYMBOL` | `SYMBOL` | Renamed |
    | `TOKEN_DECIMALS` | `DECIMALS` | Renamed |
    | `RAW_DEPOSIT`, `RAW_WITHDRAW`, `RAW_TVL`, etc. | — | Removed; use `solana.lending.metrics_daily` for flow aggregates |
    | `USD_DEPOSIT`, `USD_WITHDRAW`, `USD_TVL`, etc. | — | Removed; use `solana.lending.metrics_daily` |
    | `RAW_NET_DEPOSITS`, `RAW_UNPAID_LOANS` | — | Removed |
    | — | `RAW_BALANCE_STR` | New |
    | — | `BALANCE_STR` | New |
    | — | `USD_EXCHANGE_RATE` | New |
    | `USD_TVL` | `USD_BALANCE` | Renamed |

    For daily flow aggregates (net deposit/borrow volume, USD TVL by action), use `solana.lending.metrics_daily` instead.
  </Accordion>

  <Accordion title="solana.defi.lending → solana.lending.markets_daily">
    The old `lending` table was a static reserve/pool metadata list. The new `markets_daily` table is a daily snapshot of market state with richer fields.

    | Legacy column | New column | Notes |
    | - | - | - |
    | `LENDING_ID` | `ID` | Renamed |
    | `LENDING_RESERVE_ID` | — | Use `ID` or `MINT` |
    | `LIQUIDITY_VAULT`, `COLLATERAL_MINT`, `COLLATERAL_LIQUIDITY_VAULT`, `INSURANCE_VAULT`, `FEE_VAULT` | — | Removed; vault-level detail not in new schema |
    | `NAME`, `SYMBOL`, `DECIMALS` | `TOKEN_NAME`, `TOKEN_SYMBOL`, `TOKEN_DECIMALS` | Renamed |
    | — | `PROGRAM_ID` | New |
    | — | `OUTSTANDING_LOANS`, `OUTSTANDING_LOANS_USD` | New |
    | — | `AVAILABLE_LIQUIDITY`, `AVAILABLE_LIQUIDITY_USD` | New |
    | — | `SUPPLIED_AMOUNT`, `SUPPLIED_AMOUNT_USD` | New |
  </Accordion>
</AccordionGroup>

## What to do

1. *Replace `solana.defi.lending_tvl` queries:* filter by action type and switch to the corresponding table (`deposits`, `withdrawals`, `loans`, `repayments`, `liquidations`). Remove the `ACTION` filter — it is now implicit in the table name.
2. *Replace `solana.defi.lending_tvl_daily` queries:* use `solana.lending.tvl_daily` for per-market token balances. For flow aggregates (deposit volume, borrow volume, net TVL), use `solana.lending.metrics_daily`.
3. *Replace `solana.defi.lending` queries:* use `solana.lending.markets_daily` for market/reserve state, scoped to a date.
4. *Update column references:* see schema changes above for renamed and removed columns.
5. *Complete migration by November 30, 2026* — the `solana.defi.lending*` tables will be removed after this date.

## Support

If this migration impacts your workflows, reach out to [support@allium.so](mailto:support@allium.so) or your account team.
