> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swaps.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Transaction Lifecycle

> End-to-end walkthrough: discover a market, place an order, track it, manage the position, and withdraw.

This page walks through the full life of a prediction market position on
Swaps, from market discovery to withdrawal.

```mermaid theme={null}
flowchart LR
    discover["Discover market"] --> place["Place order"]
    place --> track["Track workflow"]
    track --> manage["Sell / Redeem / Merge"]
    manage --> withdrawStep["Withdraw"]
```

## 1. Discover a market

Find markets and the details needed to trade them:

* [`Search Markets`](/prediction-market-reference/search-markets) — query by
  keywords or tags.
* [`Get Trending Markets`](/prediction-market-reference/get-trending-markets) —
  high-volume markets by 24h activity.
* [`Get Markets`](/prediction-market-reference/get-markets) /
  [`Get Event`](/prediction-market-reference/get-event) — full market details.

From the market details, capture the CLOB `tokenID` of the outcome, the
`tickSize`, and the `negRisk` flag — every order needs them. Use
[`Get Market Price`](/prediction-market-reference/get-market-price) for
current bid/ask.

## 2. Place an order

Choose an [integration pattern](/prediction-market-reference/integration-patterns):

* **Chain abstracted** — one
  [`getAction` call](/prediction-market-reference/place-order-chain-abstracted)
  that swaps any token on any chain from the user's existing wallet and
  places the order.
* **Direct** —
  [`createOrFetchPolymarketUser`](/prediction-market-reference/create-or-fetch-user),
  fund the deposit wallet with pUSD on Polygon, then
  [`placeOrder`](/prediction-market-reference/place-order) with an EIP-712
  signature ([signing guide](/prediction-market-reference/polymarket-signing)).

## 3. Track the workflow

Every order returns a `txId`. Poll
[`GET /workflows/getStatus`](/prediction-market-reference/get-workflow-status)
with it to follow execution — the response reports the workflow `status`
(`pending`, `success`, `failed`), the `operation` (e.g. `placeOrder`), and
operation data including the order result.

Monitor open positions with
[`Get Current Positions`](/prediction-market-reference/get-current-positions)
and activity with [`Get Activity`](/prediction-market-reference/get-activity).

## 4. Manage the position

* [`Sell Position`](/prediction-market-reference/sell-position) — exit before
  resolution with a market order (FOK/FAK).
* [`Redeem Position`](/prediction-market-reference/redeem-position) — claim
  winnings from a resolved market (or burn worthless outcome tokens).
* [`Merge Position`](/prediction-market-reference/merge-position) — combine
  complementary YES/NO holdings back into collateral.

Every sell and redeem request is signed with EIP-712 — see the
[signing guide](/prediction-market-reference/polymarket-signing). Proceeds
default to the caller's EOA; set `dstWalletAddress` and/or `dstToken` to
deliver them anywhere else.

## 5. Withdraw

Move collateral out of the deposit wallet with
[`Withdraw`](/prediction-market-reference/withdraw) — funds go to any wallet,
optionally swapped into a different token or chain, authorized by an EIP-712
signature.

Withdrawals are workflows too — track them with the same
[`GET /workflows/getStatus`](/prediction-market-reference/get-workflow-status)
endpoint.
