{"id":21457832,"url":"https://github.com/papismurf/junction-swap","last_synced_at":"2026-04-18T01:03:00.309Z","repository":{"id":262248910,"uuid":"886662756","full_name":"papismurf/junction-swap","owner":"papismurf","description":"Crypto Swap Service","archived":false,"fork":false,"pushed_at":"2024-11-20T16:12:52.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-25T05:35:39.710Z","etag":null,"topics":["cryptocurrency","fastapi","graphql","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/papismurf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-11-11T11:34:48.000Z","updated_at":"2024-11-20T16:12:56.000Z","dependencies_parsed_at":"2024-11-11T12:35:28.921Z","dependency_job_id":"f8a6a095-5201-4eb1-9572-69bb847a2ff2","html_url":"https://github.com/papismurf/junction-swap","commit_stats":null,"previous_names":["papismurf/junction-swap"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/papismurf/junction-swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papismurf%2Fjunction-swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papismurf%2Fjunction-swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papismurf%2Fjunction-swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papismurf%2Fjunction-swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/papismurf","download_url":"https://codeload.github.com/papismurf/junction-swap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papismurf%2Fjunction-swap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31952208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"ssl_error","status_checked_at":"2026-04-18T00:39:20.671Z","response_time":62,"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":["cryptocurrency","fastapi","graphql","python"],"created_at":"2024-11-23T06:07:18.182Z","updated_at":"2026-04-18T01:03:00.285Z","avatar_url":"https://github.com/papismurf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swap Service\n\nA Python-based swap service that finds optimal routes for token swaps using GeckoTerminal data. The service implements a GraphQL API for querying available tokens and finding the best swap routes.\n\n## Features\n\n- 🔄 Real-time pool and token data updates from GeckoTerminal\n- 📊 Optimal route finding using graph-based algorithms\n- ⚡ High-performance async operations\n- 🗄️ Redis-based caching for fast data access\n- 📈 Support for multi-hop swaps\n- 🔍 Advanced price impact calculations\n- 🎯 GraphQL API for easy integration\n\n## Prerequisites\n\n- Python 3.8+\n- Redis\n- Docker (optional, for Redis)\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone \u003crepo-url\u003e\ncd junction_swap\n```\n\n2. Create and activate a virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: .\\venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n4. Start Redis:\n```bash\n# Using Docker\ndocker run -d -p 6379:6379 redis\n\n# Or use your existing Redis instance\n```\n\n5. Create a `.env` file:\n```env\nGECKOTERMINAL_API_URL=https://api.geckoterminal.com/api/v2\nREDIS_URL=redis://localhost:6379\nCHAIN_ID=bsc\nUPDATE_INTERVAL=300\n```\n\n## Running the Application\n\nStart the application using uvicorn:\n```bash\nuvicorn main:app --reload\n```\n\nThe API will be available at `http://localhost:8000`.\n\n## API Usage\n\n### GraphQL Endpoint\n\nThe GraphQL endpoint is available at `http://localhost:8000/graphql`.\n\n### Available Queries\n\n1. Get all available tokens:\n```graphql\nquery {\n  availableTokens {\n    address\n    symbol\n    name\n    priceUsd\n  }\n}\n```\n\n2. Get top tokens by market cap:\n```graphql\nquery {\n  topTokens(limit: 50) {\n    address\n    symbol\n    name\n    priceUsd\n  }\n}\n```\n\n3. Find best swap route:\n```graphql\nquery {\n  bestSwapRoute(\n    tokenIn: \"0x...\",\n    tokenOut: \"0x...\",\n    amountIn: 1.0\n  ) {\n    path\n    pools\n    estimatedOutput\n  }\n}\n```\n\n## Project Structure\n\n```\nswap_service/\n├── requirements.txt\n├── main.py\n├── app/\n│   ├── __init__.py\n│   ├── schema.py        # GraphQL schema definitions\n│   ├── models.py        # Pydantic models\n│   ├── services/\n│   │   ├── __init__.py\n│   │   ├── asset_loader.py    # GeckoTerminal data fetching\n│   │   ├── graph_solver.py    # Route finding logic\n│   │   └── token_store.py     # Redis storage operations\n│   └── config.py       # Configuration settings\n```\n\n## Key Components\n\n1. **Asset Loader**\n   - Fetches pool and token data from GeckoTerminal\n   - Updates data periodically\n   - Handles rate limiting and error recovery\n\n2. **Graph Solver**\n   - Finds optimal swap routes\n   - Implements constant product formula\n   - Handles multi-hop routes\n   - Calculates price impact\n\n3. **Token Store**\n   - Redis-based storage\n   - Caches token and pool data\n   - Provides fast data access\n\n## Configuration Options\n\nEdit `.env` file to configure:\n\n- `GECKOTERMINAL_API_URL`: GeckoTerminal API endpoint\n- `REDIS_URL`: Redis connection URL\n- `CHAIN_ID`: Blockchain network identifier (e.g., 'bsc', 'ethereum')\n- `UPDATE_INTERVAL`: Data update interval in seconds\n\n## Development\n\n### Running Tests\n```bash\npytest\n```\n\n### Code Formatting\n```bash\nruff format\n```\n\n## Performance Considerations\n\n- Uses async operations for concurrent processing\n- Implements efficient caching with Redis\n- Optimizes graph operations for route finding\n- Handles background updates efficiently\n\n## Error Handling\n\nThe application includes comprehensive error handling:\n- API request failures\n- Data parsing errors\n- Graph calculation errors\n- Background task management\n\n## Monitoring\n\nMonitor the application using logs:\n- Background task status\n- Data update cycles\n- Route calculation performance\n- Error rates\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapismurf%2Fjunction-swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpapismurf%2Fjunction-swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapismurf%2Fjunction-swap/lists"}