Skip to content

Commit 53fb493

Browse files
oveddanclaude
andauthored
Complete Coins Documentation Overhaul with Native Mermaid Support (#1327)
## Summary This PR delivers a comprehensive overhaul of the Zora Coins documentation with improved user experience, native Mermaid diagram support, and better navigation structure. The changes transform the documentation from technical reference material into practical developer guides while fixing broken links and improving overall organization. ## 🎯 Key Improvements ### 📚 Documentation Transformation - **Native Mermaid Support**: Implemented `remark-mermaidjs` plugin for native ````mermaid syntax instead of React components - **User-Centric Design**: Restructured all documentation to focus on "how to use" rather than technical implementation details - **Improved Navigation**: Fixed broken links, updated navigation structure, and reorganized content hierarchy - **Practical Examples**: Added extensive Solidity code examples with proper ABI encoding structures - **Authentic Messaging**: Updated language to align with authentic Zora terminology ### 🏗️ Content Structure Overhaul - **Renamed Pages**: `factory.mdx` → `creating-a-coin.mdx` for better discoverability - **New Architecture Page**: Comprehensive technical deep-dive separated from user guides - **Protocol Branding**: Updated "Zora Protocol" → "Zora Coins Protocol" throughout - **Reward System**: Renamed "Protocol Rewards" → "Coin Rewards" for clarity ## 📋 Major Documentation Changes ### New Content Structure - **Coins Homepage** (`/coins/index.mdx`): Complete redesign focusing on protocol overview and developer resources - **Creating a Coin** (`/coins/contracts/creating-a-coin.mdx`): Developer-focused guide with proper ABI encoding examples - **Architecture** (`/coins/contracts/architecture.mdx`): Technical deep-dive with UML diagrams - **Contracts Overview** (`/coins/contracts/index.mdx`): Simplified navigation hub with contract summaries ### Native Mermaid Integration - **Removed Dependencies**: Eliminated `rehype-mermaid`, `mermaid`, `react-zoom-pan-pinch` - **Added Plugin**: Configured `remark-mermaidjs` for native markdown processing - **Converted Diagrams**: All React Mermaid components → native ````mermaid code blocks ### Technical Improvements - **Fixed Pool Configuration**: Removed incorrect fee configuration, added proper ABI encoding structure - **Doppler Integration**: Added references to [Doppler protocol](https://whetstone.cc/doppler) for initial liquidity positioning - **Creator Clarification**: Added important notes about `msg.sender` being considered the creator - **Indexer Behavior**: Documented that only the first creator coin is recognized by the Zora indexer ### Content Quality Improvements - **Removed Second-Person Language**: Eliminated "you/your" throughout documentation per style guidelines - **Fixed Dead Links**: Updated all broken references from removed pages and renamed files - **Strategic Cross-Linking**: Added internal links to improve user journey and discoverability - **Homepage Card**: Updated main navigation card with better description ## 🔧 Technical Implementation Details ### Mermaid Configuration ```typescript // docs/vocs.config.ts import remarkMermaid from "remark-mermaidjs"; export default defineConfig({ markdown: { remarkPlugins: [remarkMermaid], }, }); ``` ### ABI Encoding Examples Updated all pool configuration examples to show proper encoding: ```solidity abi.encode( uint8(4), // version ZORA_TOKEN_ADDRESS, // currency [-90000, -74000, -62000], // tickLower array [-58500, -67000, -52000], // tickUpper array [11, 11, 11], // numDiscoveryPositions [0.05e18, 0.1e18, 0.1e18] // maxDiscoverySupplyShare (WAD) ) ``` ### Navigation Structure - **Fixed Links**: All `/coins/contracts/factory` → `/coins/contracts/creating-a-coin` - **Updated Config**: Navigation properly reflects actual file structure - **Removed Dead References**: Eliminated references to non-existent getting-started page ## 📝 Files Changed ### Documentation (18 files) - Complete overhaul of coins documentation structure - Native Mermaid diagram implementation - Updated navigation and cross-references - Fixed broken links and improved organization ### Configuration (3 files) - Vocs configuration for Mermaid support - Package.json dependency updates - Navigation structure improvements ## 🚀 User Experience Impact ### For Developers - **Clear Examples**: Proper Solidity code with correct ABI encoding - **Better Flow**: Logical progression from overview → creation → technical details - **Native Diagrams**: Mermaid diagrams render directly in documentation without React overhead ### For Content Creators - **Simplified Language**: Removed technical jargon and second-person references - **Better Organization**: Clear separation between user guides and technical reference - **Authentic Voice**: Documentation now uses official Zora terminology and messaging 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 40e4a70 commit 53fb493

24 files changed

+3007
-1365
lines changed

CLAUDE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
## Documentation Philosophy
6+
7+
### Contract Documentation Guidelines
8+
9+
When documenting contracts, focus on **how to use** and **how it works** rather than technical reference material:
10+
11+
- **Prioritize user goals**: What does someone want to accomplish? (e.g., "Create a coin", "Understand rewards")
12+
- **Use practical examples**: Show real code snippets and configuration values
13+
- **Explain the "why"**: Help users understand the purpose and trade-offs of different options
14+
- **Visual diagrams**: Use UML diagrams to show relationships and processes
15+
- **Avoid redundancy**: Don't repeat information covered in other sections
16+
- **Remove deprecated methods**: Only document current recommended approaches
17+
18+
### Writing Style for Contracts
19+
20+
- Use action-oriented headings (e.g., "Creating a Coin" vs "Coin Creation")
21+
- Lead with benefits and outcomes, not implementation details
22+
- Include decision-making guidance (e.g., "Use this configuration if...", "Choose based on...")
23+
- Link strategically to related concepts and next steps
24+
525
## Development Commands
626

727
### GitHub Actions Integration

docs/CLAUDE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CLAUDE.md - Docs
2+
3+
This file provides guidance to Claude Code when working with the documentation in this directory.
4+
5+
## UML Diagrams
6+
7+
### Generating UML Diagrams
8+
9+
When you create or update PlantUML diagrams in the `uml/` directory:
10+
11+
1. **Create/update the .puml file** in `uml/` directory
12+
2. **Generate the SVG** by running:
13+
```bash
14+
cd docs
15+
pnpm generate-uml
16+
```
17+
3. **Reference the generated SVG** in documentation using the path: `public/uml/filename.svg`
18+
19+
### UML File Locations
20+
21+
- **Source files**: `uml/*.puml` (PlantUML format)
22+
- **Generated files**: `public/uml/*.svg` (SVG format for web display)
23+
24+
### Example
25+
26+
For a file `uml/my-diagram.puml`, the generated SVG will be at `public/uml/my-diagram.svg` and can be referenced in documentation as:
27+
28+
```markdown
29+
![My Diagram](/uml/my-diagram.svg)
30+
```
31+
32+
Note: Use the `/uml/` path (not `public/uml/`) when referencing diagrams in documentation.
33+
34+
## Prerequisites for Docs Development
35+
36+
Before working with the documentation, you need to build the packages that are imported:
37+
38+
1. **Install dependencies** from the root directory:
39+
```bash
40+
cd /Users/danovedzora/source/protocol-clones/zora-protocol-agent-1
41+
pnpm install
42+
```
43+
44+
2. **Build packages** from the root directory:
45+
```bash
46+
pnpm build
47+
```
48+
Note: If the build fails due to missing dependencies (like `tsc`), you may need to install TypeScript globally or ensure all dependencies are properly installed.
49+
50+
3. **Start docs development server**:
51+
```bash
52+
cd docs
53+
pnpm dev
54+
```
55+
56+
## Writing Guidelines
57+
58+
- **Avoid second person language**: Never use "you", "your", "yours" in documentation. Use third person (e.g., "the user", "developers", "coin creators") or imperative voice (e.g., "Call the function", "Set the parameter") instead.
59+
60+
## Redirects Management
61+
62+
### When Renaming or Moving Documentation Files
63+
64+
When renaming or moving documentation files, always add redirects to `docs/vercel.json` to prevent broken links:
65+
66+
1. **Add redirect entries** in the `redirects` array
67+
2. **Use permanent redirects** (`"permanent": true`) for renamed pages
68+
3. **Use temporary redirects** (`"permanent": false`) for content that may change
69+
70+
### Example Redirect Entry
71+
72+
```json
73+
{
74+
"source": "/coins/contracts/factory",
75+
"destination": "/coins/contracts/creating-a-coin",
76+
"permanent": true
77+
}
78+
```
79+
80+
### Common Redirect Scenarios
81+
82+
- **Page renamed**: Redirect old URL to new URL
83+
- **Page moved**: Redirect old path to new path
84+
- **Page removed**: Redirect to most relevant existing page
85+
- **Section reorganized**: Redirect old structure to new structure
86+
87+
Always test redirects after deployment to ensure they work correctly.
88+
89+
## Development Commands
90+
91+
- `pnpm generate-uml` - Generate SVG files from PlantUML source files
92+
- `pnpm dev` - Start development server
93+
- `pnpm build` - Build documentation site

docs/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "vocs dev",
88
"build": "tsc --noEmit",
9-
"build:site": "vocs build",
9+
"build:site": "playwright install --with-deps chromium && vocs build",
1010
"preview": "vocs preview",
1111
"copy-changelog": "tsx scripts/copy-changelogs.ts",
1212
"generate-uml": "tsx scripts/generateUml.ts"
@@ -21,8 +21,11 @@
2121
"@zoralabs/coins-sdk": "workspace:*",
2222
"@zoralabs/protocol-deployments": "workspace:*",
2323
"@zoralabs/protocol-sdk": "workspace:*",
24+
"clsx": "^2.1.1",
25+
"playwright": "^1.54.1",
2426
"react": "^18.2.0",
2527
"react-dom": "^18.2.0",
28+
"remark-mermaidjs": "^7.0.0",
2629
"typescript": "^5.2.2",
2730
"viem": "^2.21.21",
2831
"vite": "^5.4.8",
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Contract Architecture
2+
3+
This page provides a technical overview of how the Coins protocol contracts work together to enable coin creation, trading, and automatic reward distribution.
4+
5+
## Architecture Overview
6+
7+
```mermaid
8+
classDiagram
9+
%% Uniswap V4 Package
10+
class IPoolManager {
11+
+initialize()
12+
+modifyLiquidity()
13+
+swap()
14+
+take()
15+
}
16+
17+
%% Factory Package
18+
class ZoraFactoryImpl {
19+
+deploy(payoutRecipient, owners, uri, name, symbol, poolConfig, platformReferrer, postDeployHook, postDeployHookData, coinSalt)
20+
+deployCreatorCoin(payoutRecipient, owners, uri, name, symbol, poolConfig, platformReferrer, coinSalt)
21+
+coinAddress(msgSender, name, symbol, poolConfig, platformReferrer, coinSalt)
22+
+coinImpl()
23+
}
24+
25+
%% Coins Package
26+
class BaseCoinV4 {
27+
<<abstract>>
28+
#poolManager: IPoolManager
29+
#poolKey: PoolKey
30+
+migrateLiquidity()
31+
+getPayoutSwapPath()
32+
}
33+
34+
class CreatorCoin {
35+
-currency: ZORA
36+
-vestingSchedule: VestingSchedule
37+
+claimVesting()
38+
+getClaimableAmount()
39+
}
40+
41+
class ContentCoin {
42+
-backingCurrency: CreatorCoin
43+
+rewardsDistributionMethodology()
44+
}
45+
46+
%% Hooks Package
47+
class BaseZoraV4CoinHook {
48+
<<abstract>>
49+
+afterInitialize()
50+
+afterSwap()
51+
-collectFees()
52+
-mintLpReward()
53+
+_distributeMarketRewards()
54+
}
55+
56+
class ContentCoinHook {
57+
+_distributeMarketRewards()
58+
}
59+
60+
class CreatorCoinHook {
61+
+_distributeMarketRewards()
62+
}
63+
64+
class ZORAToken {
65+
ZORA Token
66+
}
67+
68+
%% Inheritance relationships
69+
BaseCoinV4 <|-- CreatorCoin
70+
BaseCoinV4 <|-- ContentCoin
71+
BaseZoraV4CoinHook <|-- ContentCoinHook
72+
BaseZoraV4CoinHook <|-- CreatorCoinHook
73+
74+
%% Factory relationships
75+
ZoraFactoryImpl ..> CreatorCoin : creates
76+
ZoraFactoryImpl ..> ContentCoin : creates
77+
78+
%% Hook relationships
79+
BaseZoraV4CoinHook --> IPoolManager : uses
80+
ContentCoinHook --> BaseCoinV4 : manages rewards
81+
CreatorCoinHook --> BaseCoinV4 : manages rewards
82+
83+
%% Pool Manager relationships
84+
BaseCoinV4 --> IPoolManager : integrates with
85+
CreatorCoin --> CreatorCoinHook : uses hook
86+
ContentCoin --> ContentCoinHook : uses hook
87+
88+
%% Currency relationships
89+
ContentCoin --> CreatorCoin : backed by
90+
CreatorCoin --> ZORAToken : backed by
91+
```
92+
93+
*Visual overview of how contracts work together in the Zora Coins system*
94+
95+
## Core Components
96+
97+
### Coins Contracts
98+
99+
**BaseCoinV4 (Abstract)**
100+
- Base implementation for both coin types
101+
- Integrates with Uniswap V4 PoolManager
102+
- Handles liquidity migration between hook versions
103+
- Manages pool key and basic coin functionality
104+
105+
**CreatorCoin**
106+
- One per creator, backed by ZORA tokens
107+
- 1 billion total supply with 5-year vesting schedule
108+
- 500M tokens vest to creator, 500M available for trading
109+
- Simpler reward distribution (creator + protocol)
110+
111+
**ContentCoin**
112+
- Multiple per creator, backed by creator's coin
113+
- 1 billion total supply with instant creator allocation
114+
- 10M tokens to creator immediately, 990M available for trading
115+
- Complex reward distribution including referrals
116+
117+
### Factory Contract
118+
119+
**ZoraFactoryImpl**
120+
- Deploys new coins with deterministic addresses
121+
- Supports custom pool configurations and post-deployment hooks
122+
- Creates Uniswap V4 pools automatically with appropriate hook contracts
123+
- Provides address prediction before deployment
124+
125+
Key functions:
126+
- `deploy()` - General coin deployment with full customization
127+
- `deployCreatorCoin()` - Simplified Creator Coin deployment
128+
- `coinAddress()` - Predict deployment address before deploying
129+
130+
### Hook System
131+
132+
The protocol uses an inheritance-based hook architecture:
133+
134+
**BaseZoraV4CoinHook (Abstract)**
135+
- Contains all shared hook functionality for both coin types
136+
- Implements Uniswap V4 hook interface (`afterSwap`, `afterInitialize`)
137+
- Handles pool initialization, fee collection, and currency conversion
138+
- Supports migration to new hook versions while preserving liquidity
139+
140+
**ContentCoinHook & CreatorCoinHook**
141+
- Inherit from `BaseZoraV4CoinHook` but override reward distribution
142+
- ContentCoinHook: Distributes rewards to create referral, trade referral, creator, protocol, and Doppler
143+
- CreatorCoinHook: Distributes rewards to creator and protocol only
144+
145+
Core shared functionality:
146+
- Collects trading fees from liquidity positions
147+
- Splits fees between LP rewards (33.33%) and market rewards (66.67%)
148+
- Converts fees to backing currency via multi-hop swaps
149+
- Distributes rewards based on coin-specific methodology
150+

0 commit comments

Comments
 (0)