{"id":40206885,"url":"https://github.com/zacksff/uniswap-estimator","last_synced_at":"2026-01-19T21:01:43.912Z","repository":{"id":309374677,"uuid":"1035959981","full_name":"zacksfF/uniswap-estimator","owner":"zacksfF","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-11T13:34:11.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T15:22:22.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zacksfF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-11T10:57:22.000Z","updated_at":"2025-08-11T13:34:15.000Z","dependencies_parsed_at":"2025-08-11T15:32:52.219Z","dependency_job_id":null,"html_url":"https://github.com/zacksfF/uniswap-estimator","commit_stats":null,"previous_names":["zacksff/uniswap-estimator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zacksfF/uniswap-estimator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksfF%2Funiswap-estimator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksfF%2Funiswap-estimator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksfF%2Funiswap-estimator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksfF%2Funiswap-estimator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zacksfF","download_url":"https://codeload.github.com/zacksfF/uniswap-estimator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksfF%2Funiswap-estimator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28585199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T20:45:59.482Z","status":"ssl_error","status_checked_at":"2026-01-19T20:45:41.500Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-19T21:01:27.035Z","updated_at":"2026-01-19T21:01:43.906Z","avatar_url":"https://github.com/zacksfF.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦄 Uniswap V2 Estimator API\n\n\u003e fast REST API for estimating Uniswap V2 token swaps with real-time blockchain data integration.\n\n[![Go](https://img.shields.io/badge/Go-1.24.5-00ADD8?style=flat\u0026logo=go)](https://golang.org/)\n[![Fiber](https://img.shields.io/badge/Fiber-v2-00ADD8?style=flat)](https://gofiber.io/)\n[![Ethereum](https://img.shields.io/badge/Ethereum-Compatible-627EEA?style=flat\u0026logo=ethereum)](https://ethereum.org/)\n\n## Features\n\n- Single `/estimate` endpoint for swap calculations\n- Real-time blockchain state fetching from Ethereum mainnet\n- Custom Uniswap V2 math implementation with 0.3% fee calculation\n- Performance-optimized with minimal memory allocations\n- Built with Go and Fiber framework\n- Comprehensive input validation and error handling\n\n## Quick Start\n\n1. **Clone and setup**\n   ```bash\n   git clone https://github.com/zacksfF/uniswap-estimator.git\n   cd uniswap-estimator\n   cp .env.example .env\n   ```\n\n2. **Install dependencies and run**\n   ```bash\n   make run\n   ```\n\n## Configure Environment\n\nEdit `.env` file with your Ethereum RPC endpoint:\n\n```env\nETHEREUM_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your_key\nHOST=localhost\nPORT=1337\nENV=development\nREQUEST_TIMEOUT=10\nMAX_CONNECTIONS=100\n```\n\nGet RPC URL from:\n- [Alchemy](https://alchemy.com)\n\n## Commands / Development\n\n```bash\nmake run        # Start development server\nmake build      # Build production binary\nmake test       # Run test suite\nmake benchmark  # Run performance benchmarks\nmake clean      # Clean build artifacts\nmake help       # Show all commands\n```\n\n**Performance benchmarks:**\n```\nBenchmarkCalculateAmountOut-8    7968488    135.0 ns/op    248 B/op    6 allocs/op\n```\n\n## Test the API\n\n**Health check:**\n```bash\ncurl http://localhost:1337/health\n```\n\n**Estimate endpoint:**\n```bash\ncurl \"http://localhost:1337/estimate?pool=0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852\u0026src=0xdAC17F958D2ee523a2206206994597C13D831ec7\u0026dst=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\u0026src_amount=10000000\"\n```\n\n**Expected response:**\n```json\n{\n  \"dst_amount\": \"238316708782106591\"\n}\n```\n\n**API parameters:**\n- `pool` - Uniswap V2 pair contract address (42 chars)\n- `src` - Source token address (42 chars)\n- `dst` - Destination token address (42 chars)\n- `src_amount` - Input amount as integer string\n\n## Project Architecture\n\n```\n├── cmd/main.go                 # Application entry point\n├── internal/\n│   ├── config/                 # Environment configuration\n│   ├── handlers/               # HTTP request handlers\n│   ├── services/               # Business logic layer\n│   ├── models/                 # Data structures and errors\n│   └── utils/                  # Math and validation utilities\n├── test/                       # Tests and benchmarks\n├── .env                        # Environment variables\n└── Makefile                    # Build automation\n```\n\n**Architecture principles:**\n- Clean separation between blockchain interaction and mathematical calculation\n- Fiber framework for high-performance HTTP handling\n- Comprehensive error handling and input validation\n- Production-ready with health monitoring\n\n## Technical Implementation\n\n**Blockchain Integration:**\n- Fetches current pool reserves via Ethereum RPC calls\n- Retrieves token metadata (decimals, symbols) from ERC20 contracts\n- Uses raw contract calls without external Uniswap libraries\n- Real-time data ensures accurate calculations\n\n**Performance Optimization:**\n- 135 nanoseconds per calculation\n- 7.4 million calculations per second throughput\n- 248 bytes allocated per operation\n- Only 6 memory allocations per calculation\n\n## Mathematical Engine\n\n**Uniswap V2 Formula Implementation:**\n- Constant product formula: `x * y = k`\n- Trading fee calculation: `(amountIn * 997 * reserveOut) / (reserveIn * 1000 + amountIn * 997)`\n- 0.3% fee (997/1000 factor) applied to input amount\n- High precision using Go's `math/big` package\n- Optimized for minimal memory allocations\n\n**Token Handling:**\n- Automatic decimal conversion for different token standards\n- Proper token ordering based on Uniswap V2 pair structure\n- Comprehensive amount validation\n\n## Requirements Compliance\n\n- Single `/estimate` endpoint with specified parameters\n- No on-chain function calls for amount calculations\n- No external Uniswap SDK or calculation libraries\n- Real-time blockchain state fetching only\n- Backend mathematical calculations with performance optimization\n- Go implementation with web framework (Fiber)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacksff%2Funiswap-estimator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzacksff%2Funiswap-estimator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacksff%2Funiswap-estimator/lists"}