Summary
Enable processor netting: add a swap interface to Processor so that one processor can swap its source token for another processor's source token directly, netting the two amounts instead of each processor executing an independent market swap.
Motivation
Today, a Processor converts unwound vault tokens into its TARGET_ASSET via market swaps routed through its SubProcessor (process4626 → SubProcessor.process(calls)), bounded by maxSlippage. Every conversion that requires changing token A → token B is executed against external liquidity (DEX), incurring slippage and trading fees.
When two processors hold opposite legs of the same pair (Processor X holds token B and wants token A; Processor Y holds token A and wants token B), they can satisfy each other's demand directly. Settling that overlap peer-to-peer ("netting") avoids the round-trip through external liquidity for the netted amount, reducing slippage and fees and only routing the residual (un-netted) amount to the market.
Proposed change
Add a swap/netting interface on Processor (or a coordinating contract) that lets one processor swap its source token for another processor's source token:
- A
swap entrypoint that transfers amountIn of processor X's token to processor Y and pulls amountOut of processor Y's token in return, settling both processors in a single atomic operation.
- Pricing for the swapped amount sourced from a trusted reference (e.g. an oracle / agreed rate) rather than a DEX, with a slippage/price bound consistent with the existing
maxSlippage guard.
- Access control: restricted so only the authorized caller/counterparty processor can initiate netting (reuse
CALLER_ROLE / CONFIG_ROLE model where appropriate).
- Atomic, balance-checked settlement (mirror the
assetsAfter >= assets / amountOut >= amountOutMin invariants used in process4626).
Open questions
- Where should the reference price come from (on-chain oracle, signed quote, config-set rate)?
- Should netting be initiated peer-to-peer between two
Processor instances, or coordinated by a separate netting/settlement contract that both processors trust?
- How is the residual (un-netted) amount handled — fall back to the existing
process4626 market-swap path?
- Slippage/price-deviation bounds and how they compose with
maxSlippage.
References
contracts/Processor.sol — process4626, forward, maxSlippage
contracts/SubProcessor.sol — arbitrary-call swap execution / isolation
Summary
Enable processor netting: add a swap interface to
Processorso that one processor can swap its source token for another processor's source token directly, netting the two amounts instead of each processor executing an independent market swap.Motivation
Today, a
Processorconverts unwound vault tokens into itsTARGET_ASSETvia market swaps routed through itsSubProcessor(process4626→SubProcessor.process(calls)), bounded bymaxSlippage. Every conversion that requires changing token A → token B is executed against external liquidity (DEX), incurring slippage and trading fees.When two processors hold opposite legs of the same pair (Processor X holds token B and wants token A; Processor Y holds token A and wants token B), they can satisfy each other's demand directly. Settling that overlap peer-to-peer ("netting") avoids the round-trip through external liquidity for the netted amount, reducing slippage and fees and only routing the residual (un-netted) amount to the market.
Proposed change
Add a swap/netting interface on
Processor(or a coordinating contract) that lets one processor swap its source token for another processor's source token:swapentrypoint that transfersamountInof processor X's token to processor Y and pullsamountOutof processor Y's token in return, settling both processors in a single atomic operation.maxSlippageguard.CALLER_ROLE/CONFIG_ROLEmodel where appropriate).assetsAfter >= assets/amountOut >= amountOutMininvariants used inprocess4626).Open questions
Processorinstances, or coordinated by a separate netting/settlement contract that both processors trust?process4626market-swap path?maxSlippage.References
contracts/Processor.sol—process4626,forward,maxSlippagecontracts/SubProcessor.sol— arbitrary-call swap execution / isolation