Adapter Smart Contract Interface
Adapter Contracts (On-Chain)
Adapters are lightweight connectors that allow the Aggregator contract to interact with external DEXs and liquidity sources. Each adapter implements a standardized interface so the aggregator can perform multi-route swaps seamlessly across different protocols.
Adapters encapsulate the venue-specific logic — such as pool selection, swap encoding, or special calldata — so integrators never need to manage DEX internals directly.
Overview
Each supported DEX (Uniswap v2, Uniswap v3, PancakeSwap, Balancer, etc.) has a dedicated Adapter contract.
Adapters execute swaps on their respective venues and return the resulting token amounts to the Aggregator.
Adapters can be activated, deactivated, or marked as fee-free depending on protocol configuration.
Adapter Lifecycle
Active
Adapter can be used for routing. The Aggregator checks activeAdapters(adapter) == true.
Inactive
Adapter temporarily disabled (e.g., during maintenance or after deprecation). Calls revert with AdapterNotActive.
Fee-Free
Marked in freeOfChargeFeeAdapters(adapter) == true. Single-hop swaps using only this adapter pay no protocol fee.
Adapter Interface (Abstracted)
All adapters implement the same base functions:
swapTokens(tokenFrom, tokenTo, amountIn, additionalParams)
Executes the venue-specific swap and returns the output token amount.
getExpectedReturn(tokenFrom, tokenTo, amountIn)
(Optional) Returns the expected output amount used for quoting and route optimization.
getPool(tokenFrom, tokenTo)
(Optional) Returns the underlying pool address, if applicable.
Integrators do not call adapters directly. These are internal interfaces consumed by the Aggregator’s routing engine and API layer.
Adapter Registry (Aggregator View Functions)
The Aggregator exposes convenience view functions for managing and verifying adapters:
activeAdapters(address)
bool
Returns true if adapter is active and can be used for swaps.
freeOfChargeFeeAdapters(address)
bool
Returns true if adapter is exempt from protocol fees on single-hop swaps.
setActiveAdapter(address adapter, bool active)
—
(Admin) Enables or disables an adapter.
setFreeOfChargeAdapter(address adapter, bool isFree)
—
(Admin) Marks adapter as fee-free or reverts to standard fee model.
Supported Adapter Types
Madhouse currently supports the following adapter categories on Monad:
AMM v2
Uniswap v2, PancakeSwap v2, Atlantis v2
Constant-product pools.
AMM v3
Uniswap v3, PancakeSwap v3, Atlantis v4
Concentrated-liquidity pools.
Balancer-style AMM
Balancer
Multi-asset pools with dynamic weights.
CLOBs (Orderbooks)
zkSwap v2, Crystal
On-chain limit-order protocols.
Specialized Protocols
Kuru, Kintsu, Magma, aPriori
Staking or synthetic venues integrated via adapters.
New adapters can be added through governance without changing the Aggregator interface.
Fees and Exemptions
Adapters themselves do not set or receive fees — they inherit fee logic from the Aggregator:
Protocol fees are calculated at the Aggregator level.
Integrator fees are deducted before routing to adapters.
Fee-free adapters skip the protocol fee if used in a single-hop route.
This ensures a consistent and predictable fee model across all venues.
Events
FreeOfChargeFeeAdapterUpdated(address adapter, bool isFreeOfCharge)
Emitted whenever an adapter’s fee-free status changes.
AdapterActivated(address adapter, bool active)
Emitted when an adapter is enabled or disabled. (Optional, implementation-specific)
Example: Single-Hop Swap via Adapter
If the adapter is marked as fee-free and this is a single-hop swap, no protocol fee will apply — the user receives full quoted output.
Last updated