Data providers are responsible for fetching market and position data for the Morpho Blue Liquidation Bot.
Every data provider must implement the DataProvider interface (src/dataProvider.ts):
init()(optional) — Async initialization (e.g. spinning up an indexer, waiting for backfill). Called once before the provider is used.fetchMarkets(client, vaults)— Returns the market IDs for the given vaults.fetchLiquidatablePositions(client, marketIds)— Returns liquidatable positions for the given market IDs.
Data providers are multi-chain: a single instance is shared across all chains. They are created in the script before bots are launched, and each bot receives its provider via dependency injection.
Queries the Morpho API for liquidatable positions (with pagination) and reads vault markets on-chain. No infrastructure required. Does not support pre-liquidations.
Queries an Envio HyperIndex instance (see apps/hyperindex) via GraphQL. Supports both liquidations and pre-liquidations. Fetches positions/markets, pre-liquidation contracts, and authorizations in parallel. Oracle prices are read on-chain. Supports two deployment modes:
Use the Envio hosting service to deploy and manage the indexer. Set HYPERINDEX_URL to point to the hosted instance:
HYPERINDEX_URL=https://indexer.bigdevenergy.link/<your-indexer-id>/v1/graphqlThe provider connects directly — no local indexer is started. This is the recommended approach as it avoids local infrastructure, handles backfill automatically, and provides reliable uptime.
When HYPERINDEX_URL is not set, the provider starts a local indexer via pnpm start in apps/hyperindex and waits for it to backfill before the bot begins. While self-hosting is possible, it requires more setup and maintenance — the Envio hosted service is recommended for production use.
Requires Docker (Envio manages envio-postgres and envio-hasura containers).
The sync mode (HyperSync vs RPC) is configured in apps/hyperindex — see its README. In short:
ENVIO_API_TOKENset → HyperSync (fast, no RPC needed)ENVIO_API_TOKENnot set → RPC (requiresRPC_URL_<chainId>)
| Variable | Required | Description |
|---|---|---|
HYPERINDEX_URL |
No | URL of an external HyperIndex GraphQL endpoint. If unset, self-hosts locally. |
Set the data provider in apps/config/src/config.ts:
[mainnet.id]: {
options: {
dataProvider: "hyperIndex", // or "morphoApi"
// ...
},
},- Add the data provider name to the
DataProviderNametype inapps/config/src/types.ts. - Create a new folder in
src/with anindex.tsimplementing theDataProviderinterface. - Register it in the factory switch in
src/factory.ts. - Export it from
src/index.ts. - Set
options.dataProviderin the relevant chain configs inapps/config/src/config.ts.