soroswap / backend

Soroswap Backend: Provides Endpoints for info and to calculate optimal routing.
https://backend.soroswap.finance
0 stars 2 forks source link

Backend: Create Mercury client service #1

Closed joaquinsoza closed 8 months ago

joaquinsoza commented 9 months ago

Mercury Client Backend

We need a backend that uses the mercury sdk to index data a get the optimal routes for swaps

Describe the solution you'd like I would like to use NestJS but if you have a better idea or just want to use Express is ok, must be in typescript maybe serverless functions are better for this but we could dockerize and use Google Cloud Run or just upload it to vercel, its also possible. Again NestJS might be convenient.

Setup a basic backend using the solution you choose with a few endpoints

/optimal_route response example

{
   "token_in": "string",
   "token_out": "string",
   "path": [
      "token_a_address", 
      "token_b_address", 
      "token_c_address", 
      "token_d_address", 
      "token_f_address"
   ]
}
abstract829 commented 8 months ago

Created backend with dummy endpoints,

network is received as query param in the url, ?network=futurenet default is testnet

you can run the server with npm run start:dev

and see the docs / test the endpoints in http://localhost:4000/docs/

abstract829 commented 8 months ago

added api key authentication to the endpoints

you need to send "apiKey" in the headers with the API_KEY set in the .env file for the endpoints to be working or you will receive "Unauthorized"

also added prisma with postgres for the db in the future

envs

API_KEY=cualquiercosa
DATABASE_URL=postgresql://postgres:b-C*fgdaDeae15c*b5E3*5--fc134Ede@viaduct.proxy.rlwy.net:29019/railway