Skip to main content
Soroban RPC’s getEvents endpoint has limited retention (a few ledgers). For historical event data — transaction history, borrow records, liquidation logs — Vanna uses Mercury, an off-chain Stellar event indexer.

Mercury Overview

Mercury subscribes to on-chain contract events and stores them in a queryable database. Two query paths:
Mercury’s GraphQL endpoint on testnet is intermittently unreliable. Use the REST Classic events endpoint for production reliability.

Authentication

Mercury requires a JWT token. Never expose this token to browser clients. Use a server-side proxy (Next.js API route, Edge function, etc.):
Required environment variables (server-side only):

REST Events Endpoint

Server-Side Proxy (Next.js)

Client-Side Fetch


Event Schemas

AccountManager Events

Account Creation:
Trader Borrow:
Trader Repay:
Liquidation:

LendingPool Events

Deposit:
Withdraw:
vToken Mint:
vToken Burn:

Decoding Event Data

Mercury returns topic and data fields as base64-encoded XDR ScVal. Decode them with the Stellar SDK:

Cursor-Based Pagination

Mercury returns events newest-first (descending ID). Use the last event’s id as the cursor for the next page:

Filtering by Account

Mercury supports topic-based filtering. To fetch only events for a specific margin account, pass the account address as account — the proxy encodes it to XDR and forwards as a topics= filter:

Enriching with Ledger Timestamps

Mercury provides ledger_closed_at in ISO format for each event. If you need Unix timestamps or need to join with Horizon data:

Practical Examples

Fetch a User’s Borrow History

Fetch All Liquidations

Monitor Pool Deposits in Real Time

Combine Mercury for history with Horizon SSE for live updates:

Mercury Pricing

Sign up at mercurydata.app.