// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; import {LendingIntent, CollateralEntry, Rule} from "../types/DataTypes.sol"; /// @title IAmishHub /// @notice Entry point that verifies a matched borrow/lend pair and orchestrates loan creation. interface IAmishHub { /// @notice A matched pair submitted for execution. Each side carries its full signed intent, its /// collateral array, its rules, and its EIP-712 signature. An intent may list several /// collateral entries as alternatives; `borrowerCollateralIndex`/`lenderCollateralIndex` /// select the single entry the match uses (the loan is always single-collateral). /// `fillAmount` is the matched principal; `makerIsLender` is true when the lender was the /// resting maker. `apnName`/`apnSymbol` are the executor-computed display metadata for the /// loan's APN token — cosmetic only (the authoritative loan terms live in the LoanManager /// record), so they are supplied here rather than derived or signed. struct MatchExecution { LendingIntent borrowerIntent; CollateralEntry[] borrowerCollateral; uint256 borrowerCollateralIndex; Rule[] borrowerRules; bytes borrowerSignature; LendingIntent lenderIntent; CollateralEntry[] lenderCollateral; uint256 lenderCollateralIndex; Rule[] lenderRules; bytes lenderSignature; uint256 fillAmount; bool makerIsLender; string apnName; string apnSymbol; } /// @notice Verify both signed intents, derive the executed terms, account for the fill, and /// atomically lock collateral and create the loan. Restricted to the executor. /// @return matchId The created loan's identifier. function executeLoan(MatchExecution calldata execution) external returns (bytes32 matchId); /// @notice Cancel one of your own intents so it can no longer be filled. Callable only by the /// intent's `creator`; the intent is identified by its content (the same hash used for /// fill-accounting), so a caller can never cancel another party's intent. function cancelIntent(LendingIntent calldata intent) external; /// @notice Principal already filled against the intent identified by `intentHash`. function filledOf(bytes32 intentHash) external view returns (uint256); /// @notice Whether the intent identified by `intentHash` has been cancelled by its creator. function isCancelled(bytes32 intentHash) external view returns (bool); }