diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index cee577a..3d2dcfa 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -20,7 +20,7 @@ Docker Compose services (in startup order): ## Network Contexts -Two distinct Anvil contexts are in use; they target different networks. +Two network contexts are relevant: the dev-stack Anvil (docker-compose) and the backtesting tools that require Base mainnet. ### Dev stack Anvil (docker-compose) @@ -30,7 +30,7 @@ The `anvil` service in `docker-compose.yml` runs `containers/anvil-entrypoint.sh ${FORK_URL:-https://sepolia.base.org} ``` -**Default: Base Sepolia.** Uniswap V3 contracts are re-deployed fresh by the `bootstrap` service at start-up, so the fork target only affects block history and chain-id context. The bootstrap deploys all protocol contracts (Kraiken, Stake, LiquidityManager, OptimizerProxy) at addresses written to `tmp/containers/contracts.env`. +**Default: Base Sepolia.** The `bootstrap` service deploys all KRAIKEN protocol contracts (Kraiken, Stake, Optimizer, LiquidityManager) and creates a new KRK/WETH pool using the existing Uniswap V3 Factory already present on the forked network. Addresses are written to `tmp/containers/contracts.env`. To fork Base mainnet instead (required for red-team / backtesting — see below): @@ -38,22 +38,24 @@ To fork Base mainnet instead (required for red-team / backtesting — see below) FORK_URL=https://mainnet.base.org docker compose up -d ``` -### Backtesting / red-team Anvil (`scripts/harb-evaluator/red-team.sh`) +### Backtesting / red-team (`scripts/harb-evaluator/red-team.sh`) -`red-team.sh` boots the docker-compose stack and then calls protocol operations using **Base mainnet** addresses for the Uniswap V3 periphery (V3_FACTORY, SwapRouter02, NonfungiblePositionManager). These addresses are only valid on a mainnet fork. Before running red-team.sh, set: +`red-team.sh` boots the docker-compose stack and then calls protocol operations using **Base mainnet** addresses for the Uniswap V3 periphery (V3_FACTORY, SwapRouter02, NonfungiblePositionManager). These addresses are only valid on a mainnet fork. + +`red-team.sh` calls `sudo docker compose up -d` internally, and `sudo` strips environment variables by default. Pass `FORK_URL` inline with `-E` to preserve it: ```bash -export FORK_URL=https://mainnet.base.org +FORK_URL=https://mainnet.base.org sudo -E bash scripts/harb-evaluator/red-team.sh ``` ### FitnessEvaluator (`onchain/test/FitnessEvaluator.t.sol`) -`FitnessEvaluator.t.sol` is completely independent of the dev Anvil. It forks Base mainnet once per `forge test` run using the `BASE_RPC_URL` environment variable and has no relationship to the docker-compose stack: +`FitnessEvaluator.t.sol` does **not** use Anvil. It uses Foundry's native revm backend (`vm.createSelectFork`) to fork Base mainnet in-process — no docker-compose dependency: ```bash BASE_RPC_URL=https://mainnet.base.org \ FITNESS_MANIFEST_DIR=/tmp/manifest \ -forge test --match-contract FitnessEvaluator -vv +forge test --match-contract FitnessEvaluator --match-test testBatchEvaluate -vv ``` ## Quick Start