harb/onchain
openhands 02b055ceb9 fix: move VWAP bootstrap from forge script to bootstrap-common.sh
vm.warp in forge script --broadcast only affects the local simulation
phase, not the actual Anvil node.  The pool.observe([300,0]) call in
recenter() therefore reverted with OLD when Forge pre-flighted the
broadcast transactions on Anvil.

Fix:
- Remove the vm.warp + 2-recenter + SeedSwapper VWAP bootstrap from
  DeployLocal.sol (only contract deployment now, simpler and reliable).
- Add bootstrap_vwap() to bootstrap-common.sh that uses Anvil RPC
  evm_increaseTime + evm_mine to advance chain time before each recenter,
  then executes a 0.5 ETH WETH->KRK seed swap between them.
- Call bootstrap_vwap() before fund_liquidity_manager() in both
  containers/bootstrap.sh and ci-bootstrap.sh so the LM is seeded with
  thin positions (1 ETH) during bootstrap, ensuring the 0.5 ETH swap
  moves the price >400 ticks (amplitude gate).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 23:28:52 +00:00
..
.claude chore: analysis tooling, research artifacts, and code quality 2026-02-13 18:22:03 +00:00
.github/workflows chore: forge init 2024-03-12 10:00:53 +01:00
.husky Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
analysis fix: Remove dead Optimizer V2/V3 — Push3 is the active optimizer (#312) 2026-02-26 19:37:12 +00:00
lib feat/ponder-lm-indexing (#142) 2026-02-18 00:19:05 +01:00
script fix: move VWAP bootstrap from forge script to bootstrap-common.sh 2026-03-13 23:28:52 +00:00
src fix: Remove recenterAccess — make recenter() public with TWAP enforcement (#706) 2026-03-13 22:32:53 +00:00
test fix: Remove recenterAccess — make recenter() public with TWAP enforcement (#706) 2026-03-13 22:32:53 +00:00
.claude-code-supervisor.yml fix: refactor AGENTS.md into progressive-disclosure structure (#184) 2026-02-23 09:46:35 +00:00
.gas-snapshot chore: analysis tooling, research artifacts, and code quality 2026-02-13 18:22:03 +00:00
.gitignore fix: Details (#205) 2026-02-24 18:01:53 +00:00
.lintstagedrc.json Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
.secret.local start stack from container (#40) 2025-10-02 17:11:22 +02:00
.solhint.json Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
.solhintignore Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
AGENTS.md fix: Investigate: VWAP not preventing IL crystallization during buy-only recenter cycles (#543) 2026-03-11 03:31:45 +00:00
deployments-local.json feat: deployment scripts, E2E tests, and documentation 2026-02-13 18:21:49 +00:00
foundry.toml fix: revm evaluator — UUPS bypass, deployedBytecode, graceful attack ops 2026-03-12 19:54:58 +00:00
hAIrberger.md refactor: Complete project renaming from HARB/Harberger to KRAIKEN 2025-08-19 11:05:08 +02:00
lcov.info fix: Test coverage: Stake.sol to 100% (#284) 2026-02-26 04:28:47 +00:00
package-lock.json Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
package.json Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
README.md docs: consolidate and update all documentation for launch readiness 2026-02-13 19:22:34 +00:00
remappings.txt fix: Test coverage: LiquidityManager + Optimizer + OptimizerV3 to 100% (#285) 2026-02-26 02:41:02 +00:00
UNISWAP_V3_MATH.md more docs 2025-08-18 00:16:09 +02:00

KRAIKEN Onchain

Solidity contracts for the KRAIKEN protocol. Built with Foundry.

Contracts

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.

Setup

git submodule update --init --recursive
cd lib/uni-v3-lib && npm install && cd ../..
forge build
forge test

Deploy

source .env
forge script script/BaseSepoliaDeploy.sol:BaseSepoliaDeploy --slow --broadcast --verify --rpc-url ${BASE_SEPOLIA_RPC_URL}

See docs/DEPLOYMENT_RUNBOOK.md for production deployment.

Deployments

Base Mainnet

Contract Address
Kraiken 0x45caa5929f6ee038039984205bdecf968b954820
Stake 0xed70707fab05d973ad41eae8d17e2bcd36192cfc
LiquidityManager 0x7fd4e645ce258dd3942eddbeb2f99137da8ba13b

Base Sepolia

Contract Address
Kraiken 0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8
Stake 0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2
LiquidityManager 0x3d6a8797693a0bC598210782B6a889E11A2340Cd

Research & Analysis

The analysis/ directory contains fuzzing scripts, parameter sweep tools, and security analysis:

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