> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cantina.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Diagrams & Formulas

> Use Mermaid.js and MathJax in Cantina Code to create diagrams and render formulas, enhancing clarity and efficiency in findings and comments.

# 🔶 Diagrams & Formulas

Cantina Code supports **diagramming** libraries such as [Mermaid.js](https://mermaid.js.org/) and **MathJax for** mathematical formula rendering. Paired with a well written finding or comment, these tools allow you to visually and efficiently communicate your point to the reader.

## Mermaid Diagram

The following code block

```mermaid theme={null}
sequenceDiagram
    participant Bank
    participant Attacker

    Attacker->>+Bank: Request withdrawal
    Bank->>+Attacker: Transfer funds
    Attacker->>+Bank: Request withdrawal (reentry)
    Bank->>+Attacker: Transfer funds (reentry)
    Bank-->>-Attacker: Insufficient balance
```

when introduced as a comment will display as illustrated in the image below.

<img src="https://mintcdn.com/cantina/ku5dppycuRMaBQ9F/assets/image%20(25).png?fit=max&auto=format&n=ku5dppycuRMaBQ9F&q=85&s=b6beac5dd716ba661b6d12a49b493a74" alt="Sequence diagram shows smart contract reentrancy attack." width="594" height="523" data-path="assets/image (25).png" />

## MathJax Formulas

Cantina Comments also render MathJax formulas. The following code block

```
$$
H_{f} = \frac {\sum Collateral_{i}\;in\;ETH  \times  Liquidation\;Threshold}{Total\;Collateral\;in\;ETH} 
$$
```

when introduced inside a comment will render as such

<img src="https://mintcdn.com/cantina/ku5dppycuRMaBQ9F/assets/image%20(35).png?fit=max&auto=format&n=ku5dppycuRMaBQ9F&q=85&s=328badc10fba371ce3b656ed572a2726" alt="ssue in Cantina Code with a mathematical formula using Mathjax, highlighting a potential error in implementation for Web3 security audits." width="905" height="158" data-path="assets/image (35).png" />
