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

# Deposit & withdraw

> stake, the two-step unstake with cooldown or early unlock, and the views that tell you when funds are ready.

Deposits are one call; exits are deliberately two steps, so capital that underwrote live bets stays exposed until those bets resolve.

## Deposit

```text Flow theme={"theme":"css-variables"}
approve USDG → stake(assets) → (optional) setRewardMode(USD | CHANCE)
```

`stake` pulls USDG into the bankroll and credits your position. If public staking is disabled on the deployment, `stake` reverts `StakingDisabled` (deposits are operator-only); exits below still work for everyone.

## Withdraw — two steps

<Steps>
  <Step title="Request">
    Call `requestUnstake(assets)` for a fixed amount, or `requestUnstakeAll()` to exit the whole position (including rewards that compound in while you wait). Requested assets immediately stop underwriting new bets, but **stay staked and loss-exposed** until withdrawal. Repeat requests add to the total and restart the timer.
  </Step>

  <Step title="Wait for unlock">
    The request unlocks on the **earlier** of two paths:

    * **Settled watermark** — every bet your capital could have underwritten is settled or refunded (`settledThroughCommitId` reaches your request's epoch). Anyone can accelerate this by draining leftover bets with `settleBets`.
    * **Cooldown timer** — `unstakeDelay` elapses (default 1 hour) *and* every pre-request pending bet is refund-only, so nothing can socialize a new loss onto you.
  </Step>

  <Step title="Withdraw">
    Call `unstake(assets)`. The pool accrues your position first — losses socialized during the wait are applied before payout — and the withdrawal is capped by `availableBankroll()`. `cancelUnstakeRequest()` aborts at any point before this.
  </Step>
</Steps>

## Sizing and readiness

| View                            | Use                                                                                                                                                |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `withdrawableNow(staker)`       | USDG a `unstake` would pay **right now** — request cap, live position, and bankroll gate all applied. Size withdraw UIs with this, don't derive it |
| `unstakeUnlocked(staker)`       | `true` when the pending request can execute                                                                                                        |
| `previewStakerPosition(staker)` | Full position: assets, pending rewards, claimable CHANCE, lifetime counters                                                                        |
| `UnstakeRequested` event        | Carries `unlockAt` for the countdown; `SettledWatermarkAdvanced` signals the early unlock                                                          |

<Warning>
  Prefer `requestUnstakeAll()` for a full exit. A nominal `requestUnstake(currentBalance)` pins today's figure — USDG rewards that compound in during the cooldown fall outside the request and would need a second request and second cooldown.
</Warning>
