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

# Redeeming

> Redeem winning shares after market resolution.

After a market resolves, holders of the winning outcome can redeem their shares for USDC.

***

## Basic Redeem

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> import { Transaction } from "@solana/web3.js";
>
> // Only works on resolved markets
> const instruction = await sdk.orica.buildRedeem(
>   wallet.publicKey,
>   userUsdcAccount,
>   marketAddress
> );
>
> const tx = new Transaction().add(instruction);
> const sig = await sendAndConfirmTransaction(connection, tx, [wallet]);
> console.log("Redeemed:", sig);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> from solana.transaction import Transaction
>
> # Only works on resolved markets
> instruction = await sdk.orica.build_redeem(
>     user=wallet.pubkey(),
>     user_usdc=user_usdc_account,
>     market_address=market_address,
> )
>
> tx = Transaction()
> tx.add(instruction)
> sig = await connection.send_transaction(tx, wallet)
> print(f"Redeemed: {sig}")
> ```

***

## Check Redemption Eligibility

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const market = await sdk.orica.fetchMarket(marketAddress);
> const position = await sdk.orica.fetchPosition(marketAddress, wallet.publicKey);
>
> // Check market is resolved
> if (market.status !== "resolved") {
>   console.log("Market not yet resolved");
>   return;
> }
>
> // Check user has winning shares
> if (!position) {
>   console.log("No position in this market");
>   return;
> }
>
> const winningOutcome = market.resolution?.outcome;
> if (!winningOutcome || !("index" in winningOutcome)) {
>   console.log("Market unresolvable or no clear winner");
>   return;
> }
>
> const winningIndex = winningOutcome.index.index;
> const winningShares = position.outcomeAmounts[winningIndex];
>
> if (winningShares.isZero()) {
>   console.log("No winning shares to redeem");
>   return;
> }
>
> console.log(`You have ${winningShares.toString()} winning shares!`);
> console.log(`Redemption value: $${winningShares.toNumber() / 1_000_000} USDC`);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> from orica_sdk import MarketStatus, OutcomeType
>
> market = await sdk.orica.fetch_market(market_address)
> position = await sdk.orica.fetch_position(market_address, wallet.pubkey())
>
> # Check market is resolved
> if market.status != MarketStatus.RESOLVED:
>     print("Market not yet resolved")
>     return
>
> # Check user has winning shares
> if not position:
>     print("No position in this market")
>     return
>
> if not market.resolution or market.resolution.outcome.outcome_type != OutcomeType.INDEX:
>     print("Market unresolvable or no clear winner")
>     return
>
> winning_index = market.resolution.outcome.index
> winning_shares = position.outcome_amounts[winning_index]
>
> if winning_shares == 0:
>     print("No winning shares to redeem")
>     return
>
> print(f"You have {winning_shares} winning shares!")
> print(f"Redemption value: ${winning_shares / 1_000_000} USDC")
> ```

***

## Redemption Flow

**1. Market Resolves**

Admin or dispute system resolves the market with a winning outcome.

**2. Check Position**

Verify you hold shares of the winning outcome.

**3. Build Redeem**

Build the redeem instruction.

**4. Execute**

Send the transaction to redeem your winnings.

**5. Receive USDC**

Each winning share is worth \$1 (minus redemption fee).

***

## Redemption Fees

A small redemption fee is deducted from your payout:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const globalState = await sdk.orica.fetchGlobalState();
> const feeBps = globalState.redemptionFeeBps;
>
> console.log(`Redemption fee: ${feeBps / 100}%`);
>
> // Calculate net payout
> const grossPayout = winningShares.toNumber(); // 1 USDC per share
> const fee = grossPayout * feeBps / 10000;
> const netPayout = grossPayout - fee;
>
> console.log(`Gross: $${(grossPayout / 1_000_000).toFixed(2)}`);
> console.log(`Fee: $${(fee / 1_000_000).toFixed(2)}`);
> console.log(`Net: $${(netPayout / 1_000_000).toFixed(2)}`);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> global_state = await sdk.orica.fetch_global_state()
> fee_bps = global_state.redemption_fee_bps
>
> print(f"Redemption fee: {fee_bps / 100}%")
>
> # Calculate net payout
> gross_payout = winning_shares  # 1 USDC per share
> fee = gross_payout * fee_bps // 10000
> net_payout = gross_payout - fee
>
> print(f"Gross: ${gross_payout / 1_000_000:.2f}")
> print(f"Fee: ${fee / 1_000_000:.2f}")
> print(f"Net: ${net_payout / 1_000_000:.2f}")
> ```

***

## Error Handling

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> try {
>   const instruction = await sdk.orica.buildRedeem(
>     wallet.publicKey,
>     userUsdcAccount,
>     marketAddress
>   );
>
>   const tx = new Transaction().add(instruction);
>   await sendAndConfirmTransaction(connection, tx, [wallet]);
> } catch (error) {
>   if (error.message.includes("MarketNotResolved")) {
>     console.error("Market has not been resolved yet");
>   } else if (error.message.includes("NoWinningPosition")) {
>     console.error("No winning shares to redeem");
>   } else if (error.message.includes("AlreadyRedeemed")) {
>     console.error("Position already redeemed");
>   } else {
>     throw error;
>   }
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> try:
>     instruction = await sdk.orica.build_redeem(
>         user=wallet.pubkey(),
>         user_usdc=user_usdc_account,
>         market_address=market_address,
>     )
>
>     tx = Transaction()
>     tx.add(instruction)
>     await connection.send_transaction(tx, wallet)
> except Exception as error:
>     if "MarketNotResolved" in str(error):
>         print("Market has not been resolved yet")
>     elif "NoWinningPosition" in str(error):
>         print("No winning shares to redeem")
>     elif "AlreadyRedeemed" in str(error):
>         print("Position already redeemed")
>     else:
>         raise
> ```

***

## Next Steps

> [card] [Disputes](https://docs.orica.markets/sdk/disputes.md)
>
> Challenge incorrect resolutions.

> [card] [Markets](https://docs.orica.markets/sdk/markets.md)
>
> Find more markets to trade.


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