algodex / algodex-react

Frontend for Algodex
https://app.algodex.com/about
GNU Affero General Public License v3.0
7 stars 3 forks source link

✨ Feature: Invert all prices for stablecoin pairs #588

Open atrefonas opened 2 years ago

atrefonas commented 2 years ago

ℹ 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
  ...
}
create-issue-branch[bot] commented 2 years ago

Branch issue-588-✨_Feature_Invert_all_prices_for_stablecoin_pairs created!

mrarslanark commented 2 years ago

Kindly, provide more clarification about the issue.

atrefonas commented 2 years ago

The UI needs to be heavily refactored and inverted for some trading pairs so you are selling/buying ALGO instead of USDC.

atrefonas commented 2 years ago

So all the bids need to be displayed as asks and vice versa with inverted prices... just make it so you are buying or selling algo for the USDC/algo trading pair.

atrefonas commented 2 years ago

Please ask @PhearZero if you need help since I'm not available right now

atrefonas commented 2 years ago

Also for these certain trading pairs when you enter a buy order it should actually pass a sell order to the algodex sdk and vice versa.

UI needs to basically invert everything.

alchemist-bounty commented 2 years ago

@atrefonas Should I update this OHLC and chart value as well? image

atrefonas commented 2 years ago

@atrefonas Should I update this OHLC and chart value as well? image

Yes

alchemist-bounty commented 2 years ago

${API_HOST}/assets.php ${API_HOST}/assets.php?id=${id} it returns asset object in this format.

{
    "id": 15322902,
    "unix_time": 1656959348,
    "price": 302,
    "priceBefore": 989,
     "price24Change": -69.46410515672396,
     "isTraded": true
},

Can we add new field like isStable ? At this moment I am updating that field in frontend but it would be much better if backend provides that field.

atrefonas commented 2 years ago

No, please just hardcode the list of stable assets into the frontend. We aren’t going to change the backend for this.

On Tue, Jul 5, 2022 at 6:49 AM Giuseppe Iacono @.***> wrote:

${API_HOST}/assets.php ${API_HOST}/assets.php?id=${id} it returns asset object in this format.

{ "id": 15322902, "unix_time": 1656959348, "price": 302, "priceBefore": 989, "price24Change": -69.46410515672396, "isTraded": true },

Can we add new field like isStable ? At this moment I am updating that field in frontend but it would be much better if backend provides that field.

— Reply to this email directly, view it on GitHub https://github.com/algodex/algodex-react/issues/588#issuecomment-1174917467, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARL6JW6IOYMUVKT6GHJ4FKDVSQHNFANCNFSM5ZGSSOYQ . You are receiving this because you were mentioned.Message ID: @.***>

atrefonas commented 2 years ago

I don’t think we need to track this in the serverside and we are moving away from the 1.0 backend anyways. Just hardcode a list of the 5 asset IDs in the frontend.

On Tue, Jul 5, 2022 at 7:20 AM Alexander Trefonas @.***> wrote:

No, please just hardcode the list of stable assets into the frontend. We aren’t going to change the backend for this.

On Tue, Jul 5, 2022 at 6:49 AM Giuseppe Iacono @.***> wrote:

${API_HOST}/assets.php ${API_HOST}/assets.php?id=${id} it returns asset object in this format.

{ "id": 15322902, "unix_time": 1656959348, "price": 302, "priceBefore": 989, "price24Change": -69.46410515672396, "isTraded": true },

Can we add new field like isStable ? At this moment I am updating that field in frontend but it would be much better if backend provides that field.

— Reply to this email directly, view it on GitHub https://github.com/algodex/algodex-react/issues/588#issuecomment-1174917467, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARL6JW6IOYMUVKT6GHJ4FKDVSQHNFANCNFSM5ZGSSOYQ . You are receiving this because you were mentioned.Message ID: @.***>

alchemist-bounty commented 2 years ago

I got it. Thank you

alchemist-bounty commented 2 years ago

image

atrefonas commented 2 years ago

Not sure what you mean. Use your best judgement or ask Ikechi.

On Wed, Jul 6, 2022 at 4:54 AM Giuseppe Iacono @.***> wrote:

[image: image] https://user-images.githubusercontent.com/76131191/177511338-6337e60d-8ecd-428c-b494-8ef27c5d567e.png

— Reply to this email directly, view it on GitHub https://github.com/algodex/algodex-react/issues/588#issuecomment-1175962873, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARL6JWZDFKC5BDJJZ3IYSWLVSVCVRANCNFSM5ZGSSOYQ . You are receiving this because you were mentioned.Message ID: @.***>

alchemist-bounty commented 2 years ago