bigshortbets / market-frontend

BigShortBet$ P2P Market is a cutting-edge peer-to-peer marketplace built on the principles of decentralization that allows direct P2P trading on unique & event-based markets. Enjoy ultra-low fees and no swaps. Powered by $BigSB.
https://app.bigsb.io
GNU General Public License v3.0
2 stars 4 forks source link

It shouldn't be possible to place an order for a cost greater than the current Market Deposit #74

Closed DanDanielD closed 2 months ago

DanDanielD commented 3 months ago

Description: Users are currently able to submit orders with a cost higher than the current market deposit. For example, users can have a 1000 USD market deposit and place an order with a cost of 1600 USD. This order, when matched will create position and creates change in Market Deposit.

Steps to Reproduce:

  1. Navigate to https://test-market.bigsb.io/ and log in with your wallet.
  2. Choose e.g Tesla April 2024 market and deposit 1000 USDC into it. Make sure that Tesla Market Deposit is 1000 USDC.
  3. Place an order (Buy or Sell) for 1 UNIT at a price around the current market price, but not at a price that would match with an opposite side order and create a position if they already exist in the order book. The cost for 1 unit shown as Order Cost should be approximately $1560, which exceeds the current market deposit by $560.
  4. Observe the order being placed into the order book despite the cost being bigger than the deposit.
  5. Use a different account to create an order with the same price but in the opposite direction. When the order is matched by an opposite order and a position is created, observe (on the first account) the Market Deposit changing from 1000 USDC to 2559 USD.

Expected behaviour: It's an industry standard that when typing a required amount of contracts, and its cost exceeds the available balance (Market Deposit in this cas), the platform should disable the Buy/Sell buttons (including the Place Order button). If the user enters a number of units resulting in an Order Cost higher than the Market Deposit, the user should be notified, for example, by the text color in the UNIT field changing to red.

Additional Information: When an invalid order, one that exceeds the Market Deposit, is matched, the Market Deposit value increases automatically.

A screenshot illustrating the Tesla market with a deposit of 1000 USD, sourced from a wallet with a balance of 20,000 USD. The calculations between Wallet Balance, Total Deposits, and Market Deposit are correct. image

Screenshot displaying an order with a cost exceeding the current Market Deposit, placed in the order book. The Wallet Balance, Total Deposits, and Market Deposit amounts have changed and the calculations between them are incorrect. image

Orders have been matched, and positions have been created. Wallet Balance, Total Deposits, and Market Deposit amounts have changed. image

DanDanielD commented 2 months ago

Based on the assumptions regarding the market and target audience discussed during our Zoom call, the current market logic is functioning as intended.

During our discussion, we also identified two additional related issues that will be addressed through separate tickets:

1) Wallet balance depletion: funds are being drained from the Wallet Balance and not being returned, preventing further position opening. 2) Initial Margin visibility: upon order placement, Initial Margin is deducted from Wallet Balance but not reflected in Market Deposit or anywhere else until the order fills. This lack of visibility can create confusion and an illusion of a funds discrepancy.

Thank you, @Klapeyron, for the fruitful conversation on this topic.