> For the complete documentation index, see [llms.txt](https://docs.prophecy.bet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prophecy.bet/buy-trades.md).

# Buy Trades

#### Purpose

The Buy function allows users to purchase shares of a specific outcome in a prediction market. The price of shares is dynamically adjusted based on the current state of the market, reflecting demand and supply.

#### Workflow

1. Input Parameters:

   * Market ID.
   * Outcome to buy (e.g., YES or NO).
   * Amount of collateral the user is willing to spend.

2. Price Calculation

   * The AMM calculates the cost of the desired shares using the constant.

3. Pool Update:
   * Collateral is added to the pool for the selected outcome.
   * The share pool is adjusted to maintain the constant product.

4. Share Allocation:

* &#x20; The user receives the purchased shares in their wallet.

5. Fee Deduction:

* &#x20;A small fee is deducted and distributed to liquidity providers or the platform treasury.
