Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Предзаказ обмена

...

Code Block
{
  "data": {
    "getOffChainSwapQuote": {
      "id": null,
      "fromCurrencyId": null,
      "toCurrencyId": null,
      "direction": null,
      "amount": null,
      "give": null,
      "receive": null,
      "commissionCurrencyId": null,
      "commission": null,
      "createdAt": null,
      "expireAt": null,
      "status": "Amount is more then max",
      "isActive": null,
      "isErrored": true
    }
  }
}

...

Code Block
{
  "data": {
    "getOffChainSwapQuote": {
      "id": null,
      "fromCurrencyId": null,
      "toCurrencyId": null,
      "direction": null,
      "amount": null,
      "give": null,
      "receive": null,
      "commissionCurrencyId": null,
      "commission": null,
      "createdAt": null,
      "expireAt": null,
      "status": "Amount is less then min",
      "isActive": null,
      "isErrored": true
    }
  }
}

...

Code Block
{
  "data": {
    "getOffChainSwapQuote": {
      "id": null,
      "fromCurrencyId": null,
      "toCurrencyId": null,
      "direction": null,
      "amount": null,
      "give": null,
      "receive": null,
      "commissionCurrencyId": null,
      "commission": null,
      "createdAt": null,
      "expireAt": null,
      "status": "Offchain Swap isn't enabled",
      "isActive": null,
      "isErrored": true
    }
  }
}

...

Code Block
{
  "data": {
    "getOffChainSwapQuote": {
      "id": null,
      "fromCurrencyId": null,
      "toCurrencyId": null,
      "direction": null,
      "amount": null,
      "give": null,
      "receive": null,
      "commissionCurrencyIdcreatedAt": null,
      "commissionexpireAt": null,
      "createdAtstatus": null,"Internal       "expireAt": null,
      "status": "Internal Server ErrorServer Error. Try later",
      "isActive": null,
      "isErrored": true
    }
  }
}

...

  1. Отримання рейту - потрібне ДО формування квоти, для розуміння Юзером витраченної комісіі та приблизного рейту після обміну.
    Квота запитується при кожній зміні кількості у формі обміну. Буде один єдиний крок обміну.
    Умови валідацї на підтвердження Обміну:
    - Мінімум та максимум для обміну з налаштувань (нове)
    - Баланс Юзера
    - Баланс брокера (при отриманні квоти). Юзер бачить як неможливість обміну у формі.
    Потребує змін дизайну:
    - Показувати мінімум та максимум для Обміну
    - Прибрати зайві поля. Залишається один рейт, без можливості робити реверс рейту ( погодити )
    - Прибрати поле з комісією
    1.1. При отриманні Квоті(перехід на крок підтвердження Квоти) має враховуватись баланс Брокера
    Це вираховується на стороні Бека. Пункти при яких буде запитуватися квота:
    - зміна кількості на обмін From
    - зміна валют Send/Receive
    - зміна пари методом “Реверс”
    - інтервальне оновлення кожні 10 секунд
    1.2. При невдалому отриманні Квоти - повідомляти причину помилки
    Погодити тексти помилок для Юзера.

    Popup in case of successful swap:
    Your swap was successful

    1.3. Попередня форма, до формування Квоти, має бути “калькулятором” для прозорого розуміння Юзером сплати комісіі, обрахунок, рейт
    Ця можливсть буде присутня в межах баланса брокера і в межах налаштувань мінімума та максимума на Обміну.
    1.4 Користивуч не має бути прив'язаний до Балансу Брокера, на етапі приблизного обрахування його обміну
    Буде прив'язаний

  2. При цій запропонованій побудові - Фронт має отримувати зміну по квоті при кожній зміни кількості на обмін. Фронт не зможе адекватно обробляти це бо:

    Юзер може протягом короткоко часу ввести, змінити, додати Кількість на обмін багато разів - що приводить кожного разу до Нового запиту отримання Квоти, відповідно отримання Квоти може бути успішним/неуспішним та отримання Квоти може зайняти тривалий час .
    Це побуджує велечезну кількість запитів на отримання квоти, що буде означати не зовсім неочікуєму роботу обрахунку у формі на Фронті
    Це питання вирішується на стороні Беку

  3. В нас має бути можливість користуватися офф-чейн свапом з підключеною зовнішньою Платформою та без, в контексті однієї форми для обміну.
    Якщо - ні , то налаштування потрібно розділити : ЮзерАпп з 2ма видами налаштувань обміну або внутрішній/або зовнішній . Поєднати це проблематично та потребує досліджень та роз'яснень, а потім погодження як це має бути для Операторів, які не потребують інтеграціі зовнішних Платформ.
    Це питання потрібно погодити з Менеджментом, враховуючі Операторів які не очікують інтеграцію з зовнішніми платформами

  4. Для Обміну було б раціонально мати РейтСорс у налаштуваннях маркету з показником ЛастПрайс, отриманий з Трейдінгу(або інший рейт-сорс Зовнішньої платформи)
    Додатково: у маркета мало б бути делька рейт-сорсів. Та припиненні роботи одного рейт-сорсу(падііня сервісу) - вмикання наступного. Це запобігає некоректній роботі Свапу на платформі.
    Тільки для внутрішього Обміну це буде потрібно

  5. В якій валюті береться комісія за Обмін на Зовнішній платформі?
    В нас є можливисть налаштування як у базовій так і у валюті квотування - чи не буде це ломати наш Обмін в Операціях?
    Це питання потрібно погодити з Менеджментом
    Чи показувати взагалі комісію Юзеру

  6. Також змінилася структура отримання даних для свопу, колись ми отримували масив маркетів для кожної валюти, зараз ми отримуємо всі маркети в одному масиві
    Вирішено. Зараз отримуємо в контексті Валюти в новому запиті.

  7.  ще таке загальне питання до беків, по отриманню даних, 

    Конкретно до сутності маркетів, до чого вони унаслідувалися від моделі типу «Market»  на базі неї будувався логіна свопу, інста ордер і дт., зараз зʼявилася ще одна нова сутність «BasicMarket»

    Питання: 

    Її ми будемо використовувати тільки для off/on chain swap? 

    Чи ми переходимо тільки на неї?

    Після дзвінку:

    1. Бек робить оновлення сутностей, найменування полів та їх чищення. В ітозі будуть впровадженні нові сутності а старі видалені згодом.

    2. Фронт буде прибирати поля, які не будуть використовуватитись у сутності Market

    3. Фронт додає нову сутність SwapMarket

      Screenshot from 2024-06-11 13-11-08.pngImage Added

____________________________________________________________________

depricated:

...

Code Block
mutation {
  getSwapQuote(
      marketId: String!,
      from: String!,
      to: String!,
      # direction can be 'to' or 'from'                    
      direction: String!,
      amount: String!
  ): SwapQuote
}

Обратите внимание, параметр direction помогает указать в какой валюте указывается amount - во входящей или исходящей.

Пример 1.

Я хочу поменять 100 USDT на ETH запрос будет выглядеть:

Code Block
mutation {
  swapQuote(
    from: "USDT",
    to: "ETH",
    marketId: "ETH-USDT",
    direction: "from",
    amount: "100"
  ) {
    id
    serviceId
    from
    to
    direction
    amount
    give
    receive
    rate
    internalGive
    internalReceive
    expireAt
    status
    isActive
    isErrored
  }
}

Пример 2.

Я хочу поменять USDT и получить в результате 0.001 ETH запрос будет выглядеть:

Code Block
mutation {
  swapQuote(
    from: "USDT",
    to: "ETH",
    marketId: "ETH-USDT",
    direction: "to",
    amount: "0.001"
  ) {
    id
    serviceId
    from
    to
    direction
    amount
    give
    receive
    rate
    internalGive
    internalReceive
    expireAt
    status
    isActive
    isErrored
  }
}

Параметры из ответа:

give - сколько клиент должен будет заплатить без учета комиссии нашей системы (приблизительно, если direction = “to” и точно, если direction = “from”)

receive - сколько клиент получит без учета комиссии нашей системы (приблизительно, если direction = “from” и точно, если direction = “to”)

rate - receive / give

internalGive - сколько клиент заплатит с учетом нашей комиссии (приблизительно если direction = “to” и точно, если direction = “from”)

internalReceive - сколько клиент получит без учета комиссии нашей системы (приблизительно, если direction = “from” и точно, если direction = “to”)

expireAt - время, когда текущая квота утратит свою актуальность.

Обмен

После принятия клиентом решения об обмене (если попадаем в 10секундный интервал) используется следующий:

Code Block
mutation {
  confirmSwapQuote(id: String!): SwapQuote
}

Передаем id квоты, serviceId, marketId

UX

Screenshot from 2024-04-24 18-18-12.pngImage Removed

Off- chain Swap Step 1

As a User, I can see main details of the form:

  • 'Quick Swap' header

  • Send section with main details:

    • 'Drop down' button to select Currency to Send with logo and ID (Ticker)

    • In case there is only one option for Currency to Send: the user can observe just this option with logo and currency ID (without drop-down

    • Currency to Send is selected according Wallet selected (by default for each Wallet) with logo and ID (Ticker)

    • Input field for amount to Swap (Send internally), pre-set "Minimum amount" to Swap by default

    • “Max” button

    • Asset's balance available for operation, in selected currency with currency ID

    'Reverse' button for changing Currency positions between 'Send' and 'Receive'

  • Receive section with main details:

    • 'Drop down' button to select Currency to Receive with logo and ID (Ticker)

    • The field 'Receive' with a calculated amount (Approximate) in Currency to Receive

    • The second Asset's balance (Currency to Receive) is currently available in its Wallet

  • Platform commission portion and ID (commission ID can be in the quote or base currency according to market settings)

  • Platform rate portion for selected Market Pair: Currency to Swap -> Currency to Receive (price precision, according to market settings)

  • Estimated result rate for selected Market Pair: Currency to Swap -> Currency to Receive (price precision, according to market settings)

    'Switch' icons as buttons to switch the Estimated result rate or Platform rate reflection Currency to Receive -> Currency to Swap

    'Swap' button

    'X' button below the main form to close the modal window

...

  • See the list of currencies suggested as Currencies to Send (according to Market Pairs on the platform): - ‘Search’ field
    - Logo, ID/Ticker
    - Asset's balance available for operation
    - Selected Currency is ‘marked’

  • Select the Currency to Send from the list

See the Swap details changed according to the Market parameters with new selected Currency:

  • Pre-set for Send in the Input field for amount to Send (Minimum amount to send according to market settings)

  • Current Balance of Currency to Send

  • Option(s) for Currency(ies) to receive

  • Field 'Receive' with the calculated amount (Approximate) in Currency to Receive

  • Current Balance of Currency to Receive

  • Platform commission

  • Platform rate

  • Estimated result rate

  1. Press “Max” button and use all available balance for Swap operation:

  • See the calculated amount (Approximate) of Currency to Receive in the field 'Receive'

  • Observe that the Amount of the Currency to Receive depends on the estimated rate of the selected Market Pair and changes if the Amount to Send is edited

  • See the 'Swap' Button activated if the input amount fits the requirements

  • Platform commission displays data

  • Platform rate displays data

  • The estimated result rate displays the data
    In case the maximum balance is lower than the minimum required for Send:

  • 'Minimum amount to send' notification on top of the input field "Amount" (according to market settings)

  • See the 'Swap' Button deactivated

  • Field 'Receive' with “0.00” amount in Currency to Receive. The text has an error color

  • Platform commission has a ' – ' amount

  • Platform rate displays data

  • Estimated result rate has a ' – ' amount

...

Press the 'Reverse' button and change the position of selected currencies Currency to Receive -> Currency to Send

UX/UI User stories

As a User, I can press the 'Swap' button on Currency Wallet 'Card' and... Open the 'Quick Swap' form as a modal window
In case there are no available markets to Swap the Currency 'Swap' button is deactivated
...See the following details in the modal window: 'Quick Swap' header
Send section with main details:

...

  • 'Drop down' button to select Currency to Send with logo and ID (Ticker)

  • In case there is only one option for Currency to Send: the user can observe just this option with logo and currency ID in a drop-down

  • Currency to Send is selected according to Wallet selected (by default for each Wallet) with logo and ID (Ticker)

  • Input field for amount to Swap (Send internally), pre-set "Minimum amount" to Swap by default

  • "Max" button for Maximum amount input

  • Asset's balance available for operation, in selected currency with currency ID
    'Reverse' button for changing Currency positions between 'Send' and 'Receive'
    Receive the section with the main details:

  • 'Drop down' button to select Currency to Receive with logo and ID (Ticker)

  • The field 'Receive' with a calculated amount (Approximate) in Currency to Receive

  • The second Asset's balance (Currency to Receive) currently available in its Wallet
    "i" icon and notice the text message "Exchange rate refreshes with counter"
    "Rate" portion for selected Market Pair: Base Currency -> Quote Currency (price precision, according to market settings)
    "Rate" animated circle statement for the rate updated periodically after a certain time has elapsed (10 seconds by default).
    "Swap" button
    The 'X' button below the main form to close the modal window

...


...Press the 'Drop Down' button to change Currency to

...

Send and... Open the Currencies drop-down list
See the list of currencies suggested as Currencies to

...

Send (according to Market Pairs on the platform) with the main details:

  • - ‘Search’ field
    - Logo, Input field to search Currency to Send by ID or Name of the Currency

  • Logo

  • ID/Ticker - Asset's balance available for operation
    -

  • Available Balances of the Currencies to Send

  • Selected Currency is ‘marked’marked
    Select the Currency to Receive Send from the list
    See the Swap details changed according to the Market parameters with

...

  • new selected Currency:

  • Pre-set for Send in the Input field for the amount to Send (Minimum amount to send according to market settings)

  • Current Balance of Currency to Send

  • Option(s) for Currency(ies) to Sendreceive

  • Field 'Receive' with a calculated amount (Approximate) in Currency to Receive

  • Current Balance of Currency to Receive

  • Rate

...


...Press the 'Drop Down' button to change Currency to Receive and... Open the Currencies drop-down list
See the list of currencies suggested as Currencies to Receive (according to Market Pairs on the platform) with the main details:

  • Input field to search Currency to Receive

  • Platform commission

  • Platform rate

  • Estimated result rate

  1. Press the 'Switch' icon as a button in the Platform rate portion and change the rate reflection Base/Quote or Quote/Base
    Press the 'Switch' icon as a button in the Estimated result rate portion and change the rate reflection Base/Quote or Quote/Base

  1. Click on the Input field for the amount to Send and see previous input clears automatically and the 'Minimum amount to send' notification is on top of the input field "Amount" (according to market settings)

  2. Input amount for Send and:

  • See the calculated amount (Approximate) of Currency to Receive in the field 'Receive'

  • Observe that the Amount of the Currency to Receive depends on the estimated rate of the selected Market Pair and changes if the Amount to Send is edited

  • See the 'Swap' Button activated if the input amount fits the requirements

  • Input only 'dot' first and see automatically changing to ' 0. ' in the Input field

  • Platform commission displays data

  • Platform rate displays data

  • The estimated result rate displays the data

  1. Input amount of the Currency to Swap lower than the minimum allowed and...

  • 'Minimum amount to send' notification on top of the input field "Amount" (according to market settings)

  • See the 'Swap' Button deactivated

  • Field 'Receive' with “0.00” amount in Currency to Receive. The text has an error color

  • Platform commission has a ' – ' amount

  • Platform rate displays data

  • Estimated result rate has a ' – ' amount

  1. Input amount of the Currency to Send bigger than the amount of the Available Assets:

  • See the 'Swap' Button deactivated

  • The field 'Receive' with a calculated amount (Approximate) in Currency to Receive. The text has an error color

  • Platform commission displays data

  • Platform rate displays data

  • The estimated result rate displays the data

  1. Leave the input field for Amount to Send empty:

  • 'Minimum by ID or Name of the Currency

  • Logo

  • ID/Ticker

  • Available Balances of the Currencies to Receive

  • Selected Currency is marked
    Select the Currency to Receive from the list
    See the Swap details changed according to the Market parameters with new selected Currency:

  • Pre-set for Send in the Input field for amount to Send (Minimum amount to send according to market settings)

  • Current Balance of Currency to Send

  • Option(s) for Currency(ies) to Send

  • The field 'Receive' with calculated amount (Approximate) in Currency to Receive

  • Current Balance of Currency to Receive

  • Rate

...


...Click on the Input field for an amount to Send and see... Previous input clears automatically and the 'Minimum amount to send' notification is on top of the input field "Send" (according to market settings)

  • The "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Input amount for Send and... See calculated amount (Approximate) of Currency to Receive in the field 'Receive'
Observe Amount of the Currency to Receive depends on the rate of the selected Market Pair and changes if the Amount to Send
See the 'Swap' Button activated if the input amount fits the requirements
...Input-only 'dot' first and... See automatically changing to ' 0. ' in the Input field

...


...Input amount of the Currency to Swap lower than minimum allowed and... 'Minimum amount to send' notification on top of the input field "Amount" (according to market settings)

  • The "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Input amount of the Currency to Swap higher than the maximum allowed and... 'Maximum amount to send' notification on top of the input field "Amount" (according to market settings)

...

  • The "Max" button deactivated

  • The field 'Receive' with “0.00” amount in Currency to Receive. The text has an error color

  • Platform commission has a ' – ' amount

  • Platform rate displays data

  • Estimated result rate has a ' – ' amountthe error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Input amount of the Currency to Send

...

bigger than the

...

amount of the

...

  • See the amount pre-set equal to the minimum amount to Send in the input field for Currency to Send

  • Field 'Receive' with a calculated amount (Approximate) in Currency to Receive. The text has an error color

  • See the 'Swap' Button deactivated

  • Platform commission displays data

  • Platform rate displays data

  • The estimated result rate displays the data

  1. Press the 'Swap' button and go to Off-chain Swap Step 2

  2. Press the ‘X' button below the 'Quick Swap' form and close the modal window 'Quick Swap’ form and get back to Wallet details

Off- chain Swap Step 2

...

As a User I can see main details of the form:

  • 'Confirmation' header

  • Send section with main details:

    • Currency to Send with logo and ID (Ticker)

    • Currency to Send is selected according to Step 1

    • Amount to Swap (Send internally) according to Step 1 inputs

  • 'Arrow' icon for displaying Currency swap positions between 'Send' and 'Receive'

  • Receive section with main details:

    • Currency to Receive with logo and ID (Ticker). Selected according to Step 1

    • The field 'Receive' with a calculated amount in Currency to Receive

  • Notice text message “Swap result in precise according to current rate”

  • Rate portion for selected Market Pair: Currency to Swap -> Currency to Receive (price precision, according to market settings)

  • Inverse rate portion for selected Market Pair: Currency to Swap -> Currency to Receive (price precision, according to market settings)

  • 'Confirm Swap' button (with timer)

  • 'X' button below the main form to close the modal window

Actions on Step 2:

  1. Press 'Confirm Swap' button and:

  • See popup notification 'Successful' if everything is correct

  • See the modal window 'Swap form' closing and get back to Wallet details

In case time is over 'Confirm Swap' button changes to “Refresh Quote” button

...

  1. Press ”Refresh Quote” button and:

...

The “Refresh Quote”' button changes to Confirm Swap' button with a timer

  1. Press the ‘X' button below the 'Confirmation' form and close the modal window 'Confirmation’ form and get back to Wallet details

Main Formulas:

...

Platform rate = Rate Source or Quote Rate

...

Available Assets and higher than the maximum allowed: 'Maximum amount to send' notification on top of the input field "Amount" (according to market settings)

  • The "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Input amount of the Currency to Send bigger than the amount of the Available Assets: - "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Leave the input field for Amount to Send empty: 'Minimum amount to send' notification on top of the input field "Amount" (according to market settings)

  • The "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...In case the available balance of the Currency to Send is lower than the amount of the Currency to Send (the first time open the form) See the amount pre-set equal to minimum amount to Send in the input field for Currency to Send

  • The "Max" button deactivated

  • The field 'Receive' with the error text '0.00' in the field 'Receive'

  • Rate with "--" (empty data)
    See the 'Swap' Button deactivated

...


...Press the 'Swap' button and... See the popup notification 'Your swap was successful' if everything is correct
Observe Available Balances of the Base and Quote currencies are changed
...Press the 'X' button below the 'Swap' form and... Close the modal window 'Swap form' and get back to Wallet details