When it fires
outcomeIndex is greater than or equal to the market’s outcome count, or negative.
Why it happens
- You hard-coded
outcomeIndex: 1(assuming a binary market) and pointed at a multi-outcome market. - Off-by-one: the field is zero-indexed — first outcome is
0, not1. - A bug computed the index from a label without bounds-checking.
How to fix
- Look up the market via
GET /v1/markets/:idand checkoutcomes.length— valid range is[0, length - 1]. - Map outcome labels to indices once when you fetch the market, then use the index throughout your code.