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

Opening a template is free and never counts toward your daily diagrams. Asking the AI to change it counts as one.

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

Inside this diagram

A sequence diagram with 4 participants and 11 messages, in the order they happen.

People

  • User
  • Liquidator Bot

Systems

  • Lending Pool Contract
  • Price Oracle

Steps in order

  • 1. User β†’ Lending Pool Contract: Deposit 10 ETH collateral
  • 2. User β†’ Lending Pool Contract: Borrow 12,000 USDC
  • 3. Lending Pool Contract β†’ Price Oracle: Get ETH price
  • 4. Price Oracle β†’ Lending Pool Contract: 2,500 USD (reply)
  • 5. Lending Pool Contract β†’ User: 12,000 USDC sent (reply)
  • 6. Liquidator Bot β†’ Price Oracle: Read ETH price
  • 7. Price Oracle β†’ Liquidator Bot: 1,500 USD (reply)
  • 8. Liquidator Bot β†’ Lending Pool Contract: Check health factor
  • 9. Lending Pool Contract β†’ Liquidator Bot: 0.9, unsafe (reply)
  • 10. Liquidator Bot β†’ Lending Pool Contract: Repay 6,000 USDC of the debt
  • 11. Lending Pool Contract β†’ Liquidator Bot: ETH collateral plus 5% bonus (reply)

Make your own diagram like this

Describe your own system in plain English and the AI sequence diagram generator draws it in seconds, in the same style as this template.

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.