harb/onchain/README.md

70 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

# KRAIKEN Onchain
2023-11-21 21:24:48 +01:00
Solidity contracts for the KRAIKEN protocol. Built with Foundry.
2024-03-12 12:01:48 +01:00
## Contracts
2024-03-12 12:01:48 +01:00
| 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. |
2024-03-12 12:01:48 +01:00
## Setup
2024-03-12 12:01:48 +01:00
```bash
git submodule update --init --recursive
cd lib/uni-v3-lib && npm install && cd ../..
forge build
forge test
2024-03-12 12:01:48 +01:00
```
## Deploy
2024-03-12 12:01:48 +01:00
```bash
2024-03-12 20:22:10 +01:00
source .env
2025-01-23 16:52:13 +01:00
forge script script/BaseSepoliaDeploy.sol:BaseSepoliaDeploy --slow --broadcast --verify --rpc-url ${BASE_SEPOLIA_RPC_URL}
2024-03-12 12:01:48 +01:00
```
See [docs/DEPLOYMENT_RUNBOOK.md](../docs/DEPLOYMENT_RUNBOOK.md) for production deployment.
2024-04-11 22:32:47 +02:00
## Deployments
2024-04-11 22:32:47 +02:00
### Base Mainnet
2024-03-12 12:01:48 +01:00
| Contract | Address |
|----------|---------|
| Kraiken | `0x45caa5929f6ee038039984205bdecf968b954820` |
| Stake | `0xed70707fab05d973ad41eae8d17e2bcd36192cfc` |
| LiquidityManager | `0x7fd4e645ce258dd3942eddbeb2f99137da8ba13b` |
2024-05-15 19:44:56 +02:00
### Base Sepolia
2024-04-11 22:32:47 +02:00
| Contract | Address |
|----------|---------|
| Kraiken | `0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8` |
| Stake | `0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2` |
| LiquidityManager | `0x3d6a8797693a0bC598210782B6a889E11A2340Cd` |
2024-06-25 10:33:33 +02:00
## Research & Analysis
2024-08-15 18:30:43 +02:00
The `analysis/` directory contains fuzzing scripts, parameter sweep tools, and security analysis:
2024-08-15 18:30:43 +02:00
- [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
2024-08-15 18:30:43 +02:00
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).
2024-09-10 19:13:43 +02:00
## References
- [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