{"id":17859863,"url":"https://github.com/takshakmudgal/optibridge","last_synced_at":"2026-04-07T21:31:55.211Z","repository":{"id":259771915,"uuid":"879392472","full_name":"takshakmudgal/optibridge","owner":"takshakmudgal","description":"API that returns the most efficient fund sourcing route/s.","archived":false,"fork":false,"pushed_at":"2024-10-29T16:27:29.000Z","size":35,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T23:19:17.733Z","etag":null,"topics":["axios","bunjs","docker","docker-compose","elysiajs","ethersjs","redis","redis-cache","typesc","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/takshakmudgal.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-10-27T19:26:42.000Z","updated_at":"2025-06-24T01:36:32.000Z","dependencies_parsed_at":"2024-10-27T23:54:57.684Z","dependency_job_id":"5f3327a7-f486-40bd-8619-028249c5fe57","html_url":"https://github.com/takshakmudgal/optibridge","commit_stats":null,"previous_names":["takshakmudgal/optibridge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/takshakmudgal/optibridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takshakmudgal%2Foptibridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takshakmudgal%2Foptibridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takshakmudgal%2Foptibridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takshakmudgal%2Foptibridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takshakmudgal","download_url":"https://codeload.github.com/takshakmudgal/optibridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takshakmudgal%2Foptibridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31530641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["axios","bunjs","docker","docker-compose","elysiajs","ethersjs","redis","redis-cache","typesc","zod"],"created_at":"2024-10-28T07:03:42.237Z","updated_at":"2026-04-07T21:31:55.181Z","avatar_url":"https://github.com/takshakmudgal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# optibridge\n\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![TypeScript](https://img.shields.io/badge/typescript-4.5.4-blue.svg)\n![Redis](https://img.shields.io/badge/redis-6.2.5-blue.svg)\n![Bun](https://img.shields.io/badge/bun-v0.1.13-blue.svg)\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Technology Stack](#technology-stack)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Configuration](#configuration)\n- [Usage](#usage)\n  - [Running the Application](#running-the-application)\n  - [API Endpoints](#api-endpoints)\n- [Project Structure](#project-structure)\n- [Contributing](#contributing)\n- [License](#license)\n- [Running with Docker](#running-with-docker)\n\n## Introduction\n\nWelcome to the **optibridge** project! This backend service is designed to facilitate optimal cross-chain token bridging by calculating the most efficient routes based on user requests. Leveraging multiple blockchain networks, the service ensures minimal fees and optimal transaction times, providing a seamless bridging experience for users.\n\n## Features\n\n- **Optimal Route Calculation:** Determines the best possible paths for token bridging across supported blockchain networks.\n- **Dynamic Fee Management:** Integrates with external APIs to fetch real-time bridge fees and applies fallback mechanisms when necessary.\n- **Caching with Redis:** Implements caching strategies to enhance performance and reduce redundant API calls.\n- **Robust Error Handling:** Comprehensive error management to handle various failure scenarios gracefully.\n- **Test Mode:** Allows simulation of different blockchain balances for testing purposes without interacting with actual networks.\n- **Scalable Architecture:** Built with scalability in mind, accommodating the addition of more blockchain networks with ease.\n\n## Technology Stack\n\n- **Language:** [TypeScript](https://www.typescriptlang.org/)\n- **Runtime:** [Bun](https://bun.sh/)\n- **Framework:** [Elysia](https://github.com/elysiaJS/elysia)\n- **Caching:** [Redis](https://redis.io/)\n- **Blockchain Interaction:** [Ethers.js](https://docs.ethers.io/v5/)\n- **Validation:** [Zod](https://github.com/colinhacks/zod)\n- **HTTP Client:** [Axios](https://axios-http.com/)\n\n## Getting Started\n\n### Prerequisites\n\nEnsure you have the following installed on your system:\n\n- [Bun](https://bun.sh/) (v0.1.13)\n- [Redis](https://redis.io/) (v6.2.5)\n\n### Installation\n\n1. **Clone the Repository**\n\n   ```bash\n   git clone https://github.com/takshakmudgal/optibridge.git\n   cd optibridge\n   ```\n\n2. **Install Dependencies**\n\n   Using Bun:\n\n   ```bash\n   bun install\n   ```\n\n### Configuration\n\n1. **Environment Variables**\n\n   Create a `.env` file in the root directory and populate it with the required environment variables:\n\n   ```env\n   SOCKET_API_KEY=your_socket_api_key\n   REDIS_URL=redis://localhost:6379\n   PORT=3000\n   ```\n\n   - `SOCKET_API_KEY`: Your API key for the Socket API service.\n   - `REDIS_URL`: Connection URL for your Redis instance.\n   - `PORT`: Port on which the application will run (default is 3000).\n\n2. **Supported Chains Configuration**\n\n   The application supports multiple blockchain networks. You can configure supported chains in the `src/config/chains.ts` file. Each chain configuration includes:\n\n   - `name`: Human-readable name of the chain.\n   - `chainId`: Unique identifier for the blockchain.\n   - `nativeToken`: The native cryptocurrency of the chain.\n   - `usdcAddress`: Contract address for USDC on the chain.\n   - `rpcUrl`: RPC endpoint for interacting with the blockchain.\n\n3. **Bridge Fees Configuration**\n\n   Bridge fees between chains are defined in `src/config/bridgeFees.ts`. You can adjust the fees as needed:\n\n   ```typescript\n   export const BRIDGE_FEES: Record\u003cstring, Record\u003cstring, number\u003e\u003e = {\n     arbitrum: {\n       polygon: 1,\n     },\n     base: {\n       polygon: 0.5,\n     },\n     gnosis: {\n       polygon: 0.1,\n     },\n     blast: {\n       polygon: 0.2,\n     },\n   };\n   ```\n\n## Usage\n\n### Running the Application\n\nStart the development server using Bun:\n\n```bash\nbun run dev\n```\n\nThe server will start on the specified port (default: 3000). You should see a console message indicating that Elysia is running:\n\n```\n🦊 Elysia is running at localhost:3000\n```\n\n### API Endpoints\n\n#### `POST /api/bridge/routes`\n\nCalculates the optimal bridging routes based on the user's request.\n\n- **Request Body**\n\n  ```json\n  {\n    \"targetChain\": \"string\",      // The blockchain network to bridge to (e.g., \"polygon\")\n    \"amount\": number,             // The amount of tokens to bridge\n    \"tokenAddress\": \"string\",     // The contract address of the token to bridge\n    \"userAddress\": \"string\"       // The user's wallet address initiating the bridge\n  }\n  ```\n\n  - **Validation Rules:**\n    - `targetChain`: Must be a supported chain.\n    - `amount`: Must be a positive number.\n    - `tokenAddress` \u0026 `userAddress`: Must be valid Ethereum addresses (42 characters, starting with `0x`).\n\n- **Response**\n\n  - **Success**\n\n    ```json\n    {\n      \"success\": true,\n      \"data\": {\n        \"routes\": [\n          {\n            \"sourceChain\": \"string\",\n            \"amount\": number,\n            \"fee\": number,\n            \"estimatedTime\": number,\n            \"protocol\": \"string\",\n            \"gasToken\": \"string\",\n            \"sourceBalance\": number\n          }\n        ],\n        \"totalFee\": number,\n        \"totalAmount\": number,\n        \"estimatedTotalTime\": number,\n        \"availableBalance\": number,\n        \"requiredAmount\": number,\n        \"insufficientFunds\": false,\n        \"noValidRoutes\": false,\n        \"bridgeRoutes\": [\n          {\n            \"sourceChain\": \"string\",\n            \"amount\": number,\n            \"fee\": number,\n            \"estimatedTime\": number,\n            \"protocol\": \"string\",\n            \"gasToken\": \"string\"\n          }\n        ],\n        \"targetChain\": \"string\",\n        \"shortfall\": number\n      },\n      \"error\": null\n    }\n    ```\n\n  - **Failure**\n\n    ```json\n    {\n      \"success\": false,\n      \"error\": \"Error message detailing the issue\",\n      \"data\": {\n        \"routes\": [],\n        \"totalFee\": 0,\n        \"totalAmount\": 0,\n        \"estimatedTotalTime\": 0,\n        \"availableBalance\": 0,\n        \"requiredAmount\": number,\n        \"insufficientFunds\": true,\n        \"noValidRoutes\": true,\n        \"bridgeRoutes\": [],\n        \"targetChain\": \"string\",\n        \"shortfall\": number\n      }\n    }\n    ```\n\n- **Example Request**\n\n  ```bash\n  curl -X POST http://localhost:3000/api/bridge/routes \\\n    -H \"Content-Type: application/json\" \\\n    -d '{\n          \"targetChain\": \"arbitrum\",\n          \"amount\": 100,\n          \"tokenAddress\": \"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8\",\n          \"userAddress\": \"0xYourEthereumAddressHere\"\n        }'\n  ```\n\n## Project Structure\n\n```\noptibridge/\n├── src/\n│   ├── config/\n│   │   ├── bridgeFees.ts\n│   │   ├── chains.ts\n│   │   ├── env.ts\n│   │   └── redis.ts\n│   ├── controllers/\n│   │   └── bridgeController.ts\n│   ├── services/\n│   │   ├── routeCalculator.ts\n│   │   └── socketApi.ts\n│   ├── types/\n│   │   ├── index.ts\n│   │   └── socket.ts\n│   ├── utils/\n│   │   ├── errors.ts\n│   │   └── validation.ts\n│   └── server.ts\n├── .gitignore\n├── package.json\n├── tsconfig.json\n└── README.md\n```\n\n- **src/config/**: Contains configuration files for environment variables, Redis, supported chains, and bridge fees.\n- **src/controllers/**: Handles incoming API requests and orchestrates responses.\n- **src/services/**: Contains business logic for route calculation and external API interactions.\n- **src/types/**: Defines TypeScript interfaces and types used throughout the application.\n- **src/utils/**: Utility functions and custom error classes.\n- **src/server.ts**: Entry point of the application, sets up the Elysia server and routes.\n\n## Contributing\n\nContributions are welcome! Please follow these steps to contribute:\n\n1. **Fork the Repository**\n\n2. **Create a Feature Branch**\n\n   ```bash\n   git checkout -b feature/YourFeatureName\n   ```\n\n3. **Commit Your Changes**\n\n   ```bash\n   git commit -m \"Add your message here\"\n   ```\n\n4. **Push to the Branch**\n\n   ```bash\n   git push origin feature/YourFeatureName\n   ```\n\n5. **Open a Pull Request**\n\nPlease ensure your code adheres to the project's coding standards and passes all existing tests.\n\n## Running with Docker\n\nTo run **optibridge** using Docker, follow these steps:\n\n### Prerequisites\n\n- [Docker](https://www.docker.com/get-started) installed on your system.\n- [Docker Compose](https://docs.docker.com/compose/install/) installed.\n\n### Steps\n\n1. **Clone the Repository**\n\n   ```bash\n   git clone https://github.com/takshakmudgal/optibridge.git\n   cd optibridge\n   ```\n\n2. **Create a `.env` File**\n\n   Create a `.env` file in the root directory and add your environment variables:\n\n   ```env\n   SOCKET_API_KEY=your_socket_api_key\n   PORT=3000\n   ```\n\n3. **Build and Run with Docker Compose**\n\n   ```bash\n   docker-compose up --build\n   ```\n\n   This command will build the Docker image and start both the application and Redis services. The application will be accessible at [http://localhost:3000](http://localhost:3000).\n\n4. **Stopping the Services**\n\n   To stop the services, press `Ctrl + C` in the terminal where Docker Compose is running, then execute:\n\n   ```bash\n   docker-compose down\n   ```\n\n### Notes\n\n- The application code is mounted into the Docker container, allowing for live-reloading during development.\n- Redis data is persisted using Docker volumes to prevent data loss between restarts.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakshakmudgal%2Foptibridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakshakmudgal%2Foptibridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakshakmudgal%2Foptibridge/lists"}