Overview
MultiliquidSwap is the central execution layer for Multiliquid on EVM. It prices and settles atomic exchanges across permissioned RWAs and stablecoins while coordinating LP delegates, RWA risk controls, price adapters, whitelist adapters, and protocol fee configuration.
One Routing Surface
One
quoteSwap function prices every route and one swap function settles
single-leg or multi-leg transactions.NAV-Based Pricing
Every asset is converted through 18-decimal USD values with deterministic
exact-in and exact-out math.
Flexible Execution
Users can transact directly or authorize operators through standing
allowances and one-shot EIP-712 permits.
Integrated Liquidity
Stablecoin delegates can use automatic prefund and sweep legs backed by a
designated liquidity stablecoin.
src/prod/MultiliquidSwap.sol
Architecture
The swap contract owns routing, pricing, authorization, protocol-level controls, and atomic execution. Asset movement is delegated to the selected stablecoin LP domain. Optional RWA delegates apply stateful asset-specific controls, while whitelist adapters preflight recipient eligibility. The contract is upgradeable through UUPS and uses OpenZeppelin access control, pausing, and reentrancy protection.Unified Route Model
Every requested leg uses the same structure:stablecoinDelegateID selects the LP domain whose custody, whitelists, fee schedules, and settlement implementation apply to the leg.
Even route IDs are exact-in and odd route IDs are exact-out.
Amount Semantics
The route configuration determines which stablecoin delegate is valid:
- Stablecoin → RWA uses the input stablecoin ID.
- RWA → stablecoin uses the output stablecoin ID.
- RWA → RWA uses an accepted stablecoin LP domain selected by the caller.
- Stablecoin → stablecoin can use either the input or output stablecoin delegate.
- Prefunded routes follow the same delegate rule as their corresponding base route.
Quoting
quoteSwap prices one requested leg:
assetInAmt and treats assetOutAmt only as an execution bound. For exact-out routes, it uses assetOutAmt and treats assetInAmt only as an execution bound.
Quotes are prospective and do not require the user or custody accounts to hold
the quoted assets. Applications can exercise the complete settlement path with
an
eth_call simulation before submission.Swap Execution
All requested legs settle through one entrypoint:userowns the input assets and yield credits.msg.senderis the operator submitting the transaction.receiverreceives every requested leg’s output.inputsis an ordered array of one or more bounded swap legs.permitis optional EIP-712 authorization for delegated execution.
Multi-Leg Transactions
The contract executes requested legs in array order up to the operator-configured maximum. Each leg is independently specified and priced. Outputs are not implicitly assigned as the next leg’s input; applications can construct chained amounts off-chain and submit the resulting ordered batch. Multi-leg execution supports:- Portfolio rebalancing
- Batch order settlement
- Multi-route institutional workflows
- Atomic execution around auto-liquidity legs
User, Operator, and Receiver
Separating the economic user, transaction operator, and output receiver enables relayers, institutional operators, smart-account workflows, scheduled execution, and settlement to a designated custody account. The contract supports three authorization modes:
ERC-20 token allowance to the selected stablecoin delegate remains separate from protocol-level operator authorization.
Standing Swap Allowances
type(uint256).max acts as an infinite allowance and is not decremented.
Standing allowances can only authorize a delegated swap when receiver == user, keeping the reusable permission tied to the user’s own output account.
EIP-712 One-Shot Permits
The one-shot permit allows the user, operator, and receiver to be three different addresses for one signed execution. The user owns the inputs and signs the authorization, the operator submits the transaction, and the receiver receives the output. The signedSwapInputs[] can contain one requested leg or an ordered multi-leg batch. Batch authorization is supported because swap accepts an array, but the permit’s defining purpose is one-shot authorization across separate user, operator, and receiver identities.
SwapBatchApproval typed message binds:
- User, operator, and receiver
- The complete ordered
SwapInputs[] - Every route, asset, delegate, amount, and execution bound
- The user’s current nonce
- The permit deadline
- Chain ID and verifying contract
MultiliquidSwap and the domain version is 2. Signatures support standard ECDSA, compact EIP-2098, ERC-1271 contract accounts, and EIP-7702 delegated EOAs.
One nonce authorizes the complete signed execution, whether single-leg or multi-leg. A reverted transaction rolls back the nonce with the rest of settlement.
Pricing Engine
Multiliquid uses deterministic NAV-based pricing rather than an AMM curve. The engine:- Normalizes input amounts to 18-decimal WAD precision.
- Converts the input asset into a common USD-denominated route unit.
- Applies the selected LP’s fee schedule and protocol fee policy.
- Applies yield-adjusted value where the input is yield-bearing.
- Converts the remaining route value into output-token decimals.
- Rounds conservatively for exact-in and exact-out guarantees.
IPriceAdapter.getPrice(). Stablecoins use an operator-configured WAD value and can additionally enforce an oracle deviation guardrail.
Fee Outputs
SwapResolved and the Swap event report three fee amounts:
The protocol can configure LP-funded fee rates per stablecoin, a global protocol take on LP spread, and fee exemptions for selected stablecoins. LP delegates configure their own RWA discounts, RWA redemption fees, stablecoin acceptance fees, and stablecoin redemption fees.
Treasury’s portfolio management fee belongs to the yield-bearing delegate and is applied to posted APY before user yield accrues.
Auto-Liquidity
A stablecoin delegate can designate an accepted stablecoin—typically a yield-bearing asset—throughautoLiquidityStablecoinIDs.
Prefund
Routes8–11 signal that a stablecoin-output swap may require liquidity immediately before the user leg. The contract:
- Quotes the requested output requirement.
- Builds a stablecoin-to-stablecoin exact-out leg from the configured auto-liquidity asset.
- Executes that leg from the selected delegate’s stablecoin custody account.
- Executes the user’s requested route.
swapInputAllowance with MultiliquidSwap itself as operator. The user authorizes only the requested leg.
Sweep
Eligible stablecoin-input routes can sweep the stablecoin balance received by custody into the configured auto-liquidity asset after the requested leg. The sweep:- Uses the custody balance delta measured inside the transaction
- Executes only when a standing LP allowance is present
- Quotes and sets its own exact-in output bound
- Settles atomically with the requested swap
Swap event.
Asset and Compliance Controls
RWA Registration
setRWAAcceptance records:
- Acceptance status
- Token address and decimals
- Optional RWA delegate for stateful risk controls
Stablecoin Registration
setStablecoinAcceptance records:
- Acceptance status
- Token address and decimals
- Stablecoin delegate
- Yield-bearing status
Stablecoin Guardrails
Blacklist
The protocol blacklist applies once per batch to the user, operator, and receiver. Stablecoin delegates can apply an additional LP-controlled blacklist during settlement.Administration
Fee schedule and auto-liquidity setters are callable only through the registered stablecoin delegate, which applies LP-admin authorization.
Access Control
Unified Swap Event
Every requested and internally derived leg emits:Next: Stablecoin Delegate Contracts
Learn how LP domains manage settlement, custody, fees, and liquidity