Design

Technical architecture and system design, including core contracts and libraries

Core Contracts

These contracts form the core of the system.

  • MultiSourceLoan - Main contract of the protocol where loans are originated/refinanced/repaid. It also keeps collateral in escrow.

    • Diamond.sol - Core Diamond proxy implementation for upgradeable architecture.

    • ControlFacet.sol - Administrative functions including protocol configuration and operational controls.

    • DiamondCut.sol - Diamond standard facet for adding, replacing, and removing facets.

    • DiamondLoup.sol - Diamond standard facet for inspecting which facets and functions are available.

    • DiamondInit.sol - Initialization contract for setting up Diamond proxy with initial facets and configuration.

    • LiquidationFacet.sol - Liquidation management.

    • LoanFacet.sol - Core loan operations.

    • ViewFacet.sol - Read-only operations for querying loan states, user states, and protocol statistics.

    • RefinanceLoanFacet.sol - Loan refinancing logic.

    • LoanExtensionFacet.sol - Delegate/FlashLoan logic.

  • AuctionWithBuyoutLoanLiquidatorUpgradeable.sol - Liquidation contract including buyout and auction.

  • LoanManagerRegistryUpgradeable.sol

  • LoanManagerParameterSetterUpgradeable.sol - Utility contract for setting of loan manager parameters.

  • UserVault.sol - Allows users to mint a vault to collateralized multiple NFTs and borrow against them as a bundle under a single loan.

  • AddressManagerUpgradeable.sol - Manager of whitelisted collections/erc20 supported by BAE lending.

  • FeeDiscountManagerUpgradeable.sol - Manages dynamic protocol fee reductions based on borrower NFT holdings or keeper signatures

  • ListNftAddressesValidator.sol - Enables multi-collection offers by validating NFT contracts against approved collection lists

  • RangeValidator.sol - Validates collection offers across a range of token IDs enabling collection offers for specific Artblocks Curated collections like Fidenzas, Chromie Squiggles, and more. Used for V1, V2, and V3.

Librarires & Base Inherit Contract

  • AccessControl.sol - Base contract providing role-based access control functionality for protocol governance

  • LibAccessControl.sol - Library containing access control utilities and permission checking logic

  • LibDiamond.sol - Diamond standard library for managing facets, selectors, and Diamond proxy functionality

  • LibHash.sol - Cryptographic utilities for offer validation, signature verification, and data integrity

  • LibInterest.sol - Interest calculation utilities supporting pro-rata interest and complex tranche structures

  • LibLoan.sol - Core loan logic including validation, capacity management, and state transitions

  • LibLoanStructs.sol - Data structure definitions for loans, offers, and protocol entities

  • LibValidator.sol - Input validation

  • AccessControlStorage.sol - Storage library for role-based permissions and access control data using Diamond storage

  • BaseStorage.sol - Storage library for core protocol configuration including currencies, collections, and global parameters

  • LoanStorage.sol - Storage library for loan-specific state management including active loans, offers, and tranche information

External Libraries

  • forge-std v1.9.7 - Testing framework

  • @openzeppelin-contracts v5.3.0 - Standard contract libraries

  • @openzeppelin-contracts-upgradeable v5.3.0 - Upgradeable contract patterns

  • delegate-registry v2.0 - Delegation management system

Last updated