// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; /// @title ICollateralManager /// @notice Interface for the singleton that custodies borrower collateral, keyed by loan. interface ICollateralManager { /// @notice A borrower's locked collateral for one loan. struct CollateralDeposit { address borrower; address token; uint256 amount; } /// @notice Pull and custody `amount` of `token` (declared on `chainId`) from `borrower` for /// loan `matchId`. /// @dev Restricted to the orchestrator. `chainId` must be this chain (collateral is custodied on /// the chain where this manager is deployed). Reverts if a deposit already exists for `matchId`. function lock(bytes32 matchId, address borrower, address token, uint256 chainId, uint256 amount) external; /// @notice Return all collateral for `matchId` to its borrower and clear the deposit. Restricted /// to the LoanManager, which calls it only once the loan's principal is fully repaid. function release(bytes32 matchId) external; /// @notice Transfer `amount` of `matchId`'s collateral to `recipient` and reduce the deposit by /// that much, without clearing it. Restricted to the LoanManager, which calls it during a /// liquidation to hand the liquidator their seized collateral (bonus included); the /// LoanManager keeps its own denormalized amount in sync in the same transaction. Reverts if /// `amount` exceeds the deposit. For a full liquidation the LoanManager then calls /// {release} to return the remaining collateral to the borrower. function seizeCollateral(bytes32 matchId, address recipient, uint256 amount) external; /// @notice Add `amount` more collateral to an existing deposit, pulled from the caller, and sync /// the LoanManager's denormalized amount. Lowers the position's effective LTV; usable by /// anyone (a top-up only benefits the borrower, who receives it back on release). function addCollateral(bytes32 matchId, uint256 amount) external; /// @notice The collateral deposit recorded for `matchId` (zeroed if none). function depositOf(bytes32 matchId) external view returns (CollateralDeposit memory); }