How closing trades and profit payout function.

Scrinium.ai
1 min readMay 3, 2018

--

We have described opening a trade in our previous article. This one is about closing a trade.

  1. Trader closes a trade on Liquidity Provider side.

2. Scrinium Backend trails that order and finds all the investors trades opened in accordance with this one.

3. Then ScriniumBackend initiates closing of all trades on Liquidity Provider side.

4. For each trade Liquidity Provider attempts to close the trade in the blockchain

Platform.closeTrade(
uint _tradeId,
uint _closeTime,
uint _closePriceInstrument,
uint _closePriceSCRBase
) external onlyAllowedLiquidProvider

5. All the necessary checks are performed within Platforms contract and the profit of the trade is calculated as well. Information about the trade is updated.
One can request updated information from the contract:

platform.trades[tradeId] — general information about the trade
platform.tradeQuotes[tradeId] — information about the time and prices at the moment of opening/closing a trade.

6. Platforms contract updates investors balance using Balances contract.

Balances.updateBalance(
address _investor,
int256 amount
) external onlyPlatform

Thus, calculation of the profit and profit payout happens in the blockchain and doesn’t involve third parties or human factor.

Information about all trades is recorded to the Platform contract and is available to any investor at any given time

--

--