A Google Cloud Function that provides quote functionality for token swaps.
This service exposes an HTTP endpoint that allows users to get the best route for swapping tokens on a decentralized exchange.
- Node.js 22
- Google Cloud SDK
- TypeScript
- Clone the repository
- Install dependencies:
npm install
LOG_LEVEL
: Controls the logging verbosity (default: "debug")
Calculate the optimal route for swapping between two tokens.
GET /getQuote
Parameter | Type | Description |
---|---|---|
tokenIn | string | Source token address |
tokenOut | string | Destination token address |
amount | string | Amount of tokenIn to swap |
{
route: string[]; // Array of token addresses in the swap route
estimatedOutput: string; // Estimated output amount
price: string; // Price impact of the swap
}
400 Bad Request
: Missing required parameters405 Method Not Allowed
: Invalid HTTP method500 Internal Server Error
: Server-side error
The service uses Winston for structured logging with JSON format. All logs include timestamps and are output to the console.
├── index.ts # Main function handler
└── utils
└── logger.ts # Logging configuration
npm run dev
just test
# lints ts, md files
just lint
# formats ts, md files
npm run format