You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
`uint-quantization-lib` is a pure-function Solidity library for shift-based `uint256` lossy compression. The core mechanism is floor quantization via right-shifting via the `UintQuantizationLib` library. A `Quant` value packs `(shift, targetBits)` into a single `uint16`, making the compression scheme explicit and reusable. The recommended pattern is `immutable` + `create(shift, targetBits)` for readability.
7
+
`uint-quantization-lib` is a pure-function Solidity library for shift-based `uint256` lossy compression. The core mechanism is floor quantization via right-shifting via the `UintQuantizationLib` library. A `Quant` value packs `(discardedBitWidth, encodedBitWidth)` into a single `uint16`, making the compression scheme explicit and reusable. The recommended pattern is `immutable` + `create(discardedBitWidth, encodedBitWidth)` for readability.
8
8
9
9
## Commands
10
10
@@ -37,13 +37,13 @@ forge test --match-path test/showcase/ShowcaseGas.t.sol --gas-report -vv
37
37
38
38
### Source: `src/`
39
39
40
-
-`UintQuantizationLib.sol`: UDT `Quant` packing `(shift, targetBits)` into `uint16` (bits 0-7 = shift, bits 8-15 = targetBits). All functions are `internal pure`. Errors are file-level (not inside the library) and attached to the type. `using UintQuantizationLib for Quant global` at the bottom of the file propagates method-call binding to all importers automatically.
40
+
-`UintQuantizationLib.sol`: UDT `Quant` packing `(discardedBitWidth, encodedBitWidth)` into `uint16` (bits 0-7 = discardedBitWidth, bits 8-15 = encodedBitWidth). All functions are `internal pure`. Errors are file-level (not inside the library) and attached to the type. `using UintQuantizationLib for Quant global` at the bottom of the file propagates method-call binding to all importers automatically.
41
41
42
42
-`src/showcase/ShowcaseSolidityFixtures.sol`: Production-style showcase contracts demonstrating gas savings. `RawETHStakingShowcase` vs `QuantizedETHStakingShowcase` (real-life staking) and `RawExtremePackingShowcase` vs `QuantizedExtremePackingShowcase` (12 slots -> 1 slot). Used only for benchmarking. Both quantized contracts use `UintQuantizationLib`.
43
43
44
44
### Tests: `test/`
45
45
46
-
-`test/UintQuantizationLib.t.sol`: Foundry test file. Contains `QuantHarness` (exposes method-call syntax) and `UintQuantizationLibSmokeTest`. Smoke tests cover `create` validation and all revert paths. Fuzz tests use `uint8` for shift and targetBits and use `bound()` instead of `vm.assume` for value-in-range constraints.
46
+
-`test/UintQuantizationLib.t.sol`: Foundry test file. Contains `QuantHarness` (exposes method-call syntax) and `UintQuantizationLibSmokeTest`. Smoke tests cover `create` validation and all revert paths. Fuzz tests use `uint8` for discardedBitWidth and encodedBitWidth and use `bound()` instead of `vm.assume` for value-in-range constraints.
47
47
48
48
-`test/showcase/ShowcaseGas.t.sol`: Benchmark assertions. Enforces quantized paths save >= 32% (real-life) and >= 80% (extreme) gas vs raw paths on zero-to-nonzero writes.
0 commit comments