# PrizeBuyer

`contracts/src/PrizeBuyer.sol` — converts a round's ETH pot into the prize stock token
at claim time and delivers it **straight to the winner**. Stateless: holds no funds
between calls.

## Flow

```mermaid
sequenceDiagram
    participant DM as DrawManager
    participant PB as PrizeBuyer
    participant W as WETH9
    participant R as Uniswap V3 SwapRouter
    participant Win as Winner

    DM->>PB: buyFor{value: pot}(prizeToken, winner, poolFee, minAmountOut)
    PB->>W: deposit (wrap ETH)
    PB->>R: exactInputSingle(WETH → prizeToken, recipient = winner)
    R->>Win: prize stock tokens
```

## Interface

```solidity
function buyFor(address prizeToken, address recipient, uint24 poolFee, uint256 minAmountOut)
    external payable returns (uint256 amountOut)
```

| Param | Meaning |
|---|---|
| `prizeToken` | Tokenized stock to buy (NVDA, TSLA, …) |
| `recipient` | The winner — swap output is delivered directly, never held |
| `poolFee` | Uniswap V3 fee tier of the WETH/prizeToken pool |
| `minAmountOut` | Slippage floor. The keeper quotes off-chain when settling on a winner's behalf; a self-claiming winner sets their own tolerance |

Both immutables (`weth`, `router`) are set at deployment. Reverts with `NoValue()` on
a zero-value call.

## MEV considerations

The prize swap is a large, predictable buy — a sandwich target. Defenses:

* `minAmountOut` bounds the damage; the claimer chooses it from a fresh off-chain quote.
* `deadline = block.timestamp` prevents the transaction from executing stale out of
  the mempool (though on a first-party-sequencer chain, ordering trust dominates).
* Pool depth for each prize token is measured before it is configured as a prize
  (dry-run checklist item).

If the WETH/prizeToken pool is too shallow for a given pot, the round can instead be
configured with `prizeToken = address(0)` to pay raw ETH.
