CollateralManager
Collateral accounting and constrained mint/redeem execution.
What It Does
CollateralManager owns collateral balances, debt balances, and mint/redeem execution under oracle and risk controls.
It is also the external settlement endpoint used by HybridCollateralSettlementHook for swap-driven mint/redeem paths.
Execution Flow
Mint and Redeem Fees
CDP minting books the gross amount as debt and issues the amount minus the mint
fee. Solvency, debt ceilings, and the shared debt registry include the fee debt.
Repaying only the minted proceeds leaves that fee debt outstanding; the borrower
must acquire additional stablecoin to close it before withdrawing all collateral.
Mint fees are issued in stablecoin to the admin-configured feeRecipient.
Redemption debits gross collateral from the borrower, transfers net collateral
to the borrower or settlement hook, and sends the collateral fee to the same
recipient. A nonzero fee-bearing mint or redemption reverts until a recipient
is configured. The recipient must make the fee tokens
available for borrowers to acquire; minting them does not ensure liquidity.
Zero configured or rounded fees impose no round-trip fee cost. Repayment does
not restore mint-cap usage. This policy does not backfill fees recorded as debt
before the change, or distribute collateral fees previously retained by the manager.
Settlement Models
CollateralManager supports one hook-driven vault settlement mode:
- Non-signed hookData:
vaultSettlementSpecifiedAbs,previewSwapExternal, andsettleSwapExternalno-op for hook settlement. - Signed Quote: a signed quote payload is provided in
hookDataand validated; settlement still usesSwapParamsfor amount and direction. - Signed zero-vault success: when the hook chooses pool-only execution for a valid signed quote,
consumeSignedQuoteForSwapvalidates and consumes the replay key without vault token movement.
Signed-quote validation includes:
| Check | Condition | Failure family |
|---|---|---|
| payload encoding | payload decodes with supported signed-quote version | malformed/unsupported payload reverts |
| expiry | expiry >= block.timestamp | SignedQuoteExpired |
| trader binding | msg.sender == trader | SignedQuoteTraderMismatch |
| pool binding | quote pool matches current pool | SignedQuotePoolMismatch |
| amount bound | maxAbsAmount >= abs(params.amountSpecified) | SignedQuoteAmountLimitExceeded |
| signer binding | recovered signer equals CollateralConfig.quoteSigner and signer is configured | SignedQuoteSignerMismatch / SignedQuoteSignerMissing |
| replay safety | derived replay key not consumed yet | SignedQuoteReplay |
| oracle-policy envelope | signed quote value remains within policy versus oracle | SignedQuotePolicyViolation |
Replay lifecycle note:
- The derived replay key is consumed only after all settlement checks pass and state transition is accepted.
- A failed attempt reverts and does not consume the quote.
Observability model:
- Success path emits
SignedQuoteSettledand standard settlement telemetry. - Non-signed hook callbacks emit no settlement telemetry and leave vault/debt state unchanged.
- Failure path reverts with explicit signed-quote errors; no settlement state is applied.
Core Responsibilities
- maintain
collateralBalance,debtBalance, andtotalDebt - execute
depositCollateral,withdrawCollateral,mint, andredeem - allow hook callbacks only from the configured hook via
setSettlementHook - store settlement hook address with
setSettlementHook - emit lifecycle events (
Minted,Redeemed,HookSettlementExecuted)
Key Enforcement Points
- collateral enablement and pause flags (
mintPaused,redeemPaused) - per-collateral limits (
mintCapTx,mintCapBlock,mintCapDay, redeem equivalents) - global limits (
globalMintCapDay,globalRedeemCapDay,globalDebtCeiling) - solvency and debt bounds via
SolvencyEnginechecks
Common Reject Cases
MintNotAllowed/RedeemNotAllowedfor blocked safe modesOracleUnavailablefor missing or paused oracle outputCapExceededwhen throughput windows breach configured limitsCollateralDisabledwhen the collateral is not enabled in risk configUnsupportedCollateralwhenOracleAdapterhas no enabled config for this collateralDebtCeilingExceededorGlobalDebtCeilingExceededon issuance overflowUnauthorizedSettlementCallerfor invalid callback sourceInsufficientCollateral/InsufficientDebtandAmountTooLargeForDeltafor settlement accounting constraints- signed-quote failures:
SignedQuoteReplay, malformed/unsupported signed payload reverts,SignedQuoteExpired,SignedQuoteTraderMismatch,SignedQuotePoolMismatch,SignedQuoteSignerMismatch,SignedQuoteSignerMissing,SignedQuoteAmountLimitExceeded,SignedQuotePolicyViolation,SignedQuoteModeDisabled
Settlement Math
- Signed settlement intent comes from
SwapParams, nothookData:size = abs(params.amountSpecified)size > 0andparams.amountSpecified < 0=> mintsize > 0andparams.amountSpecified > 0=> redeem- pool
BalanceDeltais ignored byCollateralManagerfor settle amount/action - non-signed
hookDatareturns zero/no-op instead of deriving a settlement action
- Mint path:
fee = amount * mintFeeBps / 10_000mintAmount = amount - feedebtBalanceandtotalDebtincrease bymintAmount
- Redeem path:
grossCollateralOut = stableAmount * 1e18 / oraclePriceE18collateralFee = grossCollateralOut * redeemFeeBps / 10_000- user receives
grossCollateralOut - collateralFee
vaultSettlementSpecifiedAbs(...),previewSwapExternal(...),settleSwapExternal(...), andconsumeSignedQuoteForSwap(...)must be called by the hook; direct user calls revert viaonlySettlementHook.