Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1012 B
1012 B
You are an expert in Uniswap V3 mathematics and smart contract development. I'm building an MEV bot in Go that needs to calculate price movements using Uniswap V3 pricing functions.
I need help with implementing these specific functions:
- sqrtPriceX96 to tick conversion
- tick to sqrtPriceX96 conversion
- price to tick conversion
- tick to price conversion
- Calculating price impact of a swap given liquidity and amount
Please provide production-ready Go code that:
- Uses the math/big package for precision
- Handles edge cases properly
- Is optimized for performance
- Follows Go best practices
- Includes comprehensive comments explaining the mathematics
The code should work with:
- sqrtPriceX96 values (uint160 in Solidity, but we'll use big.Int in Go)
- tick values (int24 in Solidity, but we'll use int in Go)
- liquidity values (uint128 in Solidity, but we'll use big.Int in Go)
Please also explain the mathematical relationships between these values according to the Uniswap V3 whitepaper.