# Trading

## **Adding a wallet**

If you do not have a wallet yet, you can use MetaMask: <https://metamask.io/download.html>​

## **Connecting your wallet** <a href="#connecting-your-wallet" id="connecting-your-wallet"></a>

After you have a wallet, you can connect your wallet by pressing the "Connect Wallet" button on the TFX Trade page: <https://tfx.market/#/trade>

<figure><img src="https://3804870498-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkl990RPEsHxiRuhduGai%2Fuploads%2FOxUaeTbK9AbOPOe1BNkm%2Fimage.png?alt=media&#x26;token=60a11dee-9a11-47e2-99b7-50e9be8f7f96" alt=""><figcaption></figcaption></figure>

## Steps to change the RPC URL in MetaMask <a href="#steps-to-change-the-rpc-url-in-metamask" id="steps-to-change-the-rpc-url-in-metamask"></a>

* Click on the MetaMask icon, then click on the three dot icon and select Expand View
* Click on your account icon on the top right and select Settings
* Click on Networks
* Key in the New RPC URL
* Click Save

## **Swaps** <a href="#swaps" id="swaps"></a>

TFX supports both swaps and leverage trading. For swaps, click on the "Swap" tab on <https://tfx.market/#/trade>, this will open the interface to swap tokens with zero price impact.&#x20;

For leverage trading, please see the below sections for more information.

## **Opening a position** <a href="#opening-a-position" id="opening-a-position"></a>

Click on "Long" or "Short" depending on which side you would like to open a leverage position on.

* Long position
  * Earns a profit if the token's price goes up
  * Makes a loss if the token's price goes down
* Short position
  * Earns a profit if the token's price goes down
  * Makes a loss if the token's price goes up

After selecting your side, key in the amount you want to pay and the leverage you want to use, in the below example 0.1 BNB worth 32.89 USD is being used to buy a 50x BNB (Binance Coin) long position of size 1,566.20 USD

<figure><img src="https://3804870498-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkl990RPEsHxiRuhduGai%2Fuploads%2FcHEUNu5wf7YETEFhfQOO%2FSCR-25651101-jtm.png?alt=media&#x26;token=38fed406-4dea-4bd6-a8c5-8b1e971d400c" alt=""><figcaption></figcaption></figure>

The "Entry Price" is $328.90 and the Liquidation Price is $325.28. Below the swap box you would also see the "Exit Price", which is the price that would be used to calculate profits if you open and then immediately close a position. The exit price will change with the price of the token you are longing or shorting.&#x20;

The trading fee to open a position is 0.1% of the position size, similarly there is a 0.1% fee when closing the position.&#x20;

There is also a "Borrow Fee" that is deducted at the start of every hour. This is the fee paid to the counter-party of your trade. The fee per hour will vary based on utilization, it is calculated as (assets borrowed) / (total assets in pool) \* 0.01%. The "Borrow Fee" for longing or shorting is shown below the swap box.&#x20;

While there are no price impacts for trades, there can be slippage due to price movements between when your trade transaction is submitted and when it is confirmed on the blockchain. Slippage is the difference between the expected price of the trade and the execution price, this can be customised by clicking on the "..." icon next to your address at the top right of the page.

## Managing Positions

<figure><img src="https://3804870498-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkl990RPEsHxiRuhduGai%2Fuploads%2FAmCtFjzeGhVhMLdSFMVW%2FSCR-25651101-jur.png?alt=media&#x26;token=78e2afe3-5660-4e6b-ae38-6365229763f0" alt=""><figcaption></figcaption></figure>

After opening a trade, you would be able to view it under your Positions list, you can also click on "Edit" to deposit or withdraw collateral, this allows you to manage your leverage and liquidation price.&#x20;

When you open a position or deposit collateral, a snapshot of the USD price of your collateral is taken, so e.g. if your collateral is 0.1 BNB and the price of BNB is 328.90 at the time, then your collateral is 32.89 USD and will not change even if the price of BNB changes.&#x20;

The amount of profit and loss you make will be proportional to your position size. In this example, 32.89 USD has been used to buy 1,566.20 USD of BNB. If the price of BNB increases by 10%, the position would have a profit of 156.62 USD, if the price of BNB decreases by 10%, the position would have a loss of 156.62 USD.&#x20;

If a short position was opened instead, then if the price of BNB decreased by 10% the position would have a profit of 156.62 USD, if the price of BNB increased by 10%, the position would have a loss of 156.62 USD.&#x20;

Leverage for a position is displayed as (position size) / (position collateral). If you'd like to display the leverage as (position size + PnL) / (position collateral), you can customise this by clicking on the "..." button next to your address.&#x20;

Note that when depositing collateral into a long position, there is a 0.3% swap fee for the conversion of the asset to its USD value, e.g. BNB amount to USD value. This is to prevent deposits from being used as a zero fee swap. This does not apply to shorts. Withdrawing of collateral from longs and shorts do not have this fee as well.

## Closing a Position

You can close a position partially or completely by clicking on the "Close" button. For long positions, profits are paid in the asset you are longing, e.g. if you long BNB you would get your profits as BNB.&#x20;

For short positions, profits will be paid out in the same stablecoin that you used to open the position, e.g. BUSD.

Note that [bscscan](https://bscscan.com/) may not always show BNB transfers so when you close long positions on Binance and receive BNB the transaction might not show the transfer but your BNB balance would have increased. If the BNB transfer does show, it would be displayed under the "Interacted With" section:

## Stop-Loss / Take-Profit Orders

You can also set stop-loss and take-profit orders by clicking on the "Close" button and selecting the "Trigger" tab.&#x20;

After creating a trigger order, it will appear in your position's row as well as under the "Orders" tab, you can edit it the order and change the trigger price if needed.&#x20;

If you close a position manually, the associated trigger orders will remain open, you would need to cancel them manually if you do not want the order to be active when opening future positions.&#x20;

Note that orders are not guaranteed to execute, this can occur in a few situations including but not exclusive to:

* The mark price which is an aggregate of exchange prices did not reach the specified price
* The specified price was reached but not long enough for it to be executed
* No keeper picked up the order for execution

Additionally, trigger orders are market orders and are not guaranteed to execute at the trigger price.

<figure><img src="https://3804870498-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkl990RPEsHxiRuhduGai%2Fuploads%2Fu0S04LrX6f2zsbWduuZF%2FSCR-25651101-k7i.png?alt=media&#x26;token=b954c68d-665e-4371-a936-99bd6c7fd14d" alt=""><figcaption></figcaption></figure>

## Partial Liquidations

In the example, since only 32.89 USD worth of tokens is used as collateral to open the position, there will be a price at which the loss amount is very close to the collateral amount.&#x20;

This is the Liquidation Price and is calculated as the price at which the (collateral - losses - borrow fee) is less than 1% of your position's size. If the token's price crosses this point then the position will be automatically closed.&#x20;

Due to the borrow fee your liquidation price will change over time, especially if you use a leverage that is more than 10x and have the position open for more than a few days, so it is important to monitor your liquidation price.&#x20;

If there is any collateral remaining after deducting losses and fees, then the corresponding amount would be returned to your account.

## Pricing

There is no price impact for trades on TFX, so you can execute large trades exactly at the mark price. Since the protocol serves as the counter-party, there is a small spread for entering and exiting trades.

<figure><img src="https://3804870498-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkl990RPEsHxiRuhduGai%2Fuploads%2FjC2ON2qouqA6HgCeyRVR%2FSCR-25651101-jny.png?alt=media&#x26;token=b5d69d98-c949-48b8-8206-f8c53628c066" alt=""><figcaption></figcaption></figure>

The mark prices are displayed next to the market name, long positions will be opened at the higher price and closed at the lower price while short positions will be opened at the lower price and closed at the higher price.&#x20;

The chart will indicate the average of the two mark prices.

## Fees

The cost to open / close a position is 0.1% of the position size.&#x20;

The collateral of long positions is the token being longed, for BNB longs the collateral is BNB and for BTC longs the collateral is BTC, etc. The collateral of shorts positions is any of the supported stablecoins e.g. BUSD If a swap is needed when opening or closing a position then the regular swap fee would apply, this fee is 0.2% to 0.8% of the collateral size, the exact fee depends on whether the swap improves balance or reduces it.&#x20;

There is also an [execution fee](https://tfx-market.gitbook.io/tfx/basics/trading#execution-fee) detailed below which is used to pay for the blockchain network costs.

## Execution Fee

There are two transactions involved in opening / closing / editing a position:

1. User sends the first transaction to request open / close / deposit collateral / withdraw collateral
2. ​Keepers observe the blockchain for these requests then execute them

The cost of the second transaction is displayed in the confirmation box as the "Execution Fee". This network cost is paid to the blockchain network.

&#x20;
