Module Deep DivesExecution Layer
HybridCollateralSettlementHook
Swap interception, pre-trade risk gating, and bounded post-trade settlement.
What It Does
HybridCollateralSettlementHook is the execution control plane between Uniswap v4 swap flow and external settlement.
For swaps without signed quote hookData, it returns ZERO_DELTA, skips vault sizing, and leaves no active settlement state. On registered-issuer hooks, this AMM path is available only while RiskConfig.poolAllowed is true.
For signed quote swaps, at runtime it:
- runs pre-trade checks in
beforeSwap - asks the liquidity source for the safe vault leg size
- rejects any remaining AMM leg when
RiskConfig.poolAllowedis false on registered-issuer hooks - stores transient context for this swap
- validates post-trade settlement bounds in
afterSwap - triggers external settlement or signed-quote consumption and clears transient state
Runtime Flow
Core Responsibilities
- enforce pool-level configuration (
enabled, collateral, limits) - enforce the registered-issuer
poolAllowedswitch for unsigned swaps and signed routes with a pool leg, while allowing fully external settlement - gate swap-driven minting during
RedeemOnly/Pausedconditions - treat empty and malformed non-signed
hookDataas pure AMM pass-through - enforce risk and oracle checks only after signed quote metadata is present
- delegate signed-quote policy validation to
CollateralManagerduring settlement - enforce bounded settlement magnitudes
- emit
BeforeSwapRiskEvaluatedandAfterSwapSettlementEvaluated - unconfigured pools and no-collateral pool configs revert closed instead of bypassing pool-level risk checks