# Margin Trading

### Mechanism Design

Keeps creates an inventive feature called margin trading. In order to borrow leveraged assets that will be locked in the smart contract, the user must first contribute some form of tokens to the pool. If the user attempts to go long Bitcoin, the smart contract will purchase Bitcoin using the user's applied leverage in the everlasting DEX. When a position is liquidated or withdrawn, the smart contract will sell Bitcoin; if the net supply is insufficient to cover the loss, the position will be liquidated.

In order to short bitcoin three times, a user can sell bitcoin on the Eternal DEX and lock in the Keep's contract; they can also buy bitcoin back during withdrawals or liquidations; When the loss is more than the net supply, the position will be liquidated.

Therefore, as indicated in the chart below, users are not permitted to borrow against their assets prior to withdrawal or liquidation. This is different from the typical borrow model, where users can obtain assets by providing over the collateral assets and placing them in their wallets.

Keep Margin does not charge a funding fee like Perpetual does. If customers want to keep onto their place for a while, they are not need to pay the fee, which is typically collected once every eight hours, every day.

A smart contract controls the purchasing, selling, and liquidating of assets in the dex on the same chain. The best DEX will be chosen by Keep Finance to be included in the Keep margin contract.

<figure><img src="https://lh4.googleusercontent.com/bL-wvRyA-4vuef73HkYlx4CPw-nBztzlb8bIiqVjWXoOTbfHggtZlY51Kx6z_VU07T2VhIOyTtDllLSArN6liQ6-rvoUSH0JgueUbkWYeuIU6SBPQYlSp3d9VJ6a3KUpJqQkAkcK43eGQ0wKU5XgW2rVTvKTGkaE7grEhTFnkRHmjp_ikY7xDepEb1YyIw" alt=""><figcaption><p>Margin Trading Mechanism Design</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://keep-finance.gitbook.io/keep-finance/keep_core/margin-trading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
