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

# Vault Scripts

> create-darkpool-vault, vault-deposit, keeper-tick.

## `create-darkpool-vault`

One PTB: `balance_manager::new` to `mint_trade_cap` to `dark_pool::create_vault<DUSDC>` wired to a scaffolded binary market from `registry.json`. Shares the vault + BalanceManager; keeps TradeCap + VaultAdminCap with the keeper (sender).

```bash theme={"system"}
pnpm tsx scripts/create-darkpool-vault.ts \
  --market wc26_euro_champion \
  --min-deposit 1000000 \
  --execute
```

**Flags**

| Flag            | Required | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| `--market`      | yes      | Slug from `.binary-markets/registry.json`           |
| `--min-deposit` | yes      | Minimum deposit in micro DUSDC (1\_000\_000 = \$1)  |
| `--label`       | no       | Override the vault label (defaults to market label) |
| `--execute`     | no       | Sign + submit                                       |

Prints `VAULT_OBJECT_ID`. Paste into `.env`.

## `vault-deposit`

Deposits DUSDC into a `DarkPoolVault` with the exact PTB shape the frontend uses (split to `dark_pool::deposit` to receipt to sender). Smoke test + demo TVL seeder.

```bash theme={"system"}
pnpm tsx scripts/vault-deposit.ts --amount 2 --execute
```

**Flags**

| Flag        | Required | Description                |
| ----------- | -------- | -------------------------- |
| `--amount`  | yes      | Whole DUSDC amount         |
| `--vault`   | no       | Override `VAULT_OBJECT_ID` |
| `--execute` | no       | Sign + submit              |

Passes `attribution_hash` as 32 zero bytes (Seal off). Frontend does the same.

## `keeper-tick`

One vault keeper tick. Idempotent.

```bash theme={"system"}
pnpm tsx scripts/keeper-tick.ts --execute                 # all idle balance
pnpm tsx scripts/keeper-tick.ts --amount 5 --ask 0.55 --execute
```

**Market open path** (state == OPEN):

```text theme={"system"}
dark_pool::pull_for_mint
  -> settlement::mint_pair
  -> balance_manager::deposit (YES + NO)
  -> dark_pool::record_mint
-> [optional] pool::place_limit_order POST_ONLY (YES + NO asks) via TradeCap
```

V3 ask leg is auto-gated on `yesPoolId` / `noPoolId` existing in the registry. Quotes `roundLot(held × 100/105)` to leave 5% input-token fee headroom.

**Market resolved path** (after `mark_resolved`):

```text theme={"system"}
cancel V3 orders
  -> balance_manager::withdraw_all (YES + NO + idle DUSDC)
  -> settlement::redeem_{yes,no}
  -> dark_pool::receive_settlement
-> state -> SETTLED
```

**Flags**

| Flag        | Required | Description                                      |
| ----------- | -------- | ------------------------------------------------ |
| `--amount`  | no       | Override pull amount (default: all idle balance) |
| `--ask`     | no       | Override ask price for V3 asks (default: 0.55)   |
| `--execute` | no       | Sign + submit                                    |
