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

# Treasury

> Generic native-funds custodian for one principal. Holds bet stakes, routes them to yield adapters, recalls them on demand.

Source: [`packages/contracts/src/yield/Treasury.sol`](https://github.com/rstfulzz/signalium/blob/main/packages/contracts/src/yield/Treasury.sol)

The Treasury is deliberately generic — not coupled to `PredictionMarket` — so the same implementation can serve any future market type. One Treasury per principal; the principal address is **immutable** and the only address allowed to call `recallToPrincipal`.

## Roles

| Role        | Set at                                   | Powers                                                                 |
| ----------- | ---------------------------------------- | ---------------------------------------------------------------------- |
| `owner`     | constructor; rotatable via `setOwner`    | Adapter allowlist (`enable`/`disable`), `setReserveBps`, `setOperator` |
| `operator`  | constructor; rotatable via `setOperator` | `deployIdle`, `requestUnstake`, `claimFrom`                            |
| `principal` | **immutable**                            | Sole caller of `recallToPrincipal`                                     |

## Reserve floor

```solidity theme={null}
uint256 public reserveBps = 5_000; // default 50%
```

Every `deployIdle(adapter, amount)` enforces:

```solidity theme={null}
idleAfter = address(this).balance − amount
minIdle  = totalAssets() × reserveBps / BPS
require(idleAfter >= minIdle, WouldBreachReserve);
```

So at most half the float can be in adapters at any time. Owner-tunable.

## Adapter lifecycle

`enableAdapter` checks the adapter reports this Treasury as its principal and uses native asset only (`asset() == address(0)`). Subsequent `disableAdapter` requires `deployedTo == 0 && totalAssets() == 0 && pendingClaim() == 0` — strand-prevention so funds never silently drop out of accounting.

## Reentrancy + gates

All native-sending paths (`deployIdle`, `requestUnstake`, `claimFrom`, `recallToPrincipal`) carry an explicit `nonReentrant` modifier. State writes happen before the external call in every case; the guard is belt-and-suspenders.
