# Trading

## Swap

Hotbit supports swaps with 0 price impact. And 5LP will serve as a bridging asset for swaps. There are 3 kinds of routers for swaps：

* Swap inside a pool
* Swap between 5Pool & other pool
* Swap between other pools

<figure><img src="https://1920595500-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvlggcOnZgQx32ktR6Hpl%2Fuploads%2FZuneyheBgTfOXloagRjc%2Fimage.png?alt=media&#x26;token=db3a6780-27f0-48a5-bc53-985acd49b5a9" alt=""><figcaption></figcaption></figure>

During a swap, minting/burning 5LP will be involved, and the entire process will be packaged into one transaction at this time. When a swap involves multiple pools, the available liquidity will also be affected by all the pools involved.

## Leverage Trading

### Opening/Closing a position

All assets can be longed or shorted except stablecoins and 5LP. Any token can be used to open a position, and a swap is needed if the token is different from the required collateral. And the default token you will receive when closing a position is the collateral token.

**Long Position**

The collateral of long positions is the token being longed. A snapshot of the USD value of your collateral is taken when the position is opened, and all calculations about the long positions are based on the USD value.

**Short Position**

For short positions, the collateral can be any of the supported stablecoins (for the 5Pool) or the 5LP token (for sub-pools).

The mechanics for these short positions are similar to the USD-M contract, but with a key difference. We utilize the IndexToken/USD price, while the collateral token is either a stablecoin or 5LP. We treat the IndexToken/USD price as the IndexToken/Stablecoin or IndexToken/5LP price. Consequently, the Stablecoin-M or 5LP-M contract becomes functionally equivalent to a USD-M contract, with all related calculations being consistent with the USD-M contract, except that USD is replaced by the respective stablecoin or 5LP.

With this approach, the pool can fully cover traders' profits, eliminating the risk of liquidation. Consequently, liquidity providers will not incur any additional losses. Unlike the USD-M contract, traders in the Stablecoin-M or 5LP-M contract are exposed to the risk of price fluctuations in the stablecoin or 5LP token itself. When the value of the stablecoin or 5LP rises, traders can earn higher profits (in USD terms); conversely, a decrease in their value will result in lower profits.

Here is an example to compare the differences between the 5LP-M and USD-M contracts：

For ease of calculation, we assume that all fees are zero, and the initial price of 5LP is $1. The user opens two identical positions with the same cost of $1,000.

<figure><img src="https://1920595500-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvlggcOnZgQx32ktR6Hpl%2Fuploads%2F3Jpitw6J4LsUkDwYowdq%2Fimage.png?alt=media&#x26;token=97421ad5-e1cd-4add-b45a-bfa7e04df609" alt=""><figcaption></figcaption></figure>

If the price of 5LP increases by 10% to $1.1, the net value of the 5LP-M position will become $6,600 (6,000 \* 1.1), earning 10% more profit than the USD-M position.

<figure><img src="https://1920595500-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvlggcOnZgQx32ktR6Hpl%2Fuploads%2FLzJcVWjhbQlwFkOnVNAB%2Fimage.png?alt=media&#x26;token=02eb6cf8-fb2c-4937-9f49-d2387b1e44f5" alt=""><figcaption></figcaption></figure>

Conversely, if the price of 5LP decreases by 10% to $0.9, the net value of the 5LP-M position will become $5,400 (6,000 \* 0.9), earning 10% less profit than the USD-M position.

<figure><img src="https://1920595500-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvlggcOnZgQx32ktR6Hpl%2Fuploads%2FO4KIRCwpy7Yfan5jkS5c%2Fimage.png?alt=media&#x26;token=ced5a8f8-36fd-4999-b17c-0f0b0dad21ad" alt=""><figcaption></figcaption></figure>

### Adding/Reducing Collateral

After opening a position, you can edit(add or reduce) your collateral at any time.&#x20;

### Take-Profit/Stop-Loss

You can set take-profit and stop-loss orders by clicking on "Close" and selecting "Limit". You can only place one take-profit or stop-loss order at a time, which means if you want to set a take-profit and a stop-loss for a position, you need to place orders at least twice.&#x20;

TP/SL orders are reduce-only orders and will be executed based on the minimum value of the current position size and order size. Additionally, TP/SL orders are trigger-market orders and are not guaranteed to execute at the trigger price.

If you close a position manually, the associated TP/SL orders will remain open, and you have to cancel them manually if you do not want the order to be active when opening new positions.

### Liquidation

When the price of the index token being longed/shorted crosses the point at which  (collateral - losses - borrow fee) is less than 1% of your position's size, the position will be automatically liquidated. If there is any collateral remaining after deducting losses and fees when liquidation, the corresponding collateral will be returned to your account.

It's critical to regularly monitor your liquidation price as it will change over time due to the borrowing fee, especially when you are using high leverage. You can modify the liquidation price at any time by adding or reducing the collateral as necessary.

## Pricing

Hotbit uses an aggregate price feed ([Chainlink](https://chain.link)) which offers 0 price impact trades and reduces the risk of liquidations from temporary wicks.&#x20;

**Slippage**

Though the trades will not move the market price, there can still be slippage, the difference between the expected price of a trade and the actual executed price. It is caused by the price movements between when your trade is submitted and when it is confirmed on the blockchain.&#x20;

**Spread**

Mostly, there is no spread from the Chainlink price to the median price of reference exchanges, but it may exist during times of high volatility and your trades would be affected as follows:

* If you swap TokenA to TokenB, the price(tokenA/tokenB) will be (lower price price of tokenA) / (higher price of tokenB).&#x20;
* For leverage trading, 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.

## Fee

The fees involved in trading are as follows:

* Swap fee

Similar to the fees to mint or burn LP, the swap fee will vary from 0.00% to 0.65% based on whether the action improves or reduces the balance of assets in the pool.

* Position fee

For leverage trading, when you open/close a position, there will be an open/close fee, which is calculated as 0.1% of the position size.

* Borrow fee

Borrow fee is the fee paid to the counterparty of your trade and will be deducted from your collateral at the start of every hour. It will vary based on asset utilization and is calculated as 0.01% \* (assets borrowed) / (total assets in the pool).

As the leverage multiple increases, the borrowing fee will have a certain discount as follows:

<table><thead><tr><th width="48">Leverage</th><th width="115">Discount Rate</th></tr></thead><tbody><tr><td>≤10x</td><td>100%</td></tr><tr><td>10x~50x</td><td>1-(Leverage -10)*1%</td></tr><tr><td>≥50x</td><td>60%</td></tr></tbody></table>

* Execution fee

The execution fee is a network cost paid to the blockchain network. It is a fixed value that would be adjusted according to network status and has no relation to the order size. After the user's transaction request is initiated, it will be executed by <mark style="color:blue;">keepers</mark> when the request is triggered.&#x20;

* Liquidation fee

A liquidation fee is incurred when your position is facing liquidation, and paid to the executors. If (collateral - losses - borrow fee) is less than the liquidation fee, this cost will be covered by the pool.

## Others

**Limit Order**\
Limit orders are trigger-market orders and are not guaranteed to execute at the trigger price. You can edit the price of an unexecuted limit order at any time, or cancel that order.

Limit orders may not be executed in a few situations including but not exclusive to:

* Insufficient liquidity to execute the order
* 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
