Position

Position Management Mechanism in Dywe

In Dywe, position management is implemented through the interaction of Frontend, Backend and two main contracts: the Master Contract (Master Contract of positions) and User Contract (User Contract).


1. Opening a Position

The process of opening a position involves several steps:

  1. Transaction generation - the user initiates the opening of a position (Open Position) through the platform interface.

  2. Sending data to Master Contract - Frontend forms the transaction and sends it to Master Contract.

  3. Data processing - Master Contract deserialises input parameters and passes them to User Contract, which performs the functions of a database (storing and processing information about positions).

  4. Transaction Status Check - Frontend passes the BOC (Bag of Cells) of the transaction to Backend and requests the status of the transaction.

    • If the position is successfully opened, the user receives a confirmation.

    • In case of an error, an appropriate notification is displayed.


2. Closing a Position

Closing a position is performed as follows:

  1. Initiating a close - the user sends the Close Position command through the interface.

  2. Data exchange between contracts

    • The request is sent to User Contract.

    • User Contract sends a message to Master Contract containing the parameters of the position to be closed.

    • Master Contract sends a message to Liquidity Pool specifying the amount of X USDT to be credited to the user.

    • Liquidity Pool executes the transaction, sending the funds to the user's address.


3. Liquidating a Position

The process of liquidating a position is similar to closing a position, but with one key difference:

  • Liquidity Pool makes no payment to the user, as liquidation means a complete loss of margin collateral.

  • Otherwise, the procedure of data transfer between contracts remains unchanged.

This mechanism ensures reliable trade execution and protects the liquidity of the system.

Last updated