Files
mev-beta/@prompts/uniswap-pricing.md
2025-09-12 01:16:30 -05:00

23 lines
1012 B
Markdown

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:
1. sqrtPriceX96 to tick conversion
2. tick to sqrtPriceX96 conversion
3. price to tick conversion
4. tick to price conversion
5. 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.