Skip to content

✨ Feature: Invert all prices for stablecoin pairs #588

@atrefonas

Description

@atrefonas

ℹ Overview

The prices should all be inverted when trading for stablecoins like USDC. The buy orders should also appear as sell orders as vice versa. It should also be "BUY ALGO" and "SELL ALGO" in the trade window.

🧮 Calculation

New Order

// New order with USDC Price
let price = 0.65 // USDC
let amount = 10 // ALGO
let total = price * amount // USDC

// Convert to Algodex Algo based Order
let algoPrice = amount / total

// Algodex ALGO Order
let order = {
  price: algoPrice,    // 1.538461538 ALGO
  amount: total,       // 6.5 USDC
  total: amount,       // ~10 ALGO
  ...
}

Orderbook / Existing Order

// All existing Orders use Algo Pricing
let price = 1.538461538 // ALGO
let amount = 6.5 // USDC
let total = price * amount // ALGO

// Convert it to the Asset Price for Display Purposes.
// It must be converted back using the New Order calculation
let converted = {
  "price": amount / total,  // 0.65 USDC
  "amount": total,          // 10 ALGO
  "total": amount,          // 6.5  USDC
  ...
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions