Liquidium LogoLiquidium
TechnicalArchitecture

Architecture

Deep dive into the canister architecture and system design

System Overview

Design Principles

1. Separation of Concerns

CanisterResponsibility
LendingProtocol logic (shares, health factor, liquidation)
PoolAsset custody (ckAsset operations, blockchain integration)

This separation allows:

  • Adding new assets without changing lending logic
  • Asset-specific optimizations (BTC boosting, ERC fee fronting)
  • Independent upgrades and auditing

2. Dual-Phase Execution

All critical operations follow a two-phase pattern:

Phase 1: Synchronous (Atomic)

  • Validate request
  • Update state
  • Check invariants

Phase 2: Asynchronous (WAL-backed)

  • Execute inter-canister calls
  • Retry on failure
  • Idempotent handlers

3. Event-Driven Communication

Pools notify the lending canister of state changes via events:

EventTriggerAction
DepositConfirmedUser deposit detectedMint supply shares
RepaymentConfirmedDebt repayment detectedBurn debt shares
WithdrawalConfirmedWithdrawal completedUpdate records
BorrowConfirmedBorrow executedUpdate records

4. Subaccount Architecture

Each pool uses deterministic subaccounts for user isolation:

Subaccount TypePurpose
InflowFor deposits and repayments (derived from principal + pool type)
OutflowFor withdrawals and borrows (derived from address + index)
BOOST_SUBACCOUNTSmall BTC withdrawal batching
FEE_SUBACCOUNTETH gas fee management

Communication Patterns

FromToMethodPurpose
UserLendingborrow_assets()Request loan
UserLendingwithdraw()Withdraw collateral
LendingPoolwithdraw()Execute withdrawal
PoolLendingnotify_pool_event()Deposit/repayment confirmed
PoolckMinterretrieve_btc()Burn ck tokens
LendingPrice OraclePrice queryFetch prices
ERC PoolDEXToken swapConvert fees to ckETH

Trust Boundaries

Boundary Protections

BoundaryAttack VectorMitigation
User → LendingSignature forgeryNative-chain signature verification
User → LendingReplay attacksNonce-based protection
Lending → PoolUnauthorized withdrawalsCaller validation
Pool → ckMinterInvalid burn amountsPre-flight validation
Oracle → LendingPrice manipulationCaching, deviation alerts