# Buying and Selling XCP and Tokens on the DEx

<mark style="color:yellow;">Since all tokens can be traded against any token, there are a significant amount of market pairs on the Counterparty Decentralized Exchange.</mark> \
\
It's best to understand how to correctly read the data, place orders and cancel orders before jumping in and initiating functions.\
\
After reading the [Understanding Exchange Pairs](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/buying-and-selling-xcp-and-tokens-on-the-dex.md) and picking your desired market pair you wish to trade, make sure you understand all the functions, buttons and data of the order pair shown in Freewallet below.

<figure><img src="/files/rYDxEs9Q5qMBcOhY61cV" alt=""><figcaption><p>The PEPECASH/XCP market pair on the DEx</p></figcaption></figure>

Above we have for example the exchange pair PEPECASH/XCP. This data is all taken from the public trading information of this pair taken from all Counterparty orders. There are a few modules included showing various data points of the price, a customizable graph, modules to buy and sell this token pair, as well as a list of active orders below.

<figure><img src="/files/pTWlEibpXQHGEpMc2pys" alt=""><figcaption><p>By clicking the chart icon on the top left, you can view the date with trading indicators</p></figcaption></figure>

On the upper left, there is a customizable graph that is by default set to "All History" of token and on the “Candlestick” setting for viewing the data

<figure><img src="/files/3tl8Xba2wyMm02J9tHr1" alt=""><figcaption><p>Customizable slider on the bottom of the graph module</p></figcaption></figure>

When the time setting in the graph is set to “All” you can also use the slider at the bottom to view more specific timeframes

<figure><img src="/files/XR6onDYcT6Mnb5eXTnDs" alt=""><figcaption><p>Upper right module showing specific pair information such as token supply and last price</p></figcaption></figure>

On the right hand side there are some rudimentary information about each token in the pair to the right as well as links to more information about each token. \
\
When clocking the "More Information" buttons, these links will take you to each asset’s Tokenscan page to review more public information about each token not shown here.

Below that is some small icons for your customizable ‘tabbed markets’ mentioned before on the main Exchange page in the [Decentralized Counterparty (DEx)](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/the-decentralized-counterparty-exchange-dex.md) section.

Next is the order book. The left panel indicates the place to Buy PEPECASH and the right side to Sell PEPECASH.

<figure><img src="/files/fNq8soCP2yphNSCB9YcT" alt=""><figcaption><p>Buy and Sell modules with the market Sell and Buy Orders shown below</p></figcaption></figure>

* The <mark style="color:green;">Balance</mark> input is automatically filled with the balance of each Token you hold on the address you are selected on at the moment.
* The <mark style="color:orange;">Price</mark> is auto filled to the lowest price possible (market price), but this can be changed if you would like to set a limit order up to be filled later when a buyer/seller fills it
* The <mark style="color:yellow;">Amount</mark> is how many you would like to buy/sell
* <mark style="color:red;">Total</mark> is the amount this order will cost

If at first the numbers don’t make sense or confuse you (order numbers may be shown in extensive decimal numbers) it may be helpful to “switch” the pair to view it in the opposite manner.

<figure><img src="/files/sjvpH03UiQN3HOK0v1sw" alt=""><figcaption><p>Market Pair as typed into the Search Bar</p></figcaption></figure>

To do this first navigate to the top left where the exchange pair is listed. Then click the two parallel arrows pointing away from each other.

<figure><img src="/files/fms4avUWOukV96g8WquJ" alt=""><figcaption><p>Market pair flipped by pressing the two parallel lines button</p></figcaption></figure>

<mark style="color:yellow;">Doing so will now switch to XCP/PEPECASH</mark>, in which the orderbook will now show things “denominated” in XCP instead:

<figure><img src="/files/XOCpJyf4zI8ASHC2fWD9" alt=""><figcaption><p>How the market pair looks when switched</p></figcaption></figure>

Now on the left side is Buy XCP and the right is Sell XCP and as you can see the order books ‘flipped.’ Also <mark style="color:yellow;">notice how the Balance’s for each remained the same, but the Price changed</mark>.

<mark style="color:yellow;">Let flip it back</mark> to PEPECASH/XCP and put an order to buy some PEPECASH with XCP.

<figure><img src="/files/gaddbt3LomsrcMLh4jYE" alt=""><figcaption><p>After flipping the pair back to PEPECASH/XCP, this is the Buy PEPECASH module</p></figcaption></figure>

In this example we have 0.25 XCP and if we wished to just buy 0.25 XCP’s worth at the current market price I would simply change the Total input to 0.25 XCP

<figure><img src="/files/pZqrqxqTSFEzizd0apsH" alt=""><figcaption><p>Chaning the Total amount first at the bottom will auto fill the Price and Amount to the Market Price</p></figcaption></figure>

Freewallet will now automatically fill the “Amount” to be exactly how much you could buy at the market price, which in the example happens to be 0.00175 XCP as shown in the Sell Orders below this module. \
\
If we sent this order through <mark style="color:yellow;">Freewallet will automatically match any orders at the price and leave any remainder as an open order in the orderbook.</mark>

<figure><img src="/files/DkIazYyn1qQDv7IIZql1" alt=""><figcaption><p>Top Market sell orders at this time</p></figcaption></figure>

In this example if we sent this order through you can see in the order book there is only 69666 PEPECASH available at this market price so the remaining 69,523.14285714 PEPECASH would remain up for sale at this price. \
\
In the event you bought more than the 69666 PEPECASH at this price (which would be ALOT more XCP!), any amount higher than 69666 PEPECASH would be its own limit order and would remain on the order book for another user to fill.

Let’s say we would like to set a lower price than the market and would like to set up a custom Limit order and wait for someone else to match it in the future. Since any user with this asset may fill this order, it is common for users to list asks below the market price.

<figure><img src="/files/zkcxiZvPiaVhzwmVVbRs" alt=""><figcaption></figcaption></figure>

Here we now want to set the price of our XCP at 0.00155 per PEPECASH. But let’s say in this example we have decided we only want to buy 100 total PEPECASH at this price

<figure><img src="/files/JcjgMwwbArx6eocVHrcF" alt=""><figcaption><p>Custom filling the Price per XCP first, then filling the Amount</p></figcaption></figure>

Freewallet will now auto fill the Total input with exactly how much XCP you would need at this custom price to get 100 PEPECASH in a potential match.

The Sell side of things on the right works much the same way, and if you get confused, always remember instead of “selling PEPECASH” you can just ‘flip’ the chart using the icon in the upper right.\
\
So instead of buying PEPECASH you can just denote things by selling XCP. <mark style="color:yellow;">How you would like to denote your order is user preference, just make sure you understand the order book thoroughly before making a trade.</mark>

<figure><img src="/files/uwUkQ0xkKX8LktSyFlSr" alt=""><figcaption><p>The Market Depth, Trade History and My Open Order module</p></figcaption></figure>

Under the order book is Market Depth of the pair selected. <mark style="color:yellow;">This can give you some much needed information about where to place custom market or limit orders as some pairs are more liquid than others.</mark>

Below Market Depth is the Trade History of the market. <mark style="color:yellow;">Each transaction can be viewed in greater detail by clicking the link on the date of the transaction</mark> on the left side which will take you to each specific transaction hash on Tokenscan.

You can also click the My Trades button to see just your specific trade history in this market.

On the right side of that, if you had any open orders in the market they will appear here.

When you are ready to place an order and it all looks correct, simply click the “Buy” or “Sell” buttons and a confirmation pop up will appear

<figure><img src="/files/ASw85WoKGGE3ubwwwiIN" alt=""><figcaption></figcaption></figure>

This will show a “Confirm Buy Order?” or a “Confirm Sell Order?” pop up message which you can verify if the details on this order look correct.

<mark style="color:yellow;">The "Expires" input is how many Bitcoin blocks this order will stay active. The default setting (8064 blocks) is also the max amount of blocks a Counterparty Order will stay active.</mark>

The last step is to select your fee you wish to use when creating this order. If you have questions about this, check out the [What BTC fee Should I Use?](/freewallet.io-user-manual/getting-started/what-btc-fee-should-i-use.md).

<mark style="color:green;">If your order does not fill or fills partially and is not filled entirely when it is due to expire, the funds will be automatically refunded to your wallet.</mark>

<mark style="color:yellow;">To cancel an exchange order please reference</mark> [Cancelling Exchange Orders](/freewallet.io-user-manual/freewallet-functions/cancelling-exchange-orders.md) in the [Freewallet Functions](/freewallet.io-user-manual/freewallet-functions.md) section.


---

# 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://davestaxcp.gitbook.io/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/buying-and-selling-xcp-and-tokens-on-the-dex.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.
