Skip to main content
The Factory contract is responsible for deploying all components of a Monolith instance and managing the global fee. Contract implementation

Constructor

Deploys the Factory and a shared InterestModel (accessible via interestModel()). Sets the initial operator and the global minDebtFloor that applies to every instance’s minDebt parameter.

User-Facing Functions

deploy

Deploys a complete Monolith lending system consisting of a lender, stablecoin, and vault contracts. Parameters:
  • params: DeployParams struct containing deployment configuration
DeployParams Structure:
Returns:
  • lender: Address of the deployed Lender contract
  • coin: Address of the deployed Coin (ERC‑20) contract
  • vault: Address of the deployed Vault (ERC‑4626) contract
Requirements:
  • All bounds listed above are enforced by Lender’s constructor and revert on violation.
  • params.collateral decimals must be ≤ 30.
  • params.psmAsset must differ from the deployed coin.
  • If params.psmVault is set, its underlying asset() must equal params.psmAsset and psmVaultMinTotalSupply must be > 0.
Deployment Process:
  1. Calculates deterministic addresses using CREATE3
  2. Deploys contracts in order: Lender → Coin → Vault
  3. Initializes contracts with proper cross-references
  4. Records deployment in factory registry
Events Emitted:
  • Deployed(lender, coin, vault)

deploymentsLength

Returns the total number of deployments created by this factory. Returns:
  • uint256: Number of deployments

deployments

Array accessor returning the Lender address at a given deployment index. Use together with deploymentsLength() to enumerate all instances.

interestModel

Returns the address of the shared InterestModel deployed by this Factory’s constructor. All Lenders deployed by this Factory use this same InterestModel instance.

minDebtFloor

Returns the global immutable minimum debt floor. Every Lender’s minDebt must be ≥ this value at deployment.

pendingOperator

Returns the address currently queued to accept the operator role via acceptOperator().

operator

Returns the current operator address authorized to manage the factory. Returns:
  • address: Current operator address

feeRecipient

Returns the address that receives protocol fees. Returns:
  • address: Fee recipient address

feeBps

Returns the default fee rate in basis points (bps). Returns:
  • uint256: Default fee in bps (e.g., 100 = 1%)

getFeeOf

Returns the fee rate for a specific lender deployment, using custom fee if set, otherwise default fee. Parameters:
  • _lender: Address of the lender deployment
Returns:
  • uint256: Fee rate in bps

isDeployed

Checks if an address was deployed by this factory. Parameters:
  • deployment: Address to check
Returns:
  • bool: True if address was deployed by this factory

customFeeBps

Returns the custom fee rate for a specific lender deployment. Parameters:
  • lender: Address of the lender deployment
Returns:
  • uint256: Custom fee in bps, 0 if using default fee

Operator Functions

setPendingOperator

Sets a new pending operator address. Can only be called by current operator. Parameters:
  • _pendingOperator: Address to set as pending operator
Requirements:
  • msg.sender must be current operator

acceptOperator

Accepts operator role for the pending operator address. Requirements:
  • msg.sender must be pending operator

setFeeRecipient

Sets the address that receives protocol fees. Parameters:
  • _feeRecipient: New fee recipient address
Requirements:
  • msg.sender must be current operator

setFeeBps

Sets the default fee rate in basis points. Parameters:
  • _feeBps: New fee rate in bps (max 1000 = 10%)
Requirements:
  • msg.sender must be current operator
  • _feeBps must be ≤ 1000

setCustomFeeBps

Sets a custom fee rate for a specific lender deployment. Parameters:
  • _address: Lender deployment address
  • _feeBps: Custom fee rate in bps (max 1000 = 10%)
Requirements:
  • msg.sender must be current operator
  • _feeBps must be ≤ 1000

pullReserves

Pulls accumulated reserves from a lender deployment to the fee recipient. Parameters:
  • _deployment: Lender deployment address
Requirements:
  • msg.sender must be fee recipient
  • _deployment must be a valid deployment

Events

  • Deployed(address indexed lender, address indexed coin, address indexed vault) — emitted by deploy() with the new instance addresses.
  • CustomFeeBpsSet(address indexed lender, uint256 feeBps) — emitted by setCustomFeeBps().
  • FeeBpsUpdated(uint256 feeBps) — emitted by setFeeBps().
  • FeeRecipientUpdated(address indexed feeRecipient) — emitted by setFeeRecipient().
  • PendingOperatorUpdated(address indexed pendingOperator) — emitted by setPendingOperator().
  • OperatorUpdated(address indexed operator) — emitted by acceptOperator().
  • ReservesPulled(address indexed lender, address indexed recipient, uint256 amount) — emitted by pullReserves().