Smart Contract Architecture

The CosmBank Flexi Loan system is powered by a modular, upgradeable smart contract architecture — ensuring transparency, risk isolation, and gas efficiency.

Though the external product is branded as Flexi Loan, the core contracts maintain the Cooler naming convention for consistency with the protocol’s contract-level structure.


1. Cooler.sol – Borrower-Specific Loan Contract

  • Each borrower receives a dedicated Cooler contract instance.

  • Responsibilities include:

    • Custody of veCSM collateral

    • Tracking loan state (issued, repaid, defaulted)

    • Executing post-maturity logic: reclaiming collateral or releasing repayment

By separating each borrower’s obligations, Cooler.sol ensures that individual defaults cannot cascade into systemic risk.


2. Clearinghouse.sol – Protocol Treasury Gateway

  • Serves as the central bridge between governance logic and Treasury capital.

  • Key functions:

    • Approving and issuing loans based on governance parameters

    • Monitoring outstanding loan balances and interest accrual

    • Redirecting idle funds into external stablecoin strategies (e.g., Venus Protocol) to maximize idle capital returns

Clearinghouse acts as a decentralized credit committee + capital allocator — fully on-chain and auditable.


3. CoolerFactory.sol – Deployment & Registry Layer

  • Factory contract for creating new Cooler contracts per borrower.

  • Functions include:

    • On-demand deployment of new borrower instances using clone architecture (to reduce gas costs)

    • Maintaining a registry of all active loans for global view and governance oversight

CoolerFactory enables scalable lending with minimal gas overhead — powering the infrastructure behind CosmBank's Flexi Loan system.

Last updated