# Makefile for MEV Bot # Variables BINARY=mev-bot MAIN_FILE=cmd/mev-bot/main.go BINARY_PATH=bin/$(BINARY) # Default target .PHONY: all all: build # Build the application .PHONY: build build: @echo "Building $(BINARY)..." @mkdir -p bin @go build -o $(BINARY_PATH) $(MAIN_FILE) @echo "Build successful!" # Build market manager example .PHONY: build-mm build-mm: @echo "Building market manager example..." @mkdir -p bin @go build -o bin/marketmanager-example examples/marketmanager/main.go @echo "Market manager example built successfully!" # Build swap CLI tool .PHONY: build-swap-cli build-swap-cli: @echo "Building swap CLI tool..." @mkdir -p bin @go build -o bin/swap-cli cmd/swap-cli/main.go @echo "Swap CLI tool built successfully!" # Run the application .PHONY: run run: build @echo "Running $(BINARY)..." @$(BINARY_PATH) # Run market manager example .PHONY: run-mm run-mm: build-mm @echo "Running market manager example..." @bin/marketmanager-example # Run swap CLI tool .PHONY: run-swap-cli run-swap-cli: build-swap-cli @echo "Running swap CLI tool..." @bin/swap-cli # Run tests .PHONY: test test: @echo "Running tests..." @go test -v ./... # Run basic tests (fast) .PHONY: test-basic test-basic: @echo "Running basic tests (fast)..." @go test -v ./pkg/... -short # Run tests with coverage .PHONY: test-coverage test-coverage: @echo "Running tests with coverage..." @go test -coverprofile=coverage.out ./... @go tool cover -html=coverage.out -o coverage.html @echo "Coverage report generated: coverage.html" # Run tests with coverage for specific packages .PHONY: test-coverage-pkg test-coverage-pkg: @echo "Running tests with coverage for specific packages..." @go test -coverprofile=coverage.out $(PKG) && go tool cover -html=coverage.out -o coverage.html @echo "Coverage report generated: coverage.html" # Run unit tests .PHONY: test-unit test-unit: @echo "Running unit tests..." @go test -v ./test/unit/... # Run integration tests .PHONY: test-integration test-integration: @echo "Running integration tests..." @go test -v ./test/integration/... # Run end-to-end tests .PHONY: test-e2e test-e2e: @echo "Running end-to-end tests..." @go test -v ./test/e2e/... # Run property tests .PHONY: test-property test-property: @echo "Running property tests..." @go test -v ./test/property/... # Run fuzzing tests .PHONY: test-fuzzing test-fuzzing: @echo "Running fuzzing tests..." @go test -v ./test/fuzzing/... # Run stress tests .PHONY: test-stress test-stress: @echo "Running stress tests..." @go test -v ./test/stress/... # Run security tests .PHONY: test-security test-security: @echo "Running security tests..." @go test -v ./test/security/... # Run benchmark tests .PHONY: test-bench test-bench: @echo "Running benchmark tests..." @go test -bench=. -benchmem ./test/benchmarks/... # Run comprehensive tests (all test types) .PHONY: test-comprehensive test-comprehensive: @echo "Running comprehensive tests..." @$(MAKE) test-unit @$(MAKE) test-integration @$(MAKE) test-e2e @$(MAKE) test-property @$(MAKE) test-fuzzing # Run full audit tests (comprehensive + security + stress) .PHONY: test-audit test-audit: @echo "Running full audit tests..." @$(MAKE) test-comprehensive @$(MAKE) test-security @$(MAKE) test-stress @$(MAKE) test-bench # Run math-specific tests .PHONY: test-math test-math: @echo "Running math tests..." @go test -v ./pkg/math/... ./pkg/uniswap/... ./pkg/pricing/... # Run math-specific benchmarks .PHONY: test-math-bench test-math-bench: @echo "Running math benchmarks..." @go test -v -bench=. -benchmem ./pkg/math/... ./pkg/uniswap/... ./pkg/pricing/... # Run math-specific property tests .PHONY: test-math-property test-math-property: @echo "Running math property tests..." @go test -v ./test/property/... # Run all math-related tests .PHONY: test-math-all test-math-all: @echo "Running all math tests..." @$(MAKE) test-math @$(MAKE) test-math-bench @$(MAKE) test-math-property # ============================================================================== # Math Audit Commands # ============================================================================== .PHONY: math-audit math-audit-build math-audit-validate # Build the math audit tool math-audit-build: @echo "Building math audit tool..." cd tools/math-audit && go build -o ../../bin/math-audit ./cmd # Run comprehensive math audit math-audit: math-audit-build @echo "Running comprehensive math audit..." ./bin/math-audit audit --vectors default --report reports/math/latest --verbose # Validate specific exchange math-audit-validate: math-audit-build @echo "Validating specific exchange (use EXCHANGE=uniswap_v2)..." ./bin/math-audit validate --exchange $(or $(EXCHANGE),uniswap_v2) --vectors default --verbose # Quick math validation for CI math-audit-quick: math-audit-build @echo "Running quick math validation..." ./bin/math-audit audit --vectors default --report reports/math/ci --tolerance 0.001 # Run profitability simulation harness .PHONY: simulate-profit simulate-profit: @echo "Running profitability simulation..." @./scripts/run_profit_simulation.sh # Refresh MEV research datasets .PHONY: refresh-mev-datasets refresh-mev-datasets: @echo "Refreshing MEV research datasets..." @./scripts/refresh-mev-datasets.sh # Run comprehensive audit (all checks) .PHONY: audit-full audit-full: @echo "Running comprehensive audit..." @$(MAKE) vet @$(MAKE) lint @$(MAKE) test-audit @$(MAKE) math-audit @go run ./tools/security-scanner # Run security audit .PHONY: audit-security audit-security: @echo "Running security audit..." @go run ./tools/security-scanner @gosec ./... # Run performance audit .PHONY: audit-performance audit-performance: @echo "Running performance audit..." @$(MAKE) test-bench @./scripts/performance-profile.sh # Run code quality audit .PHONY: audit-quality audit-quality: @echo "Running code quality audit..." @$(MAKE) vet @$(MAKE) lint @go run ./tools/code-quality-checker # Run math-specific audit .PHONY: audit-math audit-math: @echo "Running math-specific audit..." @$(MAKE) test-math-all @$(MAKE) math-audit @go run ./tools/math-accuracy-checker # Run dependency audit .PHONY: audit-deps audit-deps: @echo "Running dependency audit..." @go list -m -u all @govulncheck ./... # Clean build artifacts .PHONY: clean clean: @echo "Cleaning..." @rm -rf bin/ @rm -f coverage.out coverage.html @echo "Clean complete!" # Install dependencies .PHONY: deps deps: @echo "Installing dependencies..." @go mod tidy @echo "Dependencies installed!" # Format code .PHONY: fmt fmt: @echo "Formatting code..." @go fmt ./... # Format market manager code .PHONY: fmt-mm fmt-mm: @echo "Formatting market manager code..." @go fmt ./pkg/marketmanager/... @go fmt ./examples/marketmanager/... # Vet code .PHONY: vet vet: @echo "Vetting code..." @go vet ./... # Vet market manager code .PHONY: vet-mm vet-mm: @echo "Vetting market manager code..." @go vet ./pkg/marketmanager/... @go vet ./examples/marketmanager/... # Lint code (requires golangci-lint) .PHONY: lint lint: @echo "Linting code..." @which golangci-lint > /dev/null || (echo "golangci-lint not found, installing..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest) @golangci-lint run # Update dependencies .PHONY: update update: @echo "Updating dependencies..." @go get -u ./... @go mod tidy @echo "Dependencies updated!" # Install test dependencies .PHONY: test-deps test-deps: @echo "Installing test dependencies..." @go get github.com/stretchr/testify/assert @go mod tidy @echo "Test dependencies installed!" # Install development dependencies .PHONY: dev-deps dev-deps: @echo "Installing development dependencies..." @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest @go install github.com/securego/gosec/v2/cmd/gosec@latest @go install golang.org/x/vuln/cmd/govulncheck@latest @go install github.com/go-delve/delve/cmd/dlv@latest @go mod tidy @echo "Development dependencies installed!" # Development environment setup .PHONY: dev-setup dev-setup: @echo "Setting up development environment..." @$(MAKE) deps @$(MAKE) dev-deps @$(MAKE) test-deps @./scripts/setup-dev.sh @echo "Development environment setup complete!" # Run development workflow (tests + vet + lint) .PHONY: dev-workflow dev-workflow: @echo "Running development workflow..." @$(MAKE) fmt @$(MAKE) vet @$(MAKE) lint @$(MAKE) test-basic # Run development workflow with coverage .PHONY: dev-workflow-full dev-workflow-full: @echo "Running development workflow with coverage..." @$(MAKE) fmt @$(MAKE) vet @$(MAKE) lint @$(MAKE) test-coverage # Run application in development mode .PHONY: dev-run dev-run: build @echo "Running application in development mode..." @$(BINARY_PATH) --config config/development.yaml # Run application in debug mode .PHONY: debug debug: build @echo "Running application in debug mode..." @dlv exec -- $(BINARY_PATH) --config config/development.yaml # Watch and run tests on file changes (requires entr - install with 'apt-get install entr' or 'brew install entr') .PHONY: watch-tests watch-tests: @echo "Watching for file changes and running tests..." @find . -name "*.go" -not -path "./vendor/*" -not -path "./bin/*" | entr -c $(MAKE) test-basic # Watch and run development workflow on file changes .PHONY: watch-dev watch-dev: @echo "Watching for file changes and running dev workflow..." @find . -name "*.go" -not -path "./vendor/*" -not -path "./bin/*" | entr -c $(MAKE) dev-workflow # Generate code documentation .PHONY: docs docs: @echo "Generating code documentation..." @mkdir -p docs/gen @go doc -all ./... > docs/gen/code-documentation.txt @echo "Code documentation generated in docs/gen/code-documentation.txt" # Generate API documentation .PHONY: docs-api docs-api: @echo "Generating API documentation..." @mkdir -p docs/gen/api @go doc -all ./pkg/... > docs/gen/api/reference.txt @echo "API documentation generated in docs/gen/api/reference.txt" # Run all documentation generation .PHONY: docs-all docs-all: @$(MAKE) docs @$(MAKE) docs-api @echo "All documentation generated in docs/gen/" # CI/CD Pipeline targets .PHONY: ci-precommit ci-precommit: @echo "Running pre-commit validation..." @./scripts/ci-precommit.sh .PHONY: ci-quick ci-quick: @echo "Running quick CI pipeline..." @./scripts/ci-quick.sh .PHONY: ci-dev ci-dev: @echo "Running development CI pipeline..." @./scripts/ci-dev.sh .PHONY: ci-full ci-full: @echo "Running full CI pipeline..." @./scripts/ci-full.sh .PHONY: ci-container ci-container: @echo "Running CI in container..." @./scripts/ci-container.sh dev .PHONY: ci-container-quick ci-container-quick: @echo "Running quick CI in container..." @./scripts/ci-container.sh quick .PHONY: ci-watch ci-watch: @echo "Starting CI watch mode..." @./scripts/ci-watch.sh precommit .PHONY: ci-watch-quick ci-watch-quick: @echo "Starting quick CI watch mode..." @./scripts/ci-watch.sh quick # Help .PHONY: help help: @echo "Available targets:" @echo "" @echo "Build & Run:" @echo " all - Build the application (default)" @echo " build - Build the application" @echo " build-mm - Build market manager example" @echo " build-swap-cli - Build swap CLI tool" @echo " run - Build and run the application" @echo " run-mm - Build and run market manager example" @echo " run-swap-cli - Build and run swap CLI tool" @echo "" @echo "Testing (Multi-Level):" @echo " test - Run tests" @echo " test-basic - Run basic tests (fast)" @echo " test-unit - Run unit tests" @echo " test-integration - Run integration tests" @echo " test-e2e - Run end-to-end tests" @echo " test-property - Run property tests" @echo " test-fuzzing - Run fuzzing tests" @echo " test-stress - Run stress tests" @echo " test-security - Run security tests" @echo " test-bench - Run benchmark tests" @echo " test-comprehensive - Run comprehensive tests (all test types)" @echo " test-audit - Run full audit tests (comprehensive + security + stress)" @echo " test-coverage - Run tests with coverage report" @echo " test-coverage-pkg - Run tests with coverage for specific package (use with PKG=package/path)" @echo "" @echo "Math Testing:" @echo " test-math - Run math tests" @echo " test-math-bench - Run math benchmarks" @echo " test-math-property - Run math property tests" @echo " test-math-all - Run all math tests" @echo "" @echo "Code Quality:" @echo " fmt - Format code" @echo " fmt-mm - Format market manager code" @echo " vet - Vet code" @echo " vet-mm - Vet market manager code" @echo " lint - Lint code (requires golangci-lint)" @echo "" @echo "Auditing:" @echo " audit-full - Run comprehensive audit (all checks)" @echo " audit-security - Run security audit" @echo " audit-performance - Run performance audit" @echo " audit-quality - Run code quality audit" @echo " audit-math - Run math-specific audit" @echo " audit-deps - Run dependency audit" @echo " math-audit - Run deterministic math audit" @echo "" @echo "Development:" @echo " dev-setup - Setup development environment" @echo " dev-deps - Install development dependencies" @echo " dev-workflow - Run development workflow (fmt + vet + lint + basic test)" @echo " dev-workflow-full - Run development workflow with coverage" @echo " dev-run - Run application in development mode" @echo " debug - Run application in debug mode" @echo " watch-tests - Watch for file changes and run basic tests (requires entr)" @echo " watch-dev - Watch for file changes and run dev workflow (requires entr)" @echo "" @echo "Documentation:" @echo " docs - Generate general code documentation" @echo " docs-api - Generate API documentation" @echo " docs-all - Generate all documentation" @echo "" @echo "CI/CD Pipeline:" @echo " ci-precommit - Fast pre-commit validation (10-30s)" @echo " ci-quick - Quick CI pipeline (30-60s)" @echo " ci-dev - Development CI pipeline (1-2min)" @echo " ci-full - Full CI pipeline (3-5min)" @echo " ci-container - Run CI in container" @echo " ci-container-quick - Run quick CI in container" @echo " ci-watch - Watch files and run pre-commit validation" @echo " ci-watch-quick - Watch files and run quick CI" @echo "" @echo "Maintenance:" @echo " clean - Clean build artifacts" @echo " deps - Install dependencies" @echo " test-deps - Install test dependencies" @echo " update - Update dependencies" @echo " help - Show this help" @echo "" @echo "Simulation:" @echo " simulate-profit - Run profitability simulation" @echo "" @echo "Git Workflow:" @echo " git-setup - Setup git hooks and enhanced workflow" @echo " git-feature - Create feature branch (use with FEATURE=name)" @echo " git-fix - Create fix branch (use with FIX=name)" @echo " git-pr - Create PR simulation (use with TARGET=branch)" @echo " git-merge - Smart merge with CI validation (use with BRANCH=name)" @echo " git-server-init - Initialize local git server for team simulation" @echo " git-server-status - Show local git server status" # Git workflow targets .PHONY: git-setup git-setup: @echo "Setting up git hooks and enhanced workflow..." @./scripts/git-hooks-setup.sh .PHONY: git-feature git-feature: @echo "Creating feature branch..." @./scripts/git-enhanced.sh feature $(FEATURE) .PHONY: git-fix git-fix: @echo "Creating fix branch..." @./scripts/git-enhanced.sh fix $(FIX) .PHONY: git-pr git-pr: @echo "Creating PR simulation..." @./scripts/git-enhanced.sh pr-create $(TARGET) .PHONY: git-merge git-merge: @echo "Smart merge with CI validation..." @./scripts/git-enhanced.sh merge $(BRANCH) .PHONY: git-server-init git-server-init: @echo "Initializing local git server..." @./scripts/git-local-server.sh init .PHONY: git-server-status git-server-status: @echo "Showing local git server status..." @./scripts/git-local-server.sh status