We need another model for trading. Whenever a trade actions happens we need to create a trade model for this purpose.
Trade has following fields:
user
side (buy / sell)
unit (transfered unit of coin for this trade)
amount (transfered unit of USDT for this trade)
createdAt
Top-up
/api/topup/ [POST]
Body
unit: 1000
Using top-up endpoint users can buy USDT using their local currency (e.g. IRT). For now it's going to be a mock api in which when a user call it and asks for some amount of USDT, we'll automatically charge their USDT balance as requested.
Buy
/api/trade/<symbol>/buy/ [POST]
Body
amount: 1000
Using this endpoint users will pay some amount of USDT to buy the request coin. System will deduct the request amount from their USDT wallet and add the purchased unit to their coin wallet.
Sell
/api/trade/<symbol>/sell/ [POST]
Body
unit: 10.12
Using this endpoint users can sell their assets. Process is exactly the opposite of buying.
We need another model for trading. Whenever a trade actions happens we need to create a trade model for this purpose. Trade has following fields:
Top-up
/api/topup/ [POST]
Body
Using top-up endpoint users can buy USDT using their local currency (e.g. IRT). For now it's going to be a mock api in which when a user call it and asks for some amount of USDT, we'll automatically charge their USDT balance as requested.
Buy
/api/trade/<symbol>/buy/ [POST]
Body
Using this endpoint users will pay some
amount
of USDT to buy the request coin. System will deduct the requestamount
from their USDT wallet and add the purchased unit to their coin wallet.Sell
/api/trade/<symbol>/sell/ [POST]
Body
Using this endpoint users can sell their assets. Process is exactly the opposite of buying.