This describes a pre-release version of LBAMM. Interfaces and behavior may change.
Verify the exact repository commit before building production integrations.
Transfer Handlers
Transfer handlers are modular settlement components used by LBAMM to expand how swap input tokens are supplied to the AMM while preserving full execution context.
They are primarily about settlement modularity: different applications can settle the same swap semantics using different mechanisms (direct ERC-20 transfer, permit-based authorization, onchain order books, etc.) without changing pool logic.
What is a transfer handler?
A transfer handler is a contract invoked by the AMM core during swap finalization to obtain the input tokens required to settle a swap.
Transfer handlers:
- Are optional per swap
- Can be used with
singleSwap,multiSwap, anddirectSwap - Receive full swap context (executor, order, amounts, and fee configuration)
How a swap selects a transfer handler
Each swap entrypoint accepts a bytes transferData parameter.
-
If
transferData.length < 32: no transfer handler is used (transferHandler = address(0)). -
If
transferData.length >= 32:- The first 32 bytes are interpreted as an ABI-encoded transfer handler address
- The remaining bytes are treated as
transferExtraDataand passed to the handler
Conceptually:
address transferHandler;
bytes transferExtraData;
if (transferData.length >= 32) {
transferHandler = abi.decode(transferData[:32], (address));
transferExtraData = transferData[32:];
} else {
transferHandler = address(0);
transferExtraData = "";
}
The chosen transfer handler address is surfaced to hooks via SwapContext.transferHandler.
Permissionless extensibility
LBAMM ships with two first-party transfer handlers as examples:
- A permit-based handler (offchain signed intent)
- A CLOB-style handler (onchain orders at specific prices)
Developers may deploy additional transfer handlers permissionlessly, provided they implement the required interface.
What transfer handlers are for
Transfer handlers exist to make settlement modular while preserving the same AMM execution semantics.
Typical uses include:
- Alternative authorization and settlement flows for supplying input tokens
- Aggregating liquidity or intent sources behind a uniform swap interface
- Order-style settlement where the AMM needs extra context to pull funds
Importantly, transfer handlers do not change:
- pool pricing logic
- swap semantics
- hook atomicity (a revert still reverts the swap)
They only change how the input tokens are obtained for settlement.
