CloudSketch AI Logo
FeaturesTemplatesPricingEnterpriseAboutContactLog in
🌙☀️
Log inStart free
Home/Templates/Blockchain & Web3

⛓️ Blockchain & Web3 · Sequence

DeFi Lending and Liquidation

How a DeFi lending protocol works: deposit collateral, borrow, and what happens when the collateral value falls and a liquidator steps in.

More Blockchain & Web3 templates

Drawing diagram…

What this diagram shows

  • Loans are over-collateralised
  • Prices come from an oracle
  • Anyone can liquidate an unsafe loan for a bonus

Prompt used

DeFi lending sequence: a user deposits 10 ETH as collateral into the lending pool contract and borrows 12,000 USDC. The pool reads the ETH price from a price oracle. When the price falls and the health factor drops below 1, a liquidator bot repays part of the debt and receives ETH collateral at a discount.

Mermaid code
sequenceDiagram
  actor U as User
  participant P as Lending Pool Contract
  participant O as Price Oracle
  actor L as Liquidator Bot
  U->>P: Deposit 10 ETH collateral
  U->>P: Borrow 12,000 USDC
  P->>O: Get ETH price
  O-->>P: 2,500 USD
  P-->>U: 12,000 USDC sent
  Note over P,O: Later the ETH price falls
  L->>O: Read ETH price
  O-->>L: 1,500 USD
  L->>P: Check health factor
  P-->>L: 0.9, unsafe
  L->>P: Repay 6,000 USDC of the debt
  P-->>L: ETH collateral plus 5% bonus

Related templates

C4 ArchitectureProBlockchain & Web3

Crypto Exchange Architecture

The main parts of a centralised crypto exchange: a matching engine, wallets split between hot and cold storage, deposits and withdrawals, and compliance checks.

SequenceBlockchain & Web3

Crypto Withdrawal Sequence

How an exchange processes a crypto withdrawal safely: balance hold, 2FA, risk and address screening, signing, broadcast and confirmations.

C4 ArchitectureProBlockchain & Web3

NFT Marketplace

How an NFT marketplace works: listings signed off-chain, metadata on IPFS, and sales settled by a marketplace smart contract.

FlowchartBlockchain & Web3

Smart Contract Upgrade Process

How a team safely upgrades a smart contract behind a proxy: audit, testnet rehearsal, multi-signature approval and a timelock before the change goes live.

State MachineBlockchain & Web3

Blockchain Transaction States

The states a blockchain transaction goes through from signing to final confirmation, including replacement and dropped transactions.

NetworkBlockchain & Web3

Hot and Cold Wallet Custody

How a custodian separates internet-connected hot wallets from offline cold storage, with signing hardware and an air-gapped transfer process.