harb/onchain/README.md

172 lines
3.8 KiB
Markdown
Raw Normal View History

2024-03-12 12:01:48 +01:00
## Foundry
2023-11-21 21:24:48 +01:00
2024-03-12 12:01:48 +01:00
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
Foundry consists of:
- **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.
## Documentation
https://book.getfoundry.sh/
## Usage
2024-03-12 20:22:10 +01:00
### Install
```shell
$ git clone
$ git submodule init
$ git submodule update
$ cd lib/uni-v3-lib
$ yarn
```
2024-03-12 12:01:48 +01:00
### Build
```shell
$ forge build
```
### Test
```shell
$ forge test
2023-11-21 21:24:48 +01:00
```
2024-03-12 12:01:48 +01:00
### Format
```shell
$ forge fmt
```
### Gas Snapshots
```shell
$ forge snapshot
2023-11-21 21:24:48 +01:00
```
2024-03-12 12:01:48 +01:00
### Anvil
2023-11-21 21:24:48 +01:00
2024-03-12 12:01:48 +01:00
```shell
$ anvil
2023-11-21 21:24:48 +01:00
```
2024-03-12 12:01:48 +01:00
### Deploy
```shell
2024-06-25 09:38:23 +02:00
forge clean
forge cache clean
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
```
2024-04-11 22:32:47 +02:00
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
2024-04-11 22:32:47 +02:00
forge verify-contract --watch --chain sepolia --constructor-args $(cast abi-encode "constructor(address)" "0x7517db0f2b24223f2f0e3567149ca180e204da8a") 0x00b4d656b8182d0c2f4841b7a6f1429b94f73a66 Stake
2024-04-11 22:32:47 +02:00
```
2024-03-12 12:01:48 +01:00
### Cast
```shell
$ cast <subcommand>
2023-11-21 21:24:48 +01:00
```
2024-03-12 12:01:48 +01:00
### Help
2023-11-21 21:24:48 +01:00
2024-03-12 12:01:48 +01:00
```shell
$ forge --help
$ anvil --help
$ cast --help
2023-11-21 21:24:48 +01:00
```
2024-03-12 20:22:10 +01:00
2025-02-05 19:47:18 +01:00
## Deployment on Base Sepolia
2024-03-12 20:22:10 +01:00
2025-02-05 19:47:18 +01:00
### Multisig
2024-03-12 20:22:10 +01:00
2025-02-05 19:47:18 +01:00
address: 0xf6a3eef9088A255c32b6aD2025f83E57291D9011
2024-05-15 19:44:56 +02:00
### Kraiken
2024-03-12 20:22:10 +01:00
2025-02-05 19:47:18 +01:00
address: 0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8
2024-03-12 20:22:10 +01:00
2025-02-05 19:47:18 +01:00
### Stake
2024-05-15 19:44:56 +02:00
2025-02-05 19:47:18 +01:00
address: 0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2
2024-04-11 22:32:47 +02:00
2024-06-25 10:33:33 +02:00
### LP
2025-02-05 19:47:18 +01:00
address: 0x3d6a8797693a0bC598210782B6a889E11A2340Cd
2024-08-15 18:30:43 +02:00
2025-02-05 19:47:18 +01:00
## Deployment on Base
### Kraiken
2024-08-15 18:30:43 +02:00
2025-02-05 19:47:18 +01:00
address: 0x45caa5929f6ee038039984205bdecf968b954820
2024-08-15 18:30:43 +02:00
### Stake
2025-02-05 19:47:18 +01:00
address: 0xed70707fab05d973ad41eae8d17e2bcd36192cfc
2024-08-15 18:30:43 +02:00
### LP
2025-02-05 19:47:18 +01:00
address: 0x7fd4e645ce258dd3942eddbeb2f99137da8ba13b
2024-08-15 18:30:43 +02:00
## 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 all fuzzing scripts, parameter sweep tools, and results data. See [`analysis/README.md`](analysis/README.md) for usage.
2024-09-10 19:13:43 +02:00
## 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":""}
]
}
```