# Staking Rewards

Understand and distribute INDY staking rewards on Indigo Protocol.

## How Rewards Work

INDY stakers earn ADA rewards from protocol fees generated by CDP operations (opening, minting, liquidations). Rewards accumulate in collector UTxOs and must be distributed to staking positions via the `distribute_staking_rewards` tool. See [Reward Calculation](../references/reward-calculation.md) for details.

## MCP Tools

### distribute_staking_rewards

Trigger distribution of pending ADA rewards from collector UTxOs to staking position holders. Anyone can call this tool — it is a permissionless on-chain action that processes pending rewards for all stakers.

**Parameters:** None

**Returns:** Transaction CBOR to be signed and submitted.

**Example — Distribute pending rewards:**

```
User: "Distribute staking rewards"

Tool call: distribute_staking_rewards()

Response:
{
  "tx": "84a400...",
  "totalDistributed": 150.5,
  "positionsUpdated": 42,
  "fee": "0.35 ADA"
}
```

**Example — Check and distribute:**

```
User: "Are there any pending staking rewards to distribute?"

Step 1 — get_collector_utxos()
         => [{ "asset": "ADA", "amount": 250.0 }, ...]

Step 2 — If collector UTxOs contain pending ADA:
         distribute_staking_rewards()

Response:
{
  "tx": "84a400...",
  "totalDistributed": 250.0,
  "positionsUpdated": 58,
  "fee": "0.38 ADA"
}
```

### Checking Accrued Rewards

To see how much ADA a staker has earned, query their positions:

```
User: "How much have I earned from staking?"

Tool call: get_staking_positions_by_owner({ owner: "stake1u8a..." })

Response:
[
  {
    "address": "addr1q...",
    "stakedIndy": 5000,
    "accruedRewards": 42.5
  }
]

=> "You have 42.5 ADA in accrued staking rewards."
```

### Collector UTxO Handling

Rewards flow through collector UTxOs before distribution. The `get_collector_utxos` tool (from indigo-analytics) shows pending protocol fees waiting to be distributed:

```
User: "Show me the collector UTxOs"

Tool call: get_collector_utxos()

Response:
[
  { "asset": "ADA", "amount": 320.0, "address": "addr1c..." },
  { "asset": "ADA", "amount": 85.0, "address": "addr1c..." }
]

=> "405 ADA in collector UTxOs is available for staking reward distribution."
```

When collector UTxOs accumulate enough ADA, calling `distribute_staking_rewards` processes them and credits each staking position proportionally based on their share of total staked INDY.

## Common Prompts

- "Distribute staking rewards"
- "Trigger INDY staking reward distribution"
- "Are there pending staking rewards?"
- "How much have I earned from staking?"
- "Show me the collector UTxOs"
- "What rewards are waiting to be distributed?"