Skip to content

kingl0w/MarketMaker

Repository files navigation

Chain-Agnostic Market Maker

An open-source, multi-tenant concentrated liquidity market maker for EVM chains. Deploys and manages Uniswap V3 / Aerodrome LP positions on behalf of one or more clients, with per-client Gnosis Safe custody and a web dashboard for operations.

Status

Active development

This is a working system that has been end to end tested on Base Sepolia testnet, but it has not been formally audited, has not been battle tested at scale, and should not be used with funds you are not prepared to lose. The author provides this software AS-IS with no warranty. See LICENSE.

What it does

  • Provisions WETH/USDC (and other pair) liquidity positions on Uniswap V3-style DEXes
  • Monitors positions and rebalances when price drifts out of range
  • Collects accumulated LP fees on rebalance
  • Runs a 7-layer risk management system (NAV limits, drawdown, gas budget, IL, price divergence, balance reconciliation, staleness)
  • Supports multiple concurrent clients with isolated per-client Safes, positions, and fee accounting
  • Exposes a REST API and a companion Next.js dashboard for operations

Architecture highlights

  • Multi-tenant by design: per-client Gnosis Safe custody, per-client API keys, per-client tick loop, zero cross-contamination
  • Chain-agnostic: ChainConfig abstraction, adapter registry keyed by (chainId, venueId), supports Base, Arbitrum, Optimism out of the box
  • Deterministic math: optimal-split calculations use pure bigint throughout (no float conversions), porting Uniswap's TickMath.sol logic
  • Strategy pattern: pluggable strategies (Passive, ConcentratedLP, MultiVenueLP) with a clean IStrategy interface
  • Persistence: SQLite via better-sqlite3, currently at SCHEMA_VERSION 15

Stack

TypeScript, viem, better-sqlite3, Express, pino, tsup, biome, vitest, pnpm.

Companion repo

Dashboard: base-market-maker-dashboard — Next.js + Tailwind + wagmi.

Getting started

Prerequisites

  • Node 20+
  • pnpm
  • A Base Sepolia RPC URL
  • A funded EOA (bot wallet) on Base Sepolia

Setup

pnpm install
cp .env.example .env.testnet
# Edit .env.testnet with your RPC URL and bot private key
pnpm build

Create an admin key

pnpm key:create --admin --label=initial-admin

Save the printed key. It won't be shown again.

Onboard a client

# Safe custody (default — deploys a Gnosis Safe):
pnpm onboard --name="Acme Corp" --plan=starter --chain=84532

# Operator custody (bot EOA as approved operator — no Safe):
pnpm onboard --name="Acme Corp" --plan=starter --chain=84532 \
  --custody=operator --client-wallet=0x...

Run

bash scripts/run-testnet.sh

Operations

  • REST API on http://localhost:3847
  • Dashboard on a separate port (see dashboard repo)

API key format

  • Admin: mm_admin_<32hex>
  • Client: mm_<clientId>_<32hex>

Key management

# Create admin key
pnpm key:create --admin --label="admin"

# Create client-scoped key
pnpm key:create --client=<clientId> --label="description"

# Revoke a key
pnpm key:revoke --hash=<key_hash>

Testing

pnpm test                                          # unit + non-fork integration (~620 tests)
MM_INTEGRATION=true pnpm test tests/integration/   # integration tests (requires testnet setup)
pnpm test:fork                                     # forked-chain tests (requires anvil)

Contributing

This is an early-stage public build. Issues and PRs welcome but response time is not guaranteed. Before opening a large PR, please open an issue to discuss the direction.

License

MIT — see LICENSE file. You can use this code for any purpose including commercial. You assume all risk.

Risks and Disclaimers

This software executes real transactions on real blockchains with real funds if run on mainnet. Even on testnet, bugs can destroy positions, miscalculate balances, or cause unintended behavior. Specifically:

  • Not audited. No formal security review has been performed on the smart contract integrations, the fee calculations, the custody logic, or the bigint math. Bugs may cause fund loss.
  • Not production-grade. This is active development code. Breaking changes happen. Schema migrations run automatically. Behavior may change between versions without notice.
  • Market making has inherent risks. Impermanent loss, price divergence, MEV, flash loan attacks, oracle manipulation — all apply. Positions can lose value even when the code works perfectly.
  • Operational risks. Running a bot 24/7 with private keys requires operational security that this README does not cover. If your server is compromised, your keys are compromised.
  • Legal risks. Market making, LP operations, and automated trading may be regulated in your jurisdiction. Consult a lawyer if you plan to run this with real capital.

By running this software you accept all of the above risks. The author is not liable for any losses, regulatory issues, or other consequences arising from use of this software.

Contact

About

Chain agnostic concentrated liquidity market maker with a web based operations dashboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages