The Decentralized Exchange of Money On Chain, TEX, is an important piece of the protocol because it ensures the existence of a secondary market for its tokens. This is a basic TEX User Guide.
First of all, it is necessary to notice something important: this guide has been written using transactions from the testnet. That is, they are operations created mainly as an example, but the TEX is running on mainnet at the address https://tex.wordpress-466376-2057547.cloudwaysapps.com and the concepts in the guide are equally applicable.
While it is not rocket science, it is reasonable to test it on testnet before using it for the first time on mainnet. Take into account that the notation used for the amounts is American, and therefore, the point is used to indicate the decimals and the comma as a separator of thousands.
To enter the TEX you have to connect to the app using Metamask or Nifty Wallet, which is the one used in this example. In case it shows zero balance when connecting, and even though the corresponding RSK network is selected, just click on network and select RSK (mainnet or testnet, as the case may be). With that, it should be resolved.
As with other apps, when connecting for the first time the wallet will request to sign a message to connect to the application.
Once it has been signed, the TEX can be used and the screen will show the necessary information (from left to right, and from top to bottom):
In the Pair box, you can choose the pair to make the exchange. In this example, rBTC / DOC.
The first thing the app requests is to configure what is called ALLOWANCE, which is the amount of funds in the wallet that is authorized to exchange within the TEX app. Only in the case of rBTC you must "wrap" them to obtain WRBTC. This way, you will be able to exchange rBTC directly with other tokens.
Once the allowance for the WRBTC / DOC pair is configured, a buy or sell offer can be placed.
In the BUY & SELL TOKENS box there are several things to consider:
There is a minimum value established to place an order. This minimum is USD 10 in the equivalent of the token that is being exchanged. There is no maximum.
The fees has two components, one fixed and the other variable:
From a $ 10 order, 50 cents are deducted for fees, and from the remainder, 0.1% (USD 9.5 * 0.001 = USD 0.0095). That is, the order is established for USD 9.4905 and there is USD 0.5095 of fee reserve.
For each partial match that occurs with an order, the proportional fee is charged. For example, if 30% of the total order is matched, $ 0.15285 is charged from the fees reserve and $ 0.35665 remains in reserve.
If the order is matched in full, the entire fees pool is consumed.
In addition to being consumed in its entirety, the order can end for two reasons:
If the user cancels it, in addition to the tokens that have not been exchanged, the totality of what has been left in the fees reserve will be returned.
If it expires, in addition to the tokens that have not been exchanged, 80% of what has been left in the fees reserve will be returned. 20% is to cover the expiration cost.
In a Limit Order, a purchase or sale order is made, setting a limit up to which the operation is to be executed. That is, buying for a price less than or equal to X or selling for a price greater than or equal to Y. The total amount of the order is provisionally deducted from the account balance. These types of orders guarantee to buy or sell at the stipulated price or a better one.
For example, if there was a buy order for 1 rBTC at 15,000 DoC and a sell order for 1 rBTC at 14,500 DoC.
At the time of the tick, both orders will be executed as the buy price is higher than the sell order price. In this case, the price will be the one that benefits both parties. In other words, whoever buys will not spend more than the maximum that he was willing to pay, nor will the one who sells receive less than the minimum he hoped to obtain; the price will be the average between the two (for this example, 14,750 DoC).
After entering the desired values in the box with the Limit Order option selected, in this case SELL, you must click on PLACE ORDER. A wallet’s box will appear asking to SUBMIT the transaction.
Once the transaction is confirmed (tx) a box appears indicating that the order is open. Each transaction pays a small fee for using the network.
To the right of the image above is the order book. Orders can also be viewed by clicking on the ORDERS option in the menu.
In the example, a WRBTC allowance was configured that is completely included in the sale request, so the app indicates that the allowance must be configured again because it has been left at zero.
Each ALLOWANCE configuration requires a transaction on the network, which implies a small fee for its use.
The other way to place an order is with the market maker option.
A market maker order is a special type of limit order. When a market maker order is entered, a percentage difference with a fair price is specified. The fair price is obtained from an oracle or from the last tick in case there is no oracle available.
For example: in the event that the price of rBTC is 15,000 DoC and a market maker order is entered to buy 15,000 DoC of rBTC and less than 0.5% of price difference is indicated, the limit order will be priced at 14,925 USD and will change its price along with the price of rBTC. If the rBTC price rises or falls, the order price will automatically adjust to reflect the rBTC price minus 0.5%.
In this example, with rBTC priced at 15,000 DoC, rBTC would be bought at $ 14,925 or less.
Two differences arise from observing the BUY & SELL TOKENS box in MARKET MAKER ORDER, these are: AMOUNT TO INVEST and PRICE DIFFERENCE.
This means that you enter the amount you want to buy or sell at the emerging price indicating the difference (plus / minus in %) accepted to carry out the transaction.
In the image you can see the placement of the order indicating the ID, the amount and the emerging price at which it was placed. And also a partial match within the 5% range specified in the order.
So far we have seen how to place an order, both Limit Order and Market Maker Order.
In the rest of the initial TEX screen you can also see a section of graphics in which you can see the current orders in CANDLE or DEPTH format.
Then you can see the table referring to TICK STATS, with information on the number of tick, approximate time remaining, volume of the pair and last closing price. By clicking on the arrow located in the upper right corner we access the TICKS tab with more detailed information on each one.
Finally, in the ORDERS tab, we find the information related to each of the placed orders, separated by type (Limit Order / Market Maker Order).
The Money On Chain Decentralized Exchange, TEX, is a powerful and simple tool for exchanging tokens on the RSK network.