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

# Combos (parlays)

> Quote, buy, cash out and redeem Polymarket combos, signed by the user's own wallet.

A **combo** (a parlay) joins 2 to 10 Polymarket outcomes into one position. It pays \$1 a share only if every leg wins. Makers price combos on request (an RFQ), so a combo has no order book. You take the quote or you don't.

The wallet signs every combo trade itself. Kairos asks Polymarket's makers for a quote, then returns one `eth_signTypedData_v4` request: the Polymarket order that accepts the quote. Nothing costs gas.

| You want to | Use |
| - | - |
| See the price | A `comboQuote` action. Nothing is signed |
| Buy | A `combo` action with `side: "buy"`. One signature |
| Cash out before it resolves | A `combo` action with `side: "sell"`. One signature |
| Collect a win | An [on-chain intent](https://docs.kairos.trade/wallets/onchain.md) with `operation: "redeem"` |
| List what the wallet holds | `GET /v3/wallets/{address}/combos` |

The wallet must be [set up on Polymarket](https://docs.kairos.trade/wallets/setup.md) first. Setup grants the approvals that combos spend: pUSD to Exchange V3 for buying, and Position Manager rights for Exchange V3 (cash-out) and the Router (redeem).

> [!NOTE]
>
> **Quotes last about 5 seconds.** Polymarket holds a combo quote for 5 seconds; `expiresAtMs` is when it lapses. Show the price with `comboQuote` first, then start `combo` and open the wallet at once. If the signature arrives later, nothing is traded: Kairos gets a fresh quote under the same `maxPrice` or `minProceeds`, and the action asks for a new signature (`needs_signature` again, with a new `request`). This happens up to 3 times; after that the action fails with `SIGNATURE_EXPIRED`. The SDK's `run` signs each request as it comes.

## Legs

A leg is a Polymarket **Protocol V2 outcome position id**, as a decimal string: one outcome of a market on Polymarket's newer exchange. Only markets that Polymarket opens to combos can be legs; Polymarket lists them, with the position ids of each outcome, at `https://combos-rfq-api.polymarket.com/v1/rfq/combo-markets` (`position_ids[0]` is the first outcome, `[1]` the second). Legs must be on different markets and must not contradict each other. Their order does not matter.

Makers decide what they price. A combo with a leg in play, or one that is already decided, may get no quote (`NO_QUOTES`), and a maker may still decline after the signature (`VENUE_REJECTED`; nothing is traded).

## Quote

```bash HTTP theme={null}
curl -X POST "$BASE/v3/actions" -H "X-Kairos-Partner-Id: $PARTNER" -H "X-Kairos-Wallet-Api: 2" -H "Content-Type: application/json" \
  -d '{"wallet":"0xUSER","action":{"type":"comboQuote","legs":["<leg 1>","<leg 2>"],"side":"buy","amount":"10"}}'
# {"status":"done","type":"comboQuote","result":{"side":"buy","price":"0.5","shares":"19.32381","cost":"10",
#   "kairosFee":"0.1","totalCost":"10.1",…}}
```

```js JavaScript (SDK) theme={null}
const quote = await kairos.wallet.run(wallet, {
  type: 'comboQuote', legs: [leg1, leg2], side: 'buy', amount: '10',
})
```

`amount` is pUSD to spend on a buy, or shares on a sell. The action ends `done` at once.

| Field | Means |
| - | - |
| `price` | Price per share |
| `shares` | Shares the buy gets, or the sell gives |
| `stake` | Buy: pUSD that buys the shares |
| `exchangeFee` | Polymarket's fee. Inside `cost` on a buy, taken from `grossProceeds` on a sell |
| `cost` | Buy: pUSD the trade takes, Polymarket's fee included. At most `amount` |
| `kairosFee` | The Kairos fee. It accrues as a debt the wallet settles through [fees](https://docs.kairos.trade/wallets/fees.md) |
| `totalCost` | Buy: `cost` plus `kairosFee` |
| `proceeds` | Sell: pUSD the trading wallet receives |
| `netProceeds` | Sell: `proceeds` less `kairosFee` |

Quotes are limited to 20 a minute per wallet.

## Buy

```bash HTTP theme={null}
curl -X POST "$BASE/v3/actions" -H "X-Kairos-Partner-Id: $PARTNER" -H "X-Kairos-Wallet-Api: 2" -H "Content-Type: application/json" \
  -d '{"wallet":"0xUSER","action":{"type":"combo","legs":["<leg 1>","<leg 2>"],"side":"buy","amount":"10","maxPrice":"0.55"}}'
# {"status":"needs_signature","request":{"method":"eth_signTypedData_v4",…},"expiresAtMs":…}
# Sign it, post {"signature":"0x…"} to /v3/actions/{id}, poll until "done":
# {"status":"done","result":{"rfqId":"…","status":"CONFIRMED","transactionHash":"0x…","shares":"19.32381",…}}
```

```js JavaScript (SDK) theme={null}
const fill = await kairos.wallet.run(wallet, {
  type: 'combo', legs: [leg1, leg2], side: 'buy', amount: '10', maxPrice: '0.55',
})
```

`maxPrice` (optional, 0–1) is the highest price per share the signed order may carry. If the quote is worse, the action is refused with `400` and `code: PRICE_LIMIT`; nothing is traded.

After the signature the action is `working` while Polymarket settles the trade on Polygon, usually a few seconds. The `done` result is the quote's fields plus `rfqId`, `status` and `transactionHash`.

## Cash out

List the wallet's combos, then sell one back to the makers before it resolves:

```bash theme={null}
curl "$BASE/v3/wallets/0xUSER/combos" -H "X-Kairos-Partner-Id: $PARTNER" -H "Authorization: SIWE $TOKEN"
# {"tradingWallet":"0x…","combos":[{"market":"polymarket:0x03…","sharesBalance":"19.32381","redeemable":false,
#   "legsPending":2,"legs":[{"legPositionId":"…",…},…],…}]}
```

```js theme={null}
await kairos.wallet.run(wallet, {
  type: 'combo', legs: combo.legs.map((l) => l.legPositionId), side: 'sell',
  amount: combo.sharesBalance, minProceeds: '9',
})
```

A cash-out sells the whole position: `amount` must equal `sharesBalance`. A maker may round the size down by less than 0.01 shares; the result's `shares` is what was sold, and the remainder (worth under a cent) drops off the combos list. `minProceeds` (optional) is the least pUSD that may land after Polymarket's and Kairos's fees. A quote below it is refused with `422` and `code: PRICE_LIMIT`.

A combo can't be cashed out once a leg has lost (it can no longer pay) or every leg has resolved (no maker buys a settled combo). Redeem a won combo instead.

## Redeem a win

When a combo's `redeemable` is `true`, every leg won. Redeem its shares for \$1 each with an [on-chain intent](https://docs.kairos.trade/wallets/onchain.md):

```js theme={null}
await kairos.wallet.onchain.redeem(wallet, combo.market, sharesRaw, { outcome: 0 })
```

`combo.market` is `polymarket:` plus the combo's condition id. `sharesRaw` is `sharesBalance` in 6-decimal base units (`"19.32381"` is `"19323810"`). Kairos checks the payout on chain before the wallet signs. Until every leg has resolved the intent answers `503`, and a combo that lost is refused with `400`. Only `redeem` works on a combo; `split` and `merge` answer `400`.

> [!NOTE]
>
> A trading wallet enrolled in Polymarket's auto-redeem (setup grants the Auto Redeemer when it is offered) is paid for a winning combo automatically, as soon as its last leg resolves: the combo leaves `GET /v3/wallets/{address}/combos` and the pUSD is in the trading wallet. An intent prepared for a combo that was just auto-redeemed ends `expired` with nothing executed.

## What the wallet signs

The combo order is the same kind of request as a Polymarket order on the newer exchange ([details](https://docs.kairos.trade/wallets/signing.md)):

* `eth_signTypedData_v4` on Polygon (`0x89`), an [ERC-7739](https://eips.ethereum.org/EIPS/eip-7739) `TypedDataSign`
* Domain `{ name: "Polymarket CTF Exchange", version: "3", chainId: 137, verifyingContract: 0xe3333700cA9d93003F00f0F71f8515005F6c00Aa }`
* `contents` is the `Order`: `maker` and `signer` are the trading wallet, `signatureType` is `3`, `tokenId` is the combo's YES position, `side` is `0` to buy and `1` to sell, `builder` and `metadata` are zero
* Price is `makerAmount / takerAmount` for a buy, `takerAmount / makerAmount` for a sell

Check before you prompt: the price is within what the user accepted, and `side` matches.

## Errors

| `code` | When | Traded? |
| - | - | - |
| `NO_QUOTES` | No maker priced the combo, often because a leg is in play | No |
| `SIZE_TOO_LARGE` | No maker takes this size | No |
| `PRICE_LIMIT` | The quote broke `maxPrice` or `minProceeds` | No |
| `SIGNATURE_EXPIRED` | Each of 4 quotes expired before its signature arrived | No |
| `VENUE_REJECTED` | Polymarket refused or did not fill the accepted quote | No |
| `ORDER_OUTCOME_UNKNOWN` | Polymarket did not confirm in time. The message names the RFQ | Maybe |

The first three come back as HTTP errors from `POST /v3/actions`. The others are on a `failed` step's `errorCode`. After `ORDER_OUTCOME_UNKNOWN`, read `/v3/wallets/{address}/combos` before you try again.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.