The Broker & Virtual AMMs
Last updated
Last updated
The Broker serves as the central exchange router in Mento V2, orchestrating all asset swaps through virtual Automated Market Makers (vAMMs). This architecture provides efficient exchanges between stable assets and collateral.
Note: This page describes Mento V2 architecture, which is currently in production. The next generation (V3) will transition to direct FPMM interactions without the Broker intermediary. See Fixed-Price Market Makers for the future architecture.
The V2 exchange system consists of three main components working together:
The Broker: Central contract that handles all swaps, manages permissions, and enforces trading limits
Exchange Providers: Modular pricing engines (currently BiPoolManager) that calculate exchange rates
Virtual AMMs: Pools that maintain virtual buckets and execute pricing logic without holding actual assets
This separation of concerns enables flexible exchange mechanisms while maintaining security and upgradability.
The Broker is the only contract with permission to mint and burn stable assets or transfer collateral from the Reserve. It serves as a secure gateway that:
Validates Exchanges: Ensures the requested exchange provider exists and has sufficient reserve backing for collateral assets.
Enforces Limits: Applies trading limits to prevent excessive flows that could destabilize the system.
Routes Swaps: Delegates price calculations to exchange providers while handling the actual asset transfers.
Manages Providers: Maintains a registry of approved exchange providers and their associated reserves.
When users swap through the Broker:
Quote Request: getAmountIn()
or getAmountOut()
queries the exchange provider for pricing
Validation: Checks exchange provider status, reserve balances, and trading limits
Execution: swapIn()
or swapOut()
performs the actual exchange
Settlement: Transfers assets between user, Broker, and Reserve as needed
Unlike traditional AMMs that hold liquidity, Mento's virtual AMMs maintain theoretical "buckets" representing the relative values of assets. These buckets:
Reset periodically based on oracle prices
Adjust ratios during swaps (for constant product) or maintain them (for constant sum)
Enable efficient pricing without locking actual capital
The BiPoolManager implements the virtual AMM logic for two-asset pools. Each pool tracks:
Virtual Buckets: Theoretical reserves that determine exchange rates without holding real assets.
Oracle Integration: Reference rate feeds that provide external price anchors for bucket resets.
Pricing Modules: Pluggable strategies for calculating swap amounts.
V2 supports two pricing modules:
Constant Sum: Maintains fixed exchange rates between bucket resets. Ideal for stable-to-stable swaps where external oracle prices should dominate. Buckets reset to match oracle rates but don't change during swaps.
Constant Product: Uses the classic x * y = k
formula. Suitable for stable-to-volatile pairs where price discovery happens on-chain. Buckets adjust with each swap to reflect supply and demand.
The Broker enforces configurable trading limits on each exchange:
Time-based limits: Restrict flow over specific time windows (L0, L1)
Global limits: Absolute caps on cumulative flow (LG)
Bidirectional tracking: Monitors both inflows and outflows
These limits work alongside circuit breakers to protect the protocol during volatile conditions.
A typical swap flow:
User initiates swap through the Broker
Broker queries BiPoolManager for exchange rate
BiPoolManager checks oracles and updates buckets if needed
Pricing module calculates output amount based on bucket state
Broker validates trading limits and reserve balances
Assets transfer:
Stable assets: minted to/burned from user
Collateral: transferred between Reserve and user
Buckets update (for constant product only)
While V2's Broker architecture has served Mento well, V3's direct FPMM approach offers:
Simplified architecture with fewer intermediary contracts
True liquidity provision with real assets in pools
More efficient gas usage
Better composability with DeFi protocols
During the transition period, both systems will operate in parallel, allowing gradual migration of liquidity and users.
For developers integrating with V2:
Use the Broker as your entry point for all swaps
Query available exchanges via getExchangeProviders()
Check trading limits before large swaps
Monitor oracle freshness for accurate pricing
See the Developer Documentation for detailed integration guides and contract addresses.
To understand how V2 components work together:
Trading Limits & Circuit Breakers - Protection mechanisms
Oracles & Price Feeds - External price anchoring
The Reserve - Asset backing for exchanges
To learn about the future architecture:
Fixed-Price Market Makers - Mento V3's approach