docs: consolidate and update all documentation for launch readiness
- Rewrite root README.md with proper project overview, tech stack, and repo structure - Remove duplicate CLAUDE.md files (root, onchain, ponder) — AGENTS.md is the standard - Update HARBERG.md to reflect Stage 1 completion and Stage 2 evolution - Delete stale onchain/testing_todos.md (all high-priority items completed) - Update VERSION_VALIDATION.md for VERSION=2 - Trim root AGENTS.md: replace Docker duplication with docs/docker.md reference - Trim onchain/AGENTS.md (129→71 lines): reference TECHNICAL_APPENDIX for formulas - Trim web-app/AGENTS.md (278→55 lines): remove internal API docs, keep architecture - Rewrite onchain/README.md: add contract table, deployment addresses, analysis links - Trim services/ponder/README.md: remove stale subgraph comparison - Add otterscan to docs/docker.md service topology - Update TECHNICAL_APPENDIX.md references Net: -388 lines across documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b7260b2eaf
commit
de3c8eef94
14 changed files with 249 additions and 701 deletions
|
|
@ -8,122 +8,63 @@
|
|||
- Every swap through the LM's positions generates Uniswap LP fees
|
||||
- Fees (WETH + KRK) flow to `feeDestination` — this is what founders withdraw
|
||||
- Locked ETH in the protocol has NO value to founders — it's locked forever
|
||||
- More trading volume = more fees = more revenue
|
||||
- The protocol WANTS active trading, even if traders extract some ETH
|
||||
|
||||
**Bull market behavior (desired):**
|
||||
- Encourage risk-taking: wide anchor, big discovery → catch more trades, earn more fees
|
||||
- Floor can be minimal — ETH abundance means low risk
|
||||
- Parameters should maximize fee capture, not protect locked ETH
|
||||
|
||||
**Bear market behavior (desired):**
|
||||
- Protect the floor: prevent catastrophic ETH drain
|
||||
- But NOT at the expense of killing all trading — some exposure is acceptable
|
||||
- The question is always: does protecting X ETH cost more in lost fees than it saves?
|
||||
|
||||
**The optimization target is NOT "minimize trader PnL". It is "maximize fee revenue while keeping the protocol solvent."** Trader losses beyond what's needed for solvency represent missed fee opportunities.
|
||||
|
||||
**Key mechanism: Floor placement**
|
||||
|
||||
The floor position protects protocol solvency by holding ETH far from the current price. Its tick is computed as:
|
||||
|
||||
```
|
||||
floorTick = max(scarcityTick, mirrorTick, clampTick) toward KRK-cheap side
|
||||
```
|
||||
|
||||
Three signals determine the floor:
|
||||
- **scarcityTick**: derived from `vwapX96` and ETH/supply ratio. Correct when ETH is scarce.
|
||||
- **mirrorTick**: `currentTick + |adjustedVwapTick - currentTick|` on KRK-cheap side. Reflects VWAP distance symmetrically. Uses `getAdjustedVWAP(CI)`.
|
||||
- **clampTick**: minimum distance from anchor edge. `anchorSpacing = 200 + (34 × 20 × AW / 100)` ticks.
|
||||
|
||||
There is no EthScarcity/EthAbundance branching — the unified formula takes the max of all three signals.
|
||||
|
||||
**VWAP mirror defense:** During sell-heavy trading, the current tick drops but the VWAP stays higher, so the mirror distance *grows* — the floor naturally resists being walked down. CI controls mirror distance through `getAdjustedVWAP(CI)` with no magic numbers.
|
||||
|
||||
**Directional VWAP recording:** VWAP only records on ETH inflow (buys into the LM), preventing attackers from diluting VWAP with sells. `shouldRecordVWAP` compares `lastRecenterTick` to current tick to detect direction. Bootstrap: always records when `cumulativeVolume == 0`. (Commits `c97714c` + `ba018c4`.)
|
||||
**The optimization target is NOT "minimize trader PnL". It is "maximize fee revenue while keeping the protocol solvent."**
|
||||
|
||||
**Four optimizer parameters:**
|
||||
- `capitalInefficiency (CI)` — adjusts VWAP for floor placement: adjustedVWAP = 70%*VWAP + CI*VWAP. **Zero effect on fee revenue** — pure risk lever. CI=0% is safest.
|
||||
- `anchorShare (AS)` — ETH split between floor and anchor (low AS = more floor, high AS = more anchor)
|
||||
- `anchorWidth (AW)` — how wide the anchor position is in ticks
|
||||
- `capitalInefficiency (CI)` — adjusts VWAP for floor placement. **Zero effect on fee revenue** — pure risk lever. CI=0% is safest.
|
||||
- `anchorShare (AS)` — ETH split between floor and anchor
|
||||
- `anchorWidth (AW)` — anchor position width in ticks
|
||||
- `discoveryDepth (DD)` — discovery position liquidity density. **Zero effect on floor safety.**
|
||||
|
||||
**Parameter safety (2D frontier):**
|
||||
See [TECHNICAL_APPENDIX.md](../TECHNICAL_APPENDIX.md) for floor placement formula, parameter safety frontier, and asymmetric slippage analysis.
|
||||
|
||||
Only extreme AS×AW configurations survive adversarial attack:
|
||||
## OptimizerV3
|
||||
|
||||
| Config | Safe | Why |
|
||||
|--------|------|-----|
|
||||
| AS ≤ 35%, AW = 100 | Yes | Wide clamp (7000 ticks) prevents floor drain. Thin anchor = less ETH for attacker. |
|
||||
| AS ≥ 50%, AW = 20 | Yes | Thin concentrated anchor near price. Floor far away with minimal ETH. |
|
||||
| AW 40-80 at most AS | **No** | Kill zone — moderate depth AND moderate clamp distance. |
|
||||
`src/OptimizerV3.sol` — UUPS upgradeable. Binary bear/bull from staking sentiment.
|
||||
|
||||
**Design principle: Fix root causes, don't add band-aids.** Safety comes from the parameter space, not from position ratchets or overrides.
|
||||
**Inputs:** `percentageStaked` (0-100%), `averageTaxRate` (effective index 0-29)
|
||||
|
||||
## Optimizer V3
|
||||
**Mapping:**
|
||||
- `staked <= 91%` → always **BEAR**: AS=30%, AW=100, CI=0, DD=0.3e18
|
||||
- `staked > 91%` → **BULL** if `deltaS^3 * effIdx / 20 < 50`: AS=100%, AW=20, CI=0, DD=1e18
|
||||
|
||||
`src/OptimizerV3.sol` — UUPS upgradeable. Uses on-chain Harberger staking data to switch between safe bear and aggressive bull configurations.
|
||||
The binary step avoids the AW 40-80 kill zone. ~94% of state space maps to bear.
|
||||
|
||||
**Inputs:** `percentageStaked` (0-100%), `averageTaxRate` (maps to effective index 0-29 in discrete tax array, with +1 shift at index ≥14)
|
||||
## Staking Triangle Cycle
|
||||
|
||||
**Direct 2D mapping — no intermediate score:**
|
||||
- `staked ≤ 91%` → always **BEAR** (no euphoria signal)
|
||||
- `staked > 91%` → **BULL** if `deltaS³ × effIdx / 20 < 50`, else BEAR
|
||||
- `deltaS = 100 - stakedPct` (0-8 range)
|
||||
- Bull requires high staking AND low tax. Any decline snaps to bear instantly.
|
||||
|
||||
**Binary parameter output:**
|
||||
- **BEAR**: AS=30%, AW=100, CI=0, DD=0.3e18
|
||||
- **BULL**: AS=100%, AW=20, CI=0, DD=1e18
|
||||
|
||||
The binary step avoids the AW 40-80 kill zone entirely. ~94% of the staking state space maps to bear.
|
||||
|
||||
## Harberger Staking Triangle Cycle
|
||||
|
||||
The staking system naturally traces a triangle in (staking%, avgTax) space:
|
||||
|
||||
**Phase 1 — Fill up (bottom edge):** Staking grows 0→100%, tax starts low. Optimizer stays bear. Transitions to bull at ~95% staked.
|
||||
|
||||
**Phase 2 — Snatching wars (right edge):** 100% staked, snatching wars push average tax rate up. Always bull. Euphoria overwhelms tax cost.
|
||||
|
||||
**Phase 3 — Collapse (hypotenuse):** Nervous exits. High tax + declining staking → cubic term snaps to bear within 4-6% staking drop.
|
||||
|
||||
Game theory validates this trajectory — incentive structures force participants through this cycle.
|
||||
The staking system traces a triangle in (staking%, avgTax) space:
|
||||
1. **Fill up:** Staking grows 0→100%, tax low. Optimizer stays bear. Bull at ~95%.
|
||||
2. **Snatching wars:** 100% staked, tax rises. Always bull.
|
||||
3. **Collapse:** Nervous exits. Cubic term snaps to bear within 4-6% staking drop.
|
||||
|
||||
## System Snapshot
|
||||
- Solidity/Foundry DeFi protocol built around the Kraiken ERC20 token, a staking auction, and a three-position Uniswap V3 liquidity manager.
|
||||
- LiquidityManager.sol mints/burns supply to maintain ANCHOR (near price), DISCOVERY (offset discovery band), and FLOOR (VWAP-protected) positions with asymmetric slippage to resist arbitrage.
|
||||
- VWAPTracker.sol stores squared price in X96 format, compresses history, and feeds adjusted VWAP data for FLOOR placement. VWAP records directionally (ETH inflow only).
|
||||
- OptimizerV3.sol (UUPS upgradeable) reads staking sentiment to output capitalInefficiency, anchorShare, anchorWidth, and discoveryDepth via a direct 2D binary mapping.
|
||||
- Stake.sol runs the self-assessed tax staking system with snatching auctions, discrete tax brackets, and redistribution to tax recipients/UBI.
|
||||
- Kraiken ERC20 with mint/burn via LiquidityManager. VERSION=2.
|
||||
- LiquidityManager.sol: ANCHOR + DISCOVERY + FLOOR positions with asymmetric slippage.
|
||||
- VWAPTracker.sol: squared price in X96, compression, directional recording (ETH inflow only).
|
||||
- OptimizerV3.sol: UUPS upgradeable, direct 2D binary mapping.
|
||||
- Stake.sol: self-assessed tax, snatching auctions, discrete brackets, UBI redistribution.
|
||||
|
||||
## Development Workflow
|
||||
- Tooling: Foundry (`forge build`, `forge test`, `forge fmt`, `forge snapshot`), Anvil for local chain, Base Sepolia deployment script (`forge script ...BaseSepoliaDeploy`).
|
||||
- Repo structure highlights: `src/` (core contracts), `test/helpers/` (Uniswap/Kraiken bases), `lib/uni-v3-lib` (math + JS setup), `script/` (deploy), `out/` (artifacts), config via `foundry.toml` & `remappings.txt`.
|
||||
- Setup steps: clone repo, init/update submodules (`git submodule update --init --recursive`), install `lib/uni-v3-lib` dependencies (`npm install` in `lib/uni-v3-lib/`), ensure Foundry installed.
|
||||
- **ABI Architecture**: Contract ABIs are exported via `kraiken-lib/src/abis.ts`, which imports directly from `onchain/out/` (forge build artifacts). All consumers (ponder, web-app) import from kraiken-lib for type-safe, single-source-of-truth ABIs. Run `forge build` in `onchain/` to update ABIs across the stack.
|
||||
- Foundry: `forge build`, `forge test`, `forge fmt`, `forge snapshot`.
|
||||
- Repo: `src/` (contracts), `test/helpers/` (Uniswap/Kraiken bases), `lib/uni-v3-lib` (math), `script/` (deploy).
|
||||
- Setup: `git submodule update --init --recursive`, `npm install` in `lib/uni-v3-lib/`, Foundry installed.
|
||||
- **ABI flow**: `kraiken-lib/src/abis.ts` imports from `onchain/out/`. Run `forge build` to update ABIs stack-wide.
|
||||
|
||||
## Containerized Builds (Podman/Docker)
|
||||
- **Git Submodules**: Must be initialized before building (`git submodule update --init --recursive`). Empty `lib/` directories cause compilation failures.
|
||||
- **uni-v3-lib Dependencies**: Requires `npm install` in `lib/uni-v3-lib/` to populate `node_modules/` with Uniswap interfaces (IUniswapV3Pool, IUniswapV3Factory) and solady dependencies.
|
||||
- **Foundry Image**: Use `ghcr.io/foundry-rs/foundry:latest` for containers. The image includes `forge`, `cast`, `anvil` but NOT `jq` or `curl`.
|
||||
- **Root Access**: Bootstrap scripts that create deployment artifacts may need to run as root (user: "0:0") to write to mounted volumes.
|
||||
- **Volume Permissions**: Use `:z` (shared SELinux label) instead of `:Z` (private) for multi-container access to the same mount.
|
||||
## Testing & Analysis
|
||||
- Fuzzing under `analysis/`: configurable trade/stake biases, adversarial attacks, parameter sweeps. See `analysis/README.md`.
|
||||
- Adversarial testing (`run-adversarial.sh`, `run-v3-adversarial.sh`) validates floor defense.
|
||||
- Background LP analysis (`run-bglp-fee-test.sh`) measures fee retention under LP competition.
|
||||
|
||||
## Strategy & Mechanics
|
||||
- Outstanding supply excludes liquidity position balances and KRK held by `feeDestination`/`stakingPool`; enforce 20% staking cap (~20k positions).
|
||||
- Anchor width and discovery depth adjusted dynamically; anchorShare tunes ETH allocation, discoveryDepth controls liquidity density multiples, capitalInefficiency shifts VWAP floor valuation (70%-170%).
|
||||
- `token0isWeth` flag flips meaning of amount0/amount1 to ETH/KRAIKEN respectively.
|
||||
- Recenter logic keeps Uniswap positions aligned; floor placement uses `vwapX96` directly (not sqrt) in fixed-point math.
|
||||
## Containerized Builds
|
||||
- Git submodules must be initialized before building.
|
||||
- `lib/uni-v3-lib/` needs `npm install` for Uniswap interfaces.
|
||||
- Foundry image: `ghcr.io/foundry-rs/foundry:latest` (includes forge/cast/anvil, NOT jq/curl).
|
||||
- Volume permissions: use `:z` (shared SELinux label) for multi-container mounts.
|
||||
|
||||
## Testing & Analysis Suite
|
||||
- Fuzzing scripts under `analysis/` support configurable trade/stake biases, adversarial attack patterns, background LP competition, and parameter sweeps. See `analysis/README.md` for full details.
|
||||
- Adversarial testing (`run-adversarial.sh`, `run-v3-adversarial.sh`) validates floor defense against sell-heavy attacks.
|
||||
- Background LP fee analysis (`run-bglp-fee-test.sh`) measures fee retention under LP competition.
|
||||
- On-chain LP scanner (`scan-final.py`) compares real Uniswap V3 LP distributions to the BackgroundLP model.
|
||||
- Recorded artifacts include CSV tick traces, frontier maps, and human-readable summaries for exploit triage.
|
||||
|
||||
## Guardrails & Conventions
|
||||
- Respect access controls (`onlyLiquidityManager`, owner) and avoid editing implementation helpers like LiquidityProvider or ThreePositionStrategy.
|
||||
- Debug tips: inspect position CSVs, verify token type assumptions, and check VWAP recording direction during simulations.
|
||||
- Staking positions tracked by `positionId`; tax rates drawn from discrete array within Stake.sol.
|
||||
## Guardrails
|
||||
- Respect access controls (`onlyLiquidityManager`, owner).
|
||||
- `token0isWeth` flips amount semantics — confirm ordering before interpreting liquidity.
|
||||
- Floor uses `vwapX96` directly (not sqrt) in fixed-point math.
|
||||
- Outstanding supply excludes LM position balances and KRK held by `feeDestination`/`stakingPool`.
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
AGENTS.md
|
||||
|
|
@ -1,171 +1,69 @@
|
|||
## Foundry
|
||||
# KRAIKEN Onchain
|
||||
|
||||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
|
||||
Solidity contracts for the KRAIKEN protocol. Built with Foundry.
|
||||
|
||||
Foundry consists of:
|
||||
## Contracts
|
||||
|
||||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
|
||||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
|
||||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
|
||||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
|
||||
| Contract | Description |
|
||||
|----------|-------------|
|
||||
| `Kraiken.sol` | ERC20 token with mint/burn controlled by LiquidityManager. VERSION=2. |
|
||||
| `LiquidityManager.sol` | Three-position Uniswap V3 strategy (Anchor, Discovery, Floor). |
|
||||
| `Stake.sol` | Harberger-tax staking with snatching auctions and discrete tax brackets. |
|
||||
| `OptimizerV3.sol` | UUPS upgradeable. Binary bear/bull parameter selection from staking sentiment. |
|
||||
| `VWAPTracker.sol` | Volume-weighted average price with directional recording and compression. |
|
||||
|
||||
## Documentation
|
||||
## Setup
|
||||
|
||||
https://book.getfoundry.sh/
|
||||
|
||||
## Usage
|
||||
|
||||
### Install
|
||||
|
||||
```shell
|
||||
$ git clone
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ cd lib/uni-v3-lib
|
||||
$ yarn
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
cd lib/uni-v3-lib && npm install && cd ../..
|
||||
forge build
|
||||
forge test
|
||||
```
|
||||
|
||||
### Build
|
||||
## Deploy
|
||||
|
||||
```shell
|
||||
$ forge build
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```shell
|
||||
$ forge test
|
||||
```
|
||||
|
||||
### Format
|
||||
|
||||
```shell
|
||||
$ forge fmt
|
||||
```
|
||||
|
||||
### Gas Snapshots
|
||||
|
||||
```shell
|
||||
$ forge snapshot
|
||||
```
|
||||
|
||||
### Anvil
|
||||
|
||||
```shell
|
||||
$ anvil
|
||||
```
|
||||
|
||||
### Deploy
|
||||
|
||||
```shell
|
||||
forge clean
|
||||
forge cache clean
|
||||
```bash
|
||||
source .env
|
||||
forge script script/BaseSepoliaDeploy.sol:BaseSepoliaDeploy --slow --broadcast --verify --rpc-url ${BASE_SEPOLIA_RPC_URL}
|
||||
```
|
||||
|
||||
if verification fails:
|
||||
```shell
|
||||
forge verify-contract --watch --chain sepolia --constructor-args $(cast abi-encode "constructor(string,string,address,address,address)" "Kraiken" "KRAIKEN" "0x0227628f3F023bb0B980b67D528571c95c6DaC1c" "0xb16F35c0Ae2912430DAc15764477E179D9B9EbEa" "0x64dda11815b883c589afed914666ef2d63c8c338") 0x7517db0f2b24223f2f0e3567149ca180e204da8a Kraiken
|
||||
See [docs/DEPLOYMENT_RUNBOOK.md](../docs/DEPLOYMENT_RUNBOOK.md) for production deployment.
|
||||
|
||||
forge verify-contract --watch --chain sepolia --constructor-args $(cast abi-encode "constructor(address)" "0x7517db0f2b24223f2f0e3567149ca180e204da8a") 0x00b4d656b8182d0c2f4841b7a6f1429b94f73a66 Stake
|
||||
```
|
||||
## Deployments
|
||||
|
||||
### Base Mainnet
|
||||
|
||||
| Contract | Address |
|
||||
|----------|---------|
|
||||
| Kraiken | `0x45caa5929f6ee038039984205bdecf968b954820` |
|
||||
| Stake | `0xed70707fab05d973ad41eae8d17e2bcd36192cfc` |
|
||||
| LiquidityManager | `0x7fd4e645ce258dd3942eddbeb2f99137da8ba13b` |
|
||||
|
||||
### Cast
|
||||
|
||||
```shell
|
||||
$ cast <subcommand>
|
||||
```
|
||||
|
||||
### Help
|
||||
|
||||
```shell
|
||||
$ forge --help
|
||||
$ anvil --help
|
||||
$ cast --help
|
||||
```
|
||||
|
||||
|
||||
## Deployment on Base Sepolia
|
||||
|
||||
### Multisig
|
||||
|
||||
address: 0xf6a3eef9088A255c32b6aD2025f83E57291D9011
|
||||
|
||||
### Kraiken
|
||||
|
||||
address: 0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8
|
||||
|
||||
### Stake
|
||||
|
||||
address: 0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2
|
||||
|
||||
### LP
|
||||
|
||||
address: 0x3d6a8797693a0bC598210782B6a889E11A2340Cd
|
||||
|
||||
|
||||
## Deployment on Base
|
||||
|
||||
### Kraiken
|
||||
|
||||
address: 0x45caa5929f6ee038039984205bdecf968b954820
|
||||
|
||||
### Stake
|
||||
|
||||
address: 0xed70707fab05d973ad41eae8d17e2bcd36192cfc
|
||||
|
||||
### LP
|
||||
|
||||
address: 0x7fd4e645ce258dd3942eddbeb2f99137da8ba13b
|
||||
### Base Sepolia
|
||||
|
||||
| Contract | Address |
|
||||
|----------|---------|
|
||||
| Kraiken | `0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8` |
|
||||
| Stake | `0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2` |
|
||||
| LiquidityManager | `0x3d6a8797693a0bC598210782B6a889E11A2340Cd` |
|
||||
|
||||
## Research & Analysis
|
||||
|
||||
See [`analysis/KRAIKEN_RESEARCH_REPORT.md`](analysis/KRAIKEN_RESEARCH_REPORT.md) for the comprehensive research report covering:
|
||||
- Critical math bugs found and fixed (sqrt inflation + outstandingSupply)
|
||||
- Floor drain vulnerability analysis and VWAP mirror defense
|
||||
- Complete 2D parameter safety frontier (AS × AW)
|
||||
- Fee revenue characterization and LP competition modeling
|
||||
- OptimizerV3 design (direct 2D binary bear/bull mapping from Harberger staking data)
|
||||
- Staking triangle cycle dynamics
|
||||
The `analysis/` directory contains fuzzing scripts, parameter sweep tools, and security analysis:
|
||||
|
||||
The `analysis/` directory contains all fuzzing scripts, parameter sweep tools, and results data. See [`analysis/README.md`](analysis/README.md) for usage.
|
||||
- [SECURITY_REVIEW.md](analysis/SECURITY_REVIEW.md) — Security analysis and vulnerability assessment
|
||||
- [KRAIKEN_RESEARCH_REPORT.md](analysis/KRAIKEN_RESEARCH_REPORT.md) — Comprehensive research report
|
||||
- [README.md](analysis/README.md) — Analysis tool usage guide
|
||||
|
||||
Key findings: critical sqrt price bug fixed, 1050-combo 4D parameter sweep completed, floor ratchet vulnerability identified. See the research report for details.
|
||||
|
||||
## ABI Architecture
|
||||
|
||||
Contract ABIs flow through the stack via `kraiken-lib/src/abis.ts`, which imports directly from `out/` (forge build artifacts). Run `forge build` to update ABIs across all consumers (ponder, web-app).
|
||||
|
||||
## References
|
||||
|
||||
## Simulation data:
|
||||
|
||||
```json
|
||||
{ "VWAP":0,
|
||||
"comEthBal":1234,
|
||||
"comHarbBal":0,
|
||||
"comStakeShare":0,
|
||||
"liquidity":[{
|
||||
"liquidity":1234,
|
||||
"tickLower":-123,
|
||||
"tickUpper":124
|
||||
}],
|
||||
"startTime":1234,
|
||||
"txns":[{
|
||||
"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":0,"ethAmount":1,"x":0,"y":""},
|
||||
{"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":0,"ethAmount":2,"x":0,"y":""},
|
||||
{"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":0,"ethAmount":4,"x":0,"y":""},
|
||||
{"action":2,"harbAmount":3000,"tax":10,"y":""},
|
||||
{"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":4,"positionId":654321,"x":0,"y":""},
|
||||
{"action":2,"harbAmount":5000,"tax":20,"y":""},
|
||||
{"action":0,"ethAmount":8,"x":0,"y":""},
|
||||
{"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":1,"harbAmount":20000,"x":0,"y":""},
|
||||
{"action":5,"timeOffset":0,"x":0,"y":""},
|
||||
{"action":4,"positionId":654321,"x":0,"y":""},
|
||||
{"action":2,"harbAmount":8000,"tax":29,"y":""}
|
||||
]
|
||||
}
|
||||
```
|
||||
- [AGENTS.md](AGENTS.md) — Agent guide for onchain development
|
||||
- [UNISWAP_V3_MATH.md](UNISWAP_V3_MATH.md) — Uniswap V3 math reference
|
||||
- [hAIrberger.md](hAIrberger.md) — Dynamic LP strategy design document
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
# Testing Todo List
|
||||
|
||||
## High Priority
|
||||
- [x] ~~Break down testDoubleOverflowRealisticScenario() into 3 separate tests with assertions~~ ✅ **COMPLETED**
|
||||
- [x] ~~**🔥 CRITICAL: Create Position Dependency Order Test** - verify _set() function order ANCHOR → DISCOVERY → FLOOR with correct dependencies~~ ✅ **COMPLETED**
|
||||
- *Implemented as anchor-discovery contiguity checking in existing test infrastructure*
|
||||
- *Added tick range validation to checkLiquidity() function and _validateRecenterResult()*
|
||||
- *Correctly handles both token orderings (WETH as token0 vs token1)*
|
||||
- [x] ~~**🔥 NEXT CRITICAL: Add assertions to testRecordVolumeAndPriceUnsafe()** - should assert recording behavior and overflow detection~~ ✅ **COMPLETED**
|
||||
- *Implemented proper contract interaction with before/after state validation*
|
||||
- *Added assertions for normal recording, compression, and extreme transaction capping*
|
||||
- *Validates VWAP calculation accuracy and handles different overflow scenarios*
|
||||
- *Now properly tests contract behavior instead of just logging calculations*
|
||||
- [x] ~~Add assertions to testAttemptToCreateDoubleOverflow() - should assert expected overflow behavior instead of just logging~~ ✅ **COMPLETED via cleanup**
|
||||
- *Duplicate functionality removed - VWAPTracker.t.sol already contains proper assertion-based double overflow tests*
|
||||
- *Eliminated VWAPDoubleOverflowAnalysis.t.sol entirely - 100% duplicate of VWAPTracker.t.sol*
|
||||
- *Proper tests with assertions already exist: testDoubleOverflowExtremeEthPriceScenario(), testDoubleOverflowHyperinflatedHarbScenario(), testDoubleOverflowMaximumTransactionScenario()*
|
||||
|
||||
## Medium Priority
|
||||
- [ ] Create Floor Position VWAP Exclusivity Test - prove only floor position uses VWAP, anchor/discovery use current tick
|
||||
- *Moved from High Priority - VWAP exclusivity not critical as long as floor correctly uses VWAP*
|
||||
- [ ] Create EthScarcity vs EthAbundance Scenarios Test - test event emission and VWAP application logic
|
||||
- [ ] Complete LiquidityManager integration tests - comprehensive test suite exercising full contract
|
||||
- [ ] Create Floor Position Discount Verification Test - verify floor position pricing uses adjusted VWAP (70% + capital inefficiency)
|
||||
- [ ] Validate gas usage equivalent to original LiquidityManager contract
|
||||
|
||||
## Low Priority
|
||||
- [ ] Create Cross-Position Independence Test - verify anchor/discovery positions unaffected by VWAP changes
|
||||
- [ ] Convert UniswapMath to library for better reusability
|
||||
- [ ] Create interfaces for position strategies
|
||||
- [ ] Design plugin architecture for swappable position strategies
|
||||
- [ ] Add enhanced monitoring with granular events per component
|
||||
|
||||
## Code Organization Improvements ✅ **COMPLETED**
|
||||
- [x] ~~DELETE VWAPDoubleOverflowAnalysis.t.sol - 100% duplicate functionality~~ ✅ **COMPLETED**
|
||||
- [x] ~~RENAME ModularComponentsTest.t.sol → CompilationValidation.t.sol~~ ✅ **COMPLETED**
|
||||
- [x] ~~All tests verified passing after cleanup~~ ✅ **COMPLETED**
|
||||
|
||||
## Progress Summary
|
||||
- **Completed**: 4/15 tasks (27%) + 3 cleanup tasks
|
||||
- **High Priority Remaining**: 1/6 tasks (testExtremeExpensiveHarbHandling - doesn't exist)
|
||||
- **Medium Priority Remaining**: 5/5 tasks
|
||||
- **Low Priority Remaining**: 5/5 tasks
|
||||
|
||||
## Priority Analysis (Post-Test Consolidation)
|
||||
✅ **COMPLETED**: Position Dependency Order Test - Successfully implemented as anchor-discovery contiguity checking
|
||||
✅ **COMPLETED**: testRecordVolumeAndPriceUnsafe() Assertions - Now properly tests VWAP contract behavior:
|
||||
- Fuzzing test with 257 runs validates recording behavior and overflow detection
|
||||
- Asserts normal recording, compression triggers, and extreme transaction capping
|
||||
- Validates VWAP calculation accuracy across different scenarios
|
||||
- Tests actual contract interface instead of just mathematical calculations
|
||||
|
||||
**NEXT PRIORITY**: Add assertions to testAttemptToCreateDoubleOverflow() - Convert logging-only test to proper assertions
|
||||
|
||||
## Recent Completion
|
||||
✅ **Break down testDoubleOverflowRealisticScenario()** - Successfully split into 3 focused tests with proper assertions:
|
||||
- `testDoubleOverflowExtremeEthPriceScenario()` - ETH at $1M, KRAIKEN at $1
|
||||
- `testDoubleOverflowHyperinflatedHarbScenario()` - KRAIKEN at $1M, ETH at $3k
|
||||
- `testDoubleOverflowMaximumTransactionScenario()` - 10k ETH transactions
|
||||
|
||||
All new tests validate that double overflow requires unrealistic conditions, proving the 1000x compression limit provides adequate protection.
|
||||
Loading…
Add table
Add a link
Reference in a new issue