> For the complete documentation index, see [llms.txt](https://docs.concordia.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.concordia.systems/use-cases/margin-trading.md).

# Margin trading

Concordia's collateral protocol presents application developers an easy path to implement margin trading.  Using Concordia, one can open trades with borrowed funds, and settle them physically across blockchain networks.

Bilbo deposits 100 USDC into his Concordia margin account.  He wants to use this deposit to trade on leverage.  An on-chain margin-trading program is connected to Concordia, and can perform a **composite operation** which includes a withdrawal, exchange, and deposit all in one transaction.  Bilbo executes this program to perform a 5x leveraged swap of USDC for ETH on a connected DEX.

* Concordia allows Bilbo to borrow 400 USDC
* All 500 USDC are withdrawn from Bilbo’s account&#x20;
* The program performs an exchange for \~$500 worth of ETH
* $500 ETH are deposited into Bilbo’s account, and the transaction ends

<figure><img src="https://lh4.googleusercontent.com/B1i9cgp3E5EDKi84uU-4VBIyUHEF6L_1q7kzUopvdVUvR2WCf0OAyJrZ5aoddjFauRczsiJUNsAE3-1qqkY0nO2sgz7at6ADbtDXpYIO5eLiii7M-7ka1lgEEUpbzY-9Ha-dknUkJ-mP3n5DguJVJ5hTeDqEIIkY28x3uznKdpD46pukD-eV_laOOlMaJA" alt=""><figcaption></figcaption></figure>

At the conclusion of this 5x trade, Bilbo is in debt 400 USDC, and owns $500 worth of ETH.  His debt is secured by the ETH he bought.  Importantly, he performed this 5x trade on an initial deposit of 100 USDC.  "Closing" this open position requires paying back the 400 USDC he borrowed.  This can be done with a second composite operation, in the reverse: withdraw the ETH, exchange it for USDC, deposit the USDC, and repay the debt.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.concordia.systems/use-cases/margin-trading.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
