Settlement

Chromatic Protocol has created a contract factory as a mechanism to enable the independent operation of individual orders without relying on an order book. It functions as a contract template generator, producing standardized contracts. Parties interested in open position fill in the parameters of the template contract, enclose the collateral, and sign it to execute the transaction. The smart contract works as both the role of the template contract and as a form of escrow for the betting collateral.

Settlement is facilitated through the interaction of the following.

Account

To open a position, the takers must first deposit the required margin and fees into their account. Taker's profit, trading fee, and interest required for opening or closing positions are deducted from this account, and any resulting profits obtained from the position are deposited back into the account.

Liquidity Bin

When providing liquidity to the liquidity bins, makers directly supply liquidity from their wallets to the liquidity bins without going through the account. The liquidity deposited in the liquidity bins is used as a maker margin for executing transactions when takers open a position.

Next Oracle Round Mechanism

Chromatic Protocol has adopted the next oracle round mechanism to prevent the front-running attacks that arise due to the time delay in reflecting oracle prices. In every transaction, when takers open and close a position, or makers deposit or withdraw liquidity, the request is executed by this next oracle round mechanism. (For a more detailed explanation: Next Oracle Round Mechanism)

Keeper & TP/SL

In the Chromatic Protocol, when the oracle price reaches the TP/SL (take-profit/stop-loss) price set by the takers at the time of position opening, the keeper automatically places an order to close the position, even if the trader does not manually close it.

As blockchains do not natively support event-driven programming, to overcome this limitation, Chromatic Protocol utilizes Mate^2 keeper, a private-exclusive keeper designed solely for the Chromatic Protocol and developed and operated by the Chromatic Protocol itself. The integration with Mate^2 keeper ensures the automated execution of actions within the protocol in a decentralized manner.

While the position is open, the Interest, which is proportional to the position size and duration, is continuously deducted from the taker margin and reflected in the TP/SL price. Therefore, even if there is no price fluctuation, when the remaining size of the taker margin reaches 0, the position is automatically closed by the keeper.

The above factors are taken into account when opening or closing a position, and the process is as follows.

Opening Position

Once the trader signs the wallet to open a position, a transaction is generated, and the entry price is specified as the price of oracle round #N+1. It is explicitly stated that the entry price will be determined only when the next oracle round occurs, allowing the calculation of profits and losses.

When a position is opened:

  • In taker’s account, trading fees corresponding to the fee rate of the liquidity bins is paid and an amount equivalent to the taker margin is transferred to the contract as collateral.

  • In the liquidity bin, the maker margin required to open the position is converted to the utilized status and becomes collateral. At this point, the liquidity provider(maker) can withdraw the remaining free liquidity, excluding the utilized liquidity amount, which is equivalent to the maker margin.

Closing Position

When closing a position, the next oracle round mechanism is also applied. The order remains in pending status until the next oracle round comes, at which point the profit and loss (PnL) is determined at the price of that round, and the position closure is completed.

When a position is closed:

  • The interest corresponding to the duration the position was open is paid to the liquidity bins.

  • The interest will be reflected and displayed on the UI for Unrealized PnL and Finalized PnL on position window.

  • If a taker has a winning position, the profit is determined. The taker’s share of the profit is deducted from the maker margin held as collateral in the liquidity bins, and the remaining liquidity is restored to a free state. Later, when the taker claims the profit, it is transferred from the tx contract to the account.

  • If a taker has a losing position, the loss is determined. The portion of the taker margin held as collateral in the contract is moved to the liquidity bins, and the PnL for both the taker and the liquidity bins is finalized.

  • However, if a taker does not claim and leaves it unattended, the keeper will automatically claim it after 24 hours, resulting in the payment of the keeper fee. The reason for claiming is to prevent funds from remaining in the contract permanently. Therefore, it is recommended to claim and transfer to my account within 24 hours after closing the position.

Forced Liquidation

In the event of forced liquidation when the position reaches the preset TP/SL price, the keeper executes this without the trader's action. The party (taker or maker) that has made a profit bears the keeper fees in this case.

  • Please note that the keeper fee paid due to forced liquidation and automatic claiming are not currently reflected and displayed in the Finalized PnL on UI. (There are plans to add a feature to optionally include these costs in the Finalized PnL in the future.)

Next Oracle Round Mechanism in Settlement

Chromatic Protocol has adopted the next oracle round mechanism to prevent the front-running attacks that arise due to the time delay in reflecting oracle prices. In every transaction, when takers open and close a position, or makers deposit or withdraw liquidity, the request is executed by this next oracle round mechanism.

When placing orders to open or close positions at a specific moment, those orders are executed at the price of the next round of the oracle. Oracle prices on the ETH/USD market are updated every 0.05% change. (For a more explanation: Oracle) Therefore, in the given example, the price difference between entry and exit is $2.00, calculated as round 4 price ($2,003.00) - round 2 price ($2,001.00).

Below are examples of how the keeper and next-round oracle mechanisms operate in the Chromatic Protocol.

Example 1: A taker opens a long position in the USDT-ETH/USD market with 20,000 USDT. Setting stop-loss at -1,000 USDT and take-profit at +5,000 USDT, to strike a balance between risk management and profit potential.

Oracle RoundOracle Price (ETH/USD)StatusPredefined TP/SLUser Current PositionPnL

1

$2,000.00

Pending

SL : -1,000 USDT(19,000USDT)

TP : +5,000 USDT(25,000 USDT)

0

N/A

2

$2,001.00

Filled

20,000 USDT

0 USDT

The taker opens the position during oracle round 1 by setting the stop-loss and take-profit levels. However, the order remains pending until the subsequent oracle update in the following round, oracle round 2. This round serves as the confirmation stage, with the trader's position validated, and the fill price of $2,001.00 established, aligning with the price from oracle round 2.

As described earlier, there are two possible ways for a position closure. The first way is to manually close the position.

Example 2: The trader submits a position closure order during oracle round 3, which remains pending until the oracle is updated in the subsequent round. In oracle round 4, the trader's profit and loss (PnL) are finalized and executed, with the exit price set at $2,003.00 based on the price in oracle round 4. The trader can claim PnL and the remaining collateral.

Oracle RoundOracle Price (ETH/USD)StatusPredefined TP/SLUser Current PositionPnL

3

$2,002.00

Pending

SL : -1,000 USDT(19,000USDT)

TP : +5,000 USDT(25,000 USDT)

20,000 USDT

+9.99 USDT

4

$2,003.00

Filled

0 USDT

+19.99 USDT

The second way is when the position meets the stop-loss or take-profit conditions set by the trader, triggering the automated closure of the position by the keeper.

Example 3: In oracle round 503, the take-profit condition set by the trader is fulfilled, resulting in the keeper automatically closing the position. The position is closed with the exit price set at $2,502.00, aligning with the price from oracle round 503. Unlike the scenarios described earlier, in this case, there is no pending until the oracle is updated in the subsequent round. Instead, it is immediately executed within the same round.

Oracle RoundOracle Price (ETH/USD)StatusPredefined TP/SLUser Current PositionPnL

503

$2,502.00

Filled

SL : -1,000 USDT(19,000USDT)

TP : +5,000 USDT(25,000 USDT)

0 USDT

+5,000.00 USDT

*It is important to note that the examples provided do not include fees required for trading.

Last updated