refactor: move all remaining files to orig/ directory
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>
This commit is contained in:
16
orig/@prompts/README.md
Normal file
16
orig/@prompts/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# MEV Bot Development Prompts
|
||||
|
||||
This directory contains prompts that can be used with AI coding assistants to help with the development of the MEV bot.
|
||||
|
||||
## Purpose
|
||||
|
||||
These prompts are designed to help developers:
|
||||
1. Understand complex Uniswap V3 pricing mathematics
|
||||
2. Implement efficient market scanning algorithms
|
||||
3. Optimize arbitrage detection logic
|
||||
4. Handle Ethereum transaction monitoring
|
||||
5. Implement gas optimization strategies
|
||||
|
||||
## Usage
|
||||
|
||||
When working on specific parts of the MEV bot, you can use these prompts with your AI coding assistant to get targeted help and suggestions.
|
||||
24
orig/@prompts/arbitrum-monitoring.md
Normal file
24
orig/@prompts/arbitrum-monitoring.md
Normal file
@@ -0,0 +1,24 @@
|
||||
You are an expert in Ethereum and Arbitrum blockchain development. I'm building an MEV bot in Go that needs to monitor the Arbitrum sequencer for potential swap transactions.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Setting up a connection to an Arbitrum node (both RPC and WebSocket)
|
||||
2. Efficiently monitoring new blocks as they are added to the chain
|
||||
3. Monitoring the mempool for pending transactions
|
||||
4. Identifying transactions that interact with Uniswap-like contracts
|
||||
5. Decoding transaction data to extract swap parameters
|
||||
6. Handling network errors and reconnections gracefully
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Uses the go-ethereum library
|
||||
- Implements efficient polling or event-driven monitoring
|
||||
- Handles errors gracefully
|
||||
- Follows Go best practices
|
||||
- Is optimized for performance
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Connect to the Arbitrum mainnet RPC endpoint (https://arb1.arbitrum.io/rpc)
|
||||
- Monitor for transactions to common DEX contract addresses
|
||||
- Extract function signatures and parameters from transaction data
|
||||
- Decode swap function calls to get token addresses and amounts
|
||||
27
orig/@prompts/concurrency-patterns.md
Normal file
27
orig/@prompts/concurrency-patterns.md
Normal file
@@ -0,0 +1,27 @@
|
||||
You are an expert in Go concurrency patterns and high-performance systems. I'm building an MEV bot that needs to efficiently process thousands of transactions per second using advanced concurrency patterns.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Implementing efficient worker pools for transaction processing
|
||||
2. Creating pipeline patterns for multi-stage processing
|
||||
3. Implementing fan-in and fan-out patterns for data distribution
|
||||
4. Using channels effectively for communication between goroutines
|
||||
5. Managing rate limiting across multiple RPC endpoints
|
||||
6. Implementing backpressure handling to prevent resource exhaustion
|
||||
7. Optimizing memory usage and garbage collection
|
||||
8. Using context for cancellation and timeouts
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Implements efficient concurrency patterns
|
||||
- Handles errors gracefully without leaking goroutines
|
||||
- Uses appropriate buffering for channels
|
||||
- Follows Go best practices for concurrent programming
|
||||
- Includes comprehensive comments explaining the patterns used
|
||||
- Provides metrics for monitoring performance
|
||||
|
||||
The code should:
|
||||
- Process transactions with minimal latency
|
||||
- Scale efficiently across multiple CPU cores
|
||||
- Handle backpressure gracefully
|
||||
- Provide clear error handling and recovery
|
||||
- Include benchmarks for critical functions
|
||||
50
orig/@prompts/continuous-dev.md
Normal file
50
orig/@prompts/continuous-dev.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Continuous Development Prompt
|
||||
|
||||
You are CoderSpert, expert coder, continuing work on the MEV Bot repository at `/home/administrator/projects/mev-beta`. Your goal is to drive the codebase to a production-grade, profitable state through iterative development, testing, auditing, and documentation updates. Follow the phases below in order, looping until all checks pass with no outstanding findings. Never skip a phase and never exit unless every requirement has been satisfied.
|
||||
|
||||
---
|
||||
|
||||
## Phase 0 – Baseline Stabilisation
|
||||
1. Complete or revert the `UniversalDecimal` migration so `go build ./...` and `go test ./...` succeed.
|
||||
2. Restore or update public APIs referenced by tests (`scanner.NewMarketScanner`, `pools.NewCREATE2Calculator`, etc.) and adjust the test suites accordingly.
|
||||
3. Fix property and fuzz tests under `test/property` and `test/fuzzing` (round-trip, monotonicity, pricing symmetry) so they pass with correct math.
|
||||
4. Update CI workflows temporarily to avoid live RPC calls while the codebase is red.
|
||||
5. Do not proceed until the baseline build and tests are green.
|
||||
|
||||
## Phase 1 – Math Audit Tooling
|
||||
1. Create `tools/math-audit`, a Go CLI that loads exchange vectors and validates pricing math.
|
||||
2. Implement commands such as `math-audit --vectors default --report reports/math/latest` producing JSON and Markdown outputs.
|
||||
3. Store canonical pool vectors under `tools/math-audit/vectors/` for Uniswap V2/V3, Camelot/Algebra variants, Curve, Balancer, TraderJoe, Ramses, etc.
|
||||
4. Reuse/port existing property & fuzz checks into the CLI and ensure deterministic seeding.
|
||||
5. Add `make math-audit` plus documentation in `docs/5_development/TESTING_BENCHMARKING.md` and a helper script `scripts/run_audit_suite.sh`.
|
||||
|
||||
## Phase 2 – Math & Arbitrage Corrections
|
||||
1. Use the CLI to fix pricing, amount in/out, and price-impact calculations per exchange until vector error ≤ 1 bp.
|
||||
2. Ensure the arbitrage pipeline uses `UniversalDecimal` end-to-end and add regression tests for profit thresholds, spreads, and slippage.
|
||||
3. Document rounding/decimal policies and update affected packages and tests.
|
||||
|
||||
## Phase 3 – CI/CD & Security Hardening
|
||||
1. Restructure GitHub workflows into environment-specific pipelines (dev/test/audit/staging) with optimised caching.
|
||||
2. Integrate math audit, `gosec`, `govulncheck`, dependency scans, fuzzing (nightly), and ensure local git hooks mirror CI checks.
|
||||
3. Generate formal auditor reports in `docs/8_reports/` (math audit, security audit, coverage summaries) and expose helper scripts.
|
||||
|
||||
## Phase 4 – Profitability & Production Readiness
|
||||
1. Build a historical replay/simulation harness (e.g., `tools/simulation`) to estimate hit rate and net profit after gas across supported exchanges.
|
||||
2. Instrument Prometheus metrics for latency, errors, and profitability; update `docs/6_operations` with dashboards and runbooks.
|
||||
3. Iterate fixes until math audit, fuzz/property tests, security scans, and profitability simulations all pass without findings.
|
||||
|
||||
## Phase 5 – Agent Validation & Release
|
||||
1. Run the full audit suite and profitability simulation under Qwen (update `.qwen/QWEN.md` and commands). Address all findings.
|
||||
2. Repeat under Claude (update `.claude/CLAUDE.md`). Address findings.
|
||||
3. Execute final CI: lint, unit, property, math audit, security, benchmarks, Docker build, integration (mock/live as applicable). Ensure all green.
|
||||
4. Generate final reports in `docs/8_reports/` and a deployment summary describing readiness.
|
||||
5. Confirm the service builds (`make build`), runs with mock configuration (`./bin/mev-bot start`), and profitability simulation meets targets. Only then conclude.
|
||||
|
||||
---
|
||||
|
||||
### General Rules
|
||||
- Maintain Conventional Commits and keep changes atomic.
|
||||
- Preserve or improve test coverage (≥85% for math packages, ≥80% overall).
|
||||
- Update documentation (README, AGENTS.md, docs/5_development, docs/6_operations) whenever workflows or expectations change.
|
||||
- Never remove existing tests; refactor or extend them to fit new APIs.
|
||||
- Loop through the phases, rerunning audits and fixing issues, until no outstanding findings remain.
|
||||
24
orig/@prompts/database.md
Normal file
24
orig/@prompts/database.md
Normal file
@@ -0,0 +1,24 @@
|
||||
You are an expert in Go database integration and data persistence. I'm building an MEV bot in Go that needs to store and query historical data for analysis and strategy optimization.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Setting up a database for storing transaction data, token data, enchange and pool data
|
||||
2. Designing efficient database schemas for MEV data
|
||||
3. Implementing efficient data access patterns
|
||||
4. Handling database migrations
|
||||
5. Optimizing queries for performance
|
||||
6. Implementing data retention policies
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Uses an embedded database like SQLite or BadgerDB
|
||||
- Implements efficient data access patterns
|
||||
- Handles database connections properly
|
||||
- Follows Go best practices
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Store transaction and swap data efficiently
|
||||
- Support fast querying of historical data
|
||||
- Implement proper indexing for performance
|
||||
- Handle concurrent access safely
|
||||
- Include backup and recovery mechanisms
|
||||
27
orig/@prompts/error-handling.md
Normal file
27
orig/@prompts/error-handling.md
Normal file
@@ -0,0 +1,27 @@
|
||||
You are an expert in Go error handling and logging best practices. I'm building an MEV bot in Go that needs robust error handling and comprehensive logging for production deployment.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Implementing structured logging throughout the application
|
||||
2. Creating meaningful error messages for debugging
|
||||
3. Implementing retry mechanisms for transient failures
|
||||
4. Handling fatal errors gracefully
|
||||
5. Implementing circuit breakers for external services
|
||||
6. Creating health checks and metrics
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Uses a structured logging library (like zap or logrus)
|
||||
- Implements comprehensive error wrapping and context
|
||||
- Includes retry mechanisms with exponential backoff
|
||||
- Handles fatal errors gracefully with proper cleanup
|
||||
- Follows Go best practices for error handling
|
||||
- Is optimized for performance
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Log at appropriate levels (debug, info, warn, error)
|
||||
- Include contextual information in log messages
|
||||
- Implement circuit breakers for RPC connections
|
||||
- Handle timeouts appropriately
|
||||
- Provide health check endpoints
|
||||
- Export metrics for monitoring
|
||||
26
orig/@prompts/gas-optimization.md
Normal file
26
orig/@prompts/gas-optimization.md
Normal file
@@ -0,0 +1,26 @@
|
||||
You are an expert in Ethereum gas optimization and MEV strategies. I'm building an MEV bot in Go that needs to optimize transaction submission for maximum profitability.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Estimating optimal gas prices for arbitrage transactions
|
||||
2. Implementing transaction bundling strategies
|
||||
3. Working with flashbots or similar MEV protection services
|
||||
4. Optimizing transaction ordering within bundles
|
||||
5. Handling frontrunning and backrunning strategies
|
||||
6. Managing gas refunds and stipends
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Integrates with flashbots or similar MEV protection services
|
||||
- Calculates optimal gas prices based on network conditions
|
||||
- Implements transaction bundling for atomic execution
|
||||
- Handles errors and edge cases properly
|
||||
- Follows Go best practices
|
||||
- Is optimized for performance
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Connect to flashbots relay or similar service
|
||||
- Calculate optimal gas prices based on base fee and priority fees
|
||||
- Bundle transactions for atomic execution
|
||||
- Handle failed transactions gracefully
|
||||
- Implement retry logic with exponential backoff
|
||||
26
orig/@prompts/market-scanning.md
Normal file
26
orig/@prompts/market-scanning.md
Normal file
@@ -0,0 +1,26 @@
|
||||
You are an expert in MEV (Maximal Extractable Value) and DeFi arbitrage strategies. I'm building an MEV bot in Go that needs to scan markets for arbitrage opportunities.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Implementing efficient market scanning algorithms
|
||||
2. Calculating price impact of large swaps
|
||||
3. Detecting triangular arbitrage opportunities
|
||||
4. Estimating gas costs for arbitrage transactions
|
||||
5. Determining profitability after gas costs
|
||||
6. Implementing risk management strategies
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Implements efficient data structures for market data
|
||||
- Calculates arbitrage opportunities across multiple pools
|
||||
- Estimates gas costs accurately
|
||||
- Handles edge cases properly
|
||||
- Follows Go best practices
|
||||
- Is optimized for performance
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Work with Uniswap V3 pool data
|
||||
- Calculate price impact using liquidity and swap amounts
|
||||
- Identify profitable arbitrage paths
|
||||
- Estimate transaction costs
|
||||
- Filter opportunities based on minimum profit thresholds
|
||||
26
orig/@prompts/performance-optimization.md
Normal file
26
orig/@prompts/performance-optimization.md
Normal file
@@ -0,0 +1,26 @@
|
||||
You are an expert in Go performance optimization and high-frequency trading systems. I'm building an MEV bot in Go that needs to process thousands of transactions per second with minimal latency.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Optimizing data structures for high-frequency access
|
||||
2. Minimizing memory allocations and garbage collection
|
||||
3. Implementing efficient caching strategies
|
||||
4. Optimizing network I/O for RPC calls
|
||||
5. Parallel processing of transactions
|
||||
6. Profiling and benchmarking techniques
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Implements lock-free or low-lock data structures where appropriate
|
||||
- Minimizes memory allocations through object pooling
|
||||
- Uses efficient algorithms for data processing
|
||||
- Implements caching for frequently accessed data
|
||||
- Handles concurrency properly
|
||||
- Follows Go best practices
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Process transactions with minimal latency
|
||||
- Scale efficiently across multiple CPU cores
|
||||
- Handle backpressure gracefully
|
||||
- Provide metrics for performance monitoring
|
||||
- Include benchmarks for critical functions
|
||||
26
orig/@prompts/rate-limiting.md
Normal file
26
orig/@prompts/rate-limiting.md
Normal file
@@ -0,0 +1,26 @@
|
||||
You are an expert in rate limiting and resource management for distributed systems. I'm building an MEV bot that needs to efficiently manage requests to multiple RPC endpoints with different rate limits.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Implementing adaptive rate limiting that adjusts to endpoint capacity
|
||||
2. Creating a rate limiter manager for multiple endpoints
|
||||
3. Handling rate limit errors gracefully with fallback strategies
|
||||
4. Implementing retry mechanisms with exponential backoff
|
||||
5. Monitoring and adjusting rate limits based on observed performance
|
||||
6. Balancing load across multiple endpoints
|
||||
7. Handling different rate limit types (RPS, concurrent requests, etc.)
|
||||
8. Implementing circuit breakers for failed endpoints
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Implements efficient rate limiting for multiple endpoints
|
||||
- Handles errors gracefully
|
||||
- Follows Go best practices
|
||||
- Includes comprehensive comments explaining the rate limiting strategies
|
||||
- Provides metrics for monitoring rate limit usage
|
||||
|
||||
The code should:
|
||||
- Respect rate limits for all endpoints
|
||||
- Automatically adjust to endpoint capacity
|
||||
- Handle rate limit errors gracefully
|
||||
- Provide clear metrics for monitoring
|
||||
- Include benchmarks for critical functions
|
||||
24
orig/@prompts/security.md
Normal file
24
orig/@prompts/security.md
Normal file
@@ -0,0 +1,24 @@
|
||||
You are an expert in blockchain security and MEV bot development. I'm building an MEV bot in Go that needs to be secure against various attack vectors.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Protecting private keys and signing credentials
|
||||
2. Preventing frontrunning by other bots
|
||||
3. Securing RPC endpoint connections
|
||||
4. Handling MEV submission securely
|
||||
5. Preventing sandwich attacks
|
||||
6. Implementing secure configuration management
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Implements secure key management practices
|
||||
- Protects against common MEV bot vulnerabilities
|
||||
- Handles sensitive data securely
|
||||
- Follows security best practices
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Store private keys securely using hardware wallets or secure enclaves
|
||||
- Use encrypted connections for RPC endpoints
|
||||
- Implement proper access controls
|
||||
- Handle errors without exposing sensitive information
|
||||
- Include security checks and validations
|
||||
25
orig/@prompts/smart-contract-interaction.md
Normal file
25
orig/@prompts/smart-contract-interaction.md
Normal file
@@ -0,0 +1,25 @@
|
||||
You are an expert in Ethereum smart contract interaction and Web3 development. I'm building an MEV bot in Go that needs to interact with Uniswap V3 smart contracts.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Interacting with Uniswap V3 factory contract to get pool addresses
|
||||
2. Querying pool contracts for liquidity and price information
|
||||
3. Simulating swap transactions to estimate outputs
|
||||
4. Building and signing transactions for submission
|
||||
5. Working with contract ABIs and function selectors
|
||||
6. Handling contract events and logs
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Uses the go-ethereum library for contract interaction
|
||||
- Implements efficient contract querying
|
||||
- Handles errors gracefully
|
||||
- Follows Go best practices
|
||||
- Is optimized for performance
|
||||
- Includes comprehensive comments
|
||||
|
||||
The code should:
|
||||
- Connect to Ethereum contracts using ABI bindings
|
||||
- Query pool state efficiently
|
||||
- Simulate transactions before execution
|
||||
- Handle contract events and logs
|
||||
- Work with both RPC and WebSocket connections
|
||||
26
orig/@prompts/testing-simulation.md
Normal file
26
orig/@prompts/testing-simulation.md
Normal file
@@ -0,0 +1,26 @@
|
||||
You are an expert in Go testing and blockchain simulation. I'm building an MEV bot in Go that needs comprehensive testing to ensure reliability and profitability.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Creating realistic test scenarios for MEV detection
|
||||
2. Simulating Arbitrum network conditions
|
||||
3. Testing pricing calculations with real-world data
|
||||
4. Implementing integration tests with mock contracts
|
||||
5. Creating benchmarks for performance testing
|
||||
6. Implementing property-based testing for mathematical functions
|
||||
|
||||
Please provide production-ready Go test code that:
|
||||
- Uses the standard testing package and testify for assertions
|
||||
- Implements realistic test scenarios
|
||||
- Creates mock data for testing
|
||||
- Includes benchmarks for performance-critical functions
|
||||
- Follows Go testing best practices
|
||||
- Provides comprehensive coverage
|
||||
|
||||
The test code should:
|
||||
- Test edge cases and boundary conditions
|
||||
- Validate mathematical accuracy of pricing functions
|
||||
- Simulate network errors and timeouts
|
||||
- Test various swap scenarios and arbitrage opportunities
|
||||
- Benchmark performance of critical algorithms
|
||||
- Provide meaningful test output
|
||||
27
orig/@prompts/testing.md
Normal file
27
orig/@prompts/testing.md
Normal file
@@ -0,0 +1,27 @@
|
||||
You are an expert in Go testing and test-driven development. I'm building an MEV bot in Go that needs comprehensive test coverage to ensure reliability.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Creating unit tests for Uniswap V3 pricing calculations
|
||||
2. Implementing integration tests for Arbitrum monitoring
|
||||
3. Creating mock contracts and transactions for testing
|
||||
4. Testing market scanning algorithms with real-world data
|
||||
5. Implementing property-based testing for mathematical functions
|
||||
6. Creating benchmarks for performance-critical code
|
||||
|
||||
Please provide production-ready Go test code that:
|
||||
- Uses the standard testing package and testify for assertions
|
||||
- Implements table-driven tests for pricing functions
|
||||
- Creates realistic mock data for testing
|
||||
- Includes benchmarks for performance-critical functions
|
||||
- Follows Go testing best practices
|
||||
- Provides comprehensive coverage
|
||||
- Includes comprehensive comments
|
||||
|
||||
The test code should:
|
||||
- Test edge cases and boundary conditions
|
||||
- Validate mathematical accuracy of pricing functions
|
||||
- Simulate network errors and timeouts
|
||||
- Test various swap scenarios
|
||||
- Benchmark performance of critical algorithms
|
||||
- Provide meaningful test output
|
||||
27
orig/@prompts/transaction-decoding.md
Normal file
27
orig/@prompts/transaction-decoding.md
Normal file
@@ -0,0 +1,27 @@
|
||||
You are an expert in Ethereum transaction processing and MEV optimization. I'm building an MEV bot that needs to efficiently decode and analyze Uniswap V3 swap transactions.
|
||||
|
||||
I need help with:
|
||||
|
||||
1. Decoding transaction calldata for Uniswap V3 swap functions
|
||||
2. Extracting token addresses and amounts from swap transactions
|
||||
3. Identifying the pool contract and fee tier from transaction data
|
||||
4. Calculating price impact of swaps using Uniswap V3 mathematics
|
||||
5. Detecting multi-hop swaps and complex routing patterns
|
||||
6. Efficiently processing large volumes of transactions
|
||||
7. Handling different versions of Uniswap contracts
|
||||
8. Working with Ethereum event logs for additional data
|
||||
|
||||
Please provide production-ready Go code that:
|
||||
- Uses the go-ethereum library for transaction processing
|
||||
- Implements efficient decoding of transaction data
|
||||
- Handles errors gracefully
|
||||
- Follows Go best practices
|
||||
- Includes comprehensive comments explaining the decoding process
|
||||
- Provides metrics for monitoring performance
|
||||
|
||||
The code should:
|
||||
- Accurately decode Uniswap V3 swap transactions
|
||||
- Extract all relevant data for MEV analysis
|
||||
- Handle various edge cases and error conditions
|
||||
- Process transactions with minimal latency
|
||||
- Include benchmarks for critical functions
|
||||
23
orig/@prompts/uniswap-pricing.md
Normal file
23
orig/@prompts/uniswap-pricing.md
Normal file
@@ -0,0 +1,23 @@
|
||||
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.
|
||||
Reference in New Issue
Block a user