Skip to content

v4.0.0 — Modular Architecture & Pre-Liquidation Support

Latest

Choose a tag to compare

@Jean-Grimal Jean-Grimal released this 16 Mar 17:53
55876fc

Highlights

This release is a major architectural refactor that splits the monolithic client into a modular workspace monorepo with independent, testable packages.

Modular workspace architecture

The bot is now organized into six packages, each with its own build, types, and test suite:

  • apps/config — Single source of truth for chain configs, venue/pricer/data-provider registrations, and all tunable parameters
  • apps/client — Bot orchestration and on-chain execution (no config or secrets hardcoded)
  • apps/data-providers — Pluggable data provider interface with factory pattern
  • apps/liquidity-venues — Pluggable liquidity venue interface with factory pattern
  • apps/pricers — Pluggable pricer interface with factory pattern
  • apps/hyperindex — Envio HyperIndex indexer for on-chain event indexing

Pre-liquidation support

  • Full support for Morpho Blue pre-liquidations via the HyperIndex data provider
  • Fetches pre-liquidation contracts, user authorizations, and on-chain oracle prices
  • Filters positions by whitelisted markets and authorization status
  • Selects the best pre-liquidation contract per user per market (highest seizable collateral)

New data provider: HyperIndex

  • GraphQL-based data provider powered by Envio HyperIndex
  • Supports both liquidations and pre-liquidations
  • Paginated position fetching (handles large markets beyond Hasura's default limit)
  • Authorization queries filtered by pre-liquidation contract addresses
  • Can be self-hosted with RPCs or use the Envio hosted service (recommended)

Bug fixes & improvements

  • 1inch venue: Fixed duplicate chainId parameter (path + query) causing Bad Request errors; upgraded API to v6.1
  • Skim refactoring: Replaced erc20Skim (requires transient storage support) with a reusable skim function using on-chain balanceOf + erc20Transfer, compatible with older executor contracts
  • Error handling: All data provider errors now include chain ID for multi-chain debugging; errors passed as objects (not string-interpolated) to preserve stack traces; Promise.allSettled used for market fetching so one failed market doesn't discard all results
  • CI: Added Claude Code review workflow, updated test scripts

Breaking changes

  • Package structure has changed — imports from @morpho-blue-liquidation-bot/* packages replace direct file imports
  • Configuration now lives entirely in apps/config — the client, venues, pricers, and data providers read from it via package imports
  • Data providers are now multi-chain: a single instance is shared across all chains

Full Changelog: v3.0.0...v4.0.0