-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
312 lines (287 loc) · 20 KB
/
index.html
File metadata and controls
312 lines (287 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>uint-quantization-lib | Solidity Quantization Library</title>
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=Azeret+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-0: #08090b; --bg-1: #0f1114; --bg-2: #17191d; --bg-3: #1f2127;
--border: #26282e; --border-focus: #3a3d44;
--fg-0: #ecedef; --fg-1: #9fa1a8; --fg-2: #5f6168;
--accent: #22d3ee; --accent-hover: #06b6d4; --accent-dim: #0e7490;
--green: #34d399; --green-dim: #059669;
--red: #fb7185; --amber: #fbbf24; --violet: #c084fc;
--code-bg: #0b0c0e; --radius: 8px; --radius-lg: 12px;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Sora', sans-serif; background: var(--bg-0); color: var(--fg-1);
line-height: 1.6; -webkit-font-smoothing: antialiased;
background-image: radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
background-size: 24px 24px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* ── Ambient ── */
.bg-glow { position: fixed; border-radius: 50%; pointer-events: none; z-index: -1; }
.bg-glow-1 { top: -200px; right: -100px; width: 700px; height: 700px; background: radial-gradient(circle, rgba(34,211,238,0.04) 0%, transparent 70%); filter: blur(100px); }
.bg-glow-2 { bottom: -300px; left: -200px; width: 800px; height: 800px; background: radial-gradient(circle, rgba(52,211,153,0.03) 0%, transparent 70%); filter: blur(120px); }
/* ── Nav ── */
.nav { position: sticky; top: 0; z-index: 100; background: rgba(8,9,11,0.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.nav-logo { font-family: 'Azeret Mono', monospace; font-size: 0.85rem; font-weight: 600; color: var(--fg-0); text-decoration: none; letter-spacing: -0.02em; }
.nav-logo:hover { color: var(--accent); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { font-size: 0.85rem; font-weight: 500; color: var(--fg-2); text-decoration: none; transition: color 0.2s; }
.nav-links a:hover { color: var(--fg-0); text-decoration: none; }
.nav-links a.active { color: var(--accent); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 22px; border-radius: 6px; font-family: 'Sora', sans-serif; font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: all 0.2s; cursor: pointer; border: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--bg-0); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 24px rgba(34,211,238,0.25); }
.btn-outline { border: 1px solid var(--border); color: var(--fg-0); background: transparent; }
.btn-outline:hover { border-color: var(--accent-dim); color: var(--accent); }
/* ── Hero ── */
.hero { position: relative; padding: 96px 0 72px; text-align: center; overflow: hidden; }
.hero::after { content: '>>'; position: absolute; right: 5%; top: 50%; transform: translateY(-50%); font-family: 'Azeret Mono', monospace; font-size: clamp(8rem, 20vw, 16rem); font-weight: 900; color: rgba(34,211,238,0.025); pointer-events: none; line-height: 1; }
.hero-tag { display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 20px; padding: 4px 14px; border: 1px solid var(--accent-dim); border-radius: 100px; animation: fadeUp 0.5s ease 0.1s both; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.5rem); font-weight: 700; color: var(--fg-0); line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 20px; max-width: 700px; margin-left: auto; margin-right: auto; animation: fadeUp 0.5s ease 0.2s both; }
.hero-desc { font-size: clamp(1rem, 2vw, 1.12rem); color: var(--fg-1); max-width: 520px; margin: 0 auto 32px; line-height: 1.7; animation: fadeUp 0.5s ease 0.3s both; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; animation: fadeUp 0.5s ease 0.4s both; }
.badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; animation: fadeUp 0.5s ease 0.5s both; }
.badge { font-size: 0.7rem; font-weight: 500; color: var(--fg-2); padding: 3px 10px; border: 1px solid var(--border); border-radius: 100px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
/* ── Sections ── */
.section { padding: 72px 0; }
.section-title { font-size: 1.5rem; font-weight: 700; color: var(--fg-0); margin-bottom: 32px; letter-spacing: -0.02em; }
/* ── Code blocks ── */
.code-block { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.code-header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.code-dot { width: 6px; height: 6px; border-radius: 50%; opacity: 0.35; }
.code-dot:nth-child(1) { background: var(--red); } .code-dot:nth-child(2) { background: var(--amber); } .code-dot:nth-child(3) { background: var(--green); }
.code-label { font-family: 'Azeret Mono', monospace; font-size: 0.68rem; color: var(--fg-2); margin-left: auto; }
.code-body { padding: 16px; font-family: 'Azeret Mono', monospace; font-size: 0.82rem; line-height: 1.7; color: var(--fg-1); overflow-x: auto; white-space: pre; }
/* ── Cards ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.card:hover { transform: translateY(-2px); border-color: var(--border-focus); box-shadow: 0 8px 32px rgba(0,0,0,0.25); }
.card { border-top: 2px solid var(--accent); }
.card h3 { font-size: 1.05rem; font-weight: 600; color: var(--fg-0); margin-bottom: 8px; }
.card p { font-size: 0.9rem; color: var(--fg-1); line-height: 1.6; }
/* ── API list ── */
.api-list { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.api-item { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 20px; gap: 20px; }
.api-item:not(:last-child) { border-bottom: 1px solid rgba(38,40,46,0.5); }
.api-item:hover { background: rgba(34,211,238,0.02); }
.api-fn { font-family: 'Azeret Mono', monospace; font-size: 0.82rem; font-weight: 500; color: var(--accent); white-space: nowrap; }
.api-desc { font-size: 0.88rem; color: var(--fg-1); text-align: right; }
/* ── Footer ── */
.footer { padding: 48px 0; text-align: center; border-top: 1px solid var(--border); }
.footer p { font-size: 0.85rem; color: var(--fg-2); }
.footer a { color: var(--fg-2); } .footer a:hover { color: var(--accent); }
/* ── Infographic ── */
.ig-pipeline { display: flex; align-items: center; gap: 0; margin-bottom: 20px; overflow-x: auto; }
.ig-stage { flex: 1; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px; text-align: center; min-width: 130px; }
.ig-hl { border-color: var(--accent-dim); background: rgba(34,211,238,0.04); }
.ig-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-2); margin-bottom: 2px; }
.ig-num { font-family: 'Azeret Mono', monospace; font-size: 1.1rem; font-weight: 700; color: var(--fg-0); margin-bottom: 10px; }
.ig-bar { display: flex; height: 20px; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.ig-seg { display: flex; align-items: center; justify-content: center; min-width: 1px; overflow: hidden; }
.ig-seg span { font-family: 'Azeret Mono', monospace; font-size: 0.58rem; font-weight: 500; color: rgba(255,255,255,0.7); white-space: nowrap; }
.ig-kept { background: var(--accent-dim); }
.ig-lost { background: rgba(251,191,36,0.3); }
.ig-zeros { background: rgba(255,255,255,0.06); border: 1px dashed rgba(255,255,255,0.12); }
.ig-empty { background: rgba(255,255,255,0.03); }
.ig-sub { font-size: 0.72rem; color: var(--fg-2); }
.ig-legend { display: flex; gap: 14px; justify-content: center; margin-top: 5px; }
.ig-legend-item { font-family: 'Azeret Mono', monospace; font-size: 0.6rem; color: var(--fg-2); display: flex; align-items: center; gap: 5px; }
.ig-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.ig-dot.ig-kept { background: var(--accent-dim); }
.ig-dot.ig-lost { background: rgba(251,191,36,0.3); }
.ig-dot.ig-zeros { background: rgba(255,255,255,0.12); border: 1px dashed rgba(255,255,255,0.25); }
.ig-arrow { padding: 0 10px; text-align: center; flex-shrink: 0; }
.ig-arrow-op { font-family: 'Azeret Mono', monospace; font-size: 0.85rem; font-weight: 600; color: var(--fg-2); }
.ig-arrow-lbl { font-size: 0.62rem; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.05em; }
.ig-bridge { font-size: 0.9rem; color: var(--fg-1); line-height: 1.7; margin-bottom: 20px; }
.ig-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ig-slot-side { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.ig-slot-side-hl { border-color: var(--accent-dim); }
.ig-slot-hd { font-size: 0.78rem; font-weight: 600; color: var(--fg-1); margin-bottom: 10px; }
.ig-slot-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ig-slot-n { font-family: 'Azeret Mono', monospace; font-size: 0.65rem; color: var(--fg-2); width: 14px; flex-shrink: 0; }
.ig-slot-bar { flex: 1; display: flex; height: 28px; border-radius: 3px; overflow: hidden; }
/* ── Ask AI ── */
.ask-ai { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.ask-q { font-size: 0.92rem; color: var(--fg-1); line-height: 1.7; margin-bottom: 18px; padding: 14px 16px; background: var(--bg-2); border-radius: var(--radius); border-left: 3px solid var(--accent-dim); }
.ask-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.ask-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 6px; font-family: 'Sora', sans-serif; font-size: 0.85rem; font-weight: 500; border: 1px solid var(--border); background: var(--bg-2); color: var(--fg-0); cursor: pointer; transition: all 0.2s; }
.ask-btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.ask-btn.copied { border-color: var(--green-dim); color: var(--green); }
/* ── Scroll reveal ── */
.sr { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.sr.visible { opacity: 1; transform: translateY(0); }
/* ── Responsive ── */
@media (max-width: 640px) {
.hero { padding: 64px 0 48px; }
.section { padding: 48px 0; }
.api-item { flex-direction: column; gap: 4px; }
.api-desc { text-align: left; }
.nav-links { gap: 16px; }
.ig-pipeline { flex-direction: column; }
.ig-arrow { padding: 4px 0; }
.ig-slots { grid-template-columns: 1fr; }
.ask-btns { flex-direction: column; }
}
</style>
</head>
<body>
<div class="bg-glow bg-glow-1"></div>
<div class="bg-glow bg-glow-2"></div>
<nav class="nav">
<div class="nav-inner">
<a href="index.html" class="nav-logo">uint-quantization-lib</a>
<div class="nav-links">
<a href="https://github.com/0xferit/uint-quantization-lib/blob/main/README.md">Docs</a>
<a href="playground.html">Playground</a>
<a href="https://github.com/0xferit/uint-quantization-lib">GitHub</a>
</div>
</div>
</nav>
<div class="container">
<section class="hero">
<span class="hero-tag">Solidity Library</span>
<h1>Stop paying for resolution you don't need.</h1>
<p class="hero-desc">A Solidity library for shift-based quantization of unsigned integers, enabling tighter struct packing and lower gas costs.</p>
<div class="hero-cta">
<a class="btn btn-primary" href="https://github.com/0xferit/uint-quantization-lib">View on GitHub</a>
<a class="btn btn-outline" href="https://github.com/0xferit/uint-quantization-lib/blob/main/README.md">Documentation</a>
<a class="btn btn-outline" href="playground.html">Playground</a>
</div>
<div class="badges">
<span class="badge">Solidity</span>
<span class="badge">EVM</span>
<span class="badge">Gas Optimization</span>
<span class="badge">MIT License</span>
</div>
</section>
<section class="section">
<h2 class="section-title sr">Quick Start</h2>
<div class="code-block sr" style="transition-delay:0.1s">
<div class="code-header"><span class="code-dot"></span><span class="code-dot"></span><span class="code-dot"></span><span class="code-label">Terminal</span></div>
<div class="code-body">forge soldeer install uint-quantization-lib</div>
</div>
<div class="code-block sr" style="transition-delay:0.2s">
<div class="code-header"><span class="code-dot"></span><span class="code-dot"></span><span class="code-dot"></span><span class="code-label">MyContract.sol</span></div>
<div class="code-body">import {Quant, UintQuantizationLib} from "uint-quantization-lib/src/UintQuantizationLib.sol";
Quant private immutable SCHEME = UintQuantizationLib.create(32, 24);
uint24 stored = uint24(SCHEME.encode(largeValue)); // compress
uint256 restored = SCHEME.decode(stored); // decompress</div>
</div>
</section>
<section class="section">
<h2 class="section-title sr">How It Works</h2>
<div class="ig-pipeline sr" style="transition-delay:0.1s">
<div class="ig-stage">
<div class="ig-label">Original</div>
<div class="ig-num">1e18 wei</div>
<div class="ig-bar">
<div class="ig-seg ig-kept" style="flex:224"></div>
<div class="ig-seg ig-lost" style="flex:32"></div>
</div>
<div class="ig-legend">
<span class="ig-legend-item"><span class="ig-dot ig-kept"></span>kept: 224 bits</span>
<span class="ig-legend-item"><span class="ig-dot ig-lost"></span>discarded: 32 bits</span>
</div>
<div class="ig-sub">256 bits total (1 token, 18 decimals)</div>
</div>
<div class="ig-arrow">
<div class="ig-arrow-op">>> 32</div>
<div class="ig-arrow-lbl">encode</div>
</div>
<div class="ig-stage ig-hl">
<div class="ig-label">Stored</div>
<div class="ig-num">232,830,643 wei</div>
<div class="ig-bar">
<div class="ig-seg ig-kept" style="flex:1"></div>
</div>
<div class="ig-sub">fits in uint224</div>
</div>
<div class="ig-arrow">
<div class="ig-arrow-op"><< 32</div>
<div class="ig-arrow-lbl">decode</div>
</div>
<div class="ig-stage">
<div class="ig-label">Restored</div>
<div class="ig-num">≈ 1e18 wei</div>
<div class="ig-bar">
<div class="ig-seg ig-kept" style="flex:224"></div>
<div class="ig-seg ig-zeros" style="flex:32"></div>
</div>
<div class="ig-legend">
<span class="ig-legend-item"><span class="ig-dot ig-kept"></span>preserved: 224 bits</span>
<span class="ig-legend-item"><span class="ig-dot ig-zeros"></span>zero-filled: 32 bits</span>
</div>
<div class="ig-sub">max error < 2^32 wei (~4.3 gwei)</div>
</div>
</div>
</section>
<section class="section" style="padding-top:0">
<h2 class="section-title sr">Ask an AI</h2>
<div class="ask-ai sr" style="transition-delay:0.1s">
<p class="ask-q" id="askQuestion">Explain how the uint-quantization-lib Solidity library (https://github.com/0xferit/uint-quantization-lib) works. How does its shift-based quantization reduce gas costs, and what are the tradeoffs?</p>
<div class="ask-btns">
<button class="ask-btn" data-url="https://claude.ai/new">Ask Claude</button>
<button class="ask-btn" data-url="https://chatgpt.com">Ask ChatGPT</button>
<button class="ask-btn" data-url="https://gemini.google.com/app">Ask Gemini</button>
<button class="ask-btn" data-url="https://www.perplexity.ai/search">Ask Perplexity</button>
</div>
</div>
</section>
<section class="section">
<h2 class="section-title sr">API</h2>
<div class="api-list sr" style="transition-delay:0.1s">
<div class="api-item"><code class="api-fn">create(discardedBitWidth, encodedBitWidth)</code><span class="api-desc">Create a quantization scheme</span></div>
<div class="api-item"><code class="api-fn">encode(value)</code><span class="api-desc">Floor-encode a value (reverts on overflow)</span></div>
<div class="api-item"><code class="api-fn">encode(value, true)</code><span class="api-desc">Strict encode (reverts if not step-aligned)</span></div>
<div class="api-item"><code class="api-fn">decode(encoded) / decodeMax(encoded)</code><span class="api-desc">Restore lower-bound or upper-bound value</span></div>
<div class="api-item"><code class="api-fn">fits(value) / fitsEncoded(encoded)</code><span class="api-desc">Check if value is representable</span></div>
<div class="api-item"><code class="api-fn">isAligned(value) / remainder(value)</code><span class="api-desc">Check step alignment and lost bits</span></div>
<div class="api-item"><code class="api-fn">requireAligned(value) / requireMinStep(value)</code><span class="api-desc">Guard helpers that revert on bad input</span></div>
<div class="api-item"><code class="api-fn">floor(value) / ceil(value)</code><span class="api-desc">Snap to nearest step boundary</span></div>
<div class="api-item"><code class="api-fn">stepSize() / max()</code><span class="api-desc">Query scheme parameters</span></div>
</div>
</section>
<footer class="footer">
<p>Built by <a href="https://github.com/0xferit">0xferit</a> · MIT License · <a href="https://github.com/0xferit/uint-quantization-lib">GitHub</a> · <a href="playground.html">Playground</a></p>
</footer>
</div>
<script>
(function() {
/* ── Scroll Reveal ── */
const srObs = new IntersectionObserver(entries => {
entries.forEach(e => { if (e.isIntersecting) e.target.classList.add('visible'); });
}, { threshold: 0.1 });
document.querySelectorAll('.sr').forEach(el => srObs.observe(el));
/* ── Ask AI ── */
document.querySelectorAll('.ask-btn').forEach(function(btn) {
var label = btn.textContent;
btn.addEventListener('click', function() {
var q = document.getElementById('askQuestion').textContent;
navigator.clipboard.writeText(q).then(function() {
var url = btn.dataset.url;
if (url.indexOf('perplexity') !== -1) url += '?q=' + encodeURIComponent(q);
window.open(url, '_blank');
btn.classList.add('copied');
btn.textContent = 'Copied! Paste in chat';
setTimeout(function() { btn.classList.remove('copied'); btn.textContent = label; }, 3000);
});
});
});
})();
</script>
</body>
</html>