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.):REST Events Endpoint
Server-Side Proxy (Next.js)
Client-Side Fetch
Event Schemas
AccountManager Events
Account Creation:LendingPool Events
Deposit:Decoding Event Data
Mercury returns topic and data fields as base64-encoded XDRScVal. Decode them with the Stellar SDK:
Cursor-Based Pagination
Mercury returns events newest-first (descending ID). Use the last event’sid 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 asaccount — the proxy encodes it to XDR and forwards as a topics= filter:
Enriching with Ledger Timestamps
Mercury providesledger_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.
Related
- Events & Indexing Guide — complete integration walkthrough
- Transaction Flow — submitting transactions
- Getting Started — SDK setup

