Skip to content

devmenon23/StablePay-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StablePay

An app that helps people in hyperinflation economies manage stablecoin assets by finding the cheapest conversion rates from local currency and providing financial intelligence on wealth management.

Installation

  1. Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
  1. Install dependencies:
poetry install
  1. Set up environment variables (copy .env.example to .env and fill in your values):
cp .env.example .env

Edit .env with your API keys:

BITSO_API_KEY=your_api_key
BITSO_API_SECRET=your_api_secret
BITSO_BASE_URL=https://stage.bitso.com

Running the Application

Option 1: Using Poetry Shell (Recommended)

Activate the Poetry shell:

poetry shell

Then run:

python run.py

Or with uvicorn directly:

uvicorn app.main:app --reload

Option 2: Using Poetry Run

poetry run python run.py

Or:

poetry run uvicorn app.main:app --reload

The API will be available at http://localhost:8000

Code Formatting

Format code with black and isort:

poetry run black app/ run.py
poetry run isort app/ run.py

API Endpoints

POST /convert

Convert currency using exchange rates.

Request:

{
    "from_ccy": "USD",
    "to_ccy": "BTC",
    "amount": 1000.0
}

Response:

{
    "converted_amount": 0.0234
}

POST /cost

Get the cost (fee) for converting from one currency to another.

Request:

{
    "from_currency": "USDC",
    "to_currency": "ARS",
    "amount": 1000.0
}

Response:

{
    "cost": 6.5,
    "exchange": "bitso"
}

POST /dijkstra

Run Dijkstra's algorithm to find shortest path costs from a starting currency.

Request:

{
    "start_currency": "USDC",
    "amount": 1000.0
}

Response:

{
  "costs": {
    "USDC": 0.0,
    "ARS": 0.0065,
    "MXN": 0.0065,
    ...
  },
  "previous": {
    "USDC": null,
    "ARS": "USDC",
    ...
  }
}

About

A stablecoin conversion optimizer built for users in volatile economies. StablePay computes the cheapest multi-hop conversion route between fiat, stablecoins, and cryptocurrencies using a graph-based optimizer with log-space Dijkstra traversal to minimize slippage and hidden fees.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages