When it fires
outcomeIndex is negative, or greater than or equal to the market’s number of outcomes. Returned by POST /v1/trades, GET /v1/markets/{id}/quote and POST /v1/redemptions.
Why it happens
- You hard-coded
outcomeIndex: 1assuming a binary market and pointed it at a market with a different shape. - Off by one: the field is zero-indexed. The first outcome is
0, not1. - The index was computed from a label without a bounds check.
How to fix
- Fetch the market with
GET /v1/markets/{id}and checkoutcomes.length. The valid range is0tolength - 1. - Map outcome labels to indices once when you fetch the market, then use the index throughout your code.