Closed zed-wong closed 5 months ago
The whole process of placing an order would look like this:
AfterMixinOauth
function will read user balance, we need to get the balance from inside wallet.ts
userAssets
store corresponding to asset id, e.g. BTC/USDT, when the type is Buy, we need to show the balance of USDT, and Sell shows the balance of BTC.@Get('/tickers/pairs')
in marketdata.controller.ts
as getSupportedPairs
in marketdata.service.ts
The check for sufficient liquidity is implemented by using the method in exchange.service.ts
to read the balance of the corresponding pair on the exchange.
This can be done by adding a field to getSupportedPairs
so that the front-end can directly read the information it needs when switching between pairs, but this will expose the balance of the API key because it must return the balance of the corresponding asset on the exchange to do a quantity check, and should prevent the user from placing an order if there is insufficient quantity on the exchange. It is also possible to make a separate endpoint for checking the balance, so that the quantity is passed in and only whether there is enough balance to support the transaction is returned.
@Get('/tickers/pairs')
getSupportedPairs
This API is used to get the list of supported pairs for the frontend, and is called when we select and switch pairs in /spot/okx/BTC-USDT
.
Estimated price
in confirm order
dialog. The current Estimated price
is a value that directly get from exchange. which is needed to subtract our platform trading fee and our rebalance cost. The trading fee is a value in customConfig.service.ts
inside readSpotFee
function. Now it's 0.2%. The rebalance cost is a bit of complicated. For different token there will be different fee and the fee is dynamic. We need to get the value from mixin api and bigone api. We may add a field to getSupportedPairs
endpoint for rebalance cost calculation.
It would take massive amount of time to find the best and the most precise way for calculating the rebalance cost. We can skip this for now and just reduce the platform trading fee from the Estimated price
.
placedOrderUpdater()
in exchange.service.ts
to make sure that the order state in our database will be successfully updated to the latest values.@mj-blockydevs @arianejasuwienas
@mj-blockydevs As we don't have enough time for fine tuning the massive amount of details:
estimated price
to subtract 0.2%
fees (which in practice is to add 0.2%)@mj-blockydevs
the whole process of placing an order would be like:
OKX
BTC/USDT
, buy
and market order
Buy BTC
Confirm order
Confirm order
buttonplaceOrder()
) in exchange.placedOrderUpdater()
) update the order state.mixin.listener.ts
and release token to user.we will need to mainly focus on steps 7-12
For displaying price
For clicking the confirm buy/sell button
Check order status