Specs / Auto-Vault Rule Engine

Auto-Vault Rule Engine

Made for Degens. By Degens.

Auto-Vault Rule Engine

Made for Degens. By Degens.

The Auto-Vault Rule Engine lets users configure flexible, automatic vault rules that move winnings into the casino's vault feature based on configurable triggers — before the urge to gamble them back kicks in.

---

The Problem It Solves

Winning is easy. Keeping the win is hard. Manual vaulting requires discipline in the exact moment you have the least of it. The rule engine automates the decision so the discipline is set once, not every hand.

---

Rule Types

1. percent_of_win

Vault a fixed percentage of every win.

2. fixed_per_threshold

Vault a fixed dollar amount for every X dollars won cumulatively.

3. balance_ceiling

Vault everything above a set balance ceiling.

4. session_profit_lock

Lock in your session profit once a target is hit.

---

Casino Support

| Casino | Vault Method | Notes |

|--------|-------------|-------|

| Stake.com | GraphQL API | Full native support, uses session cookie |

| Roobet | DOM-based | Finds and clicks the vault button |

| BC.Game | DOM-based | Targets "Safe" UI button |

| Rollbit | DOM-based | Targets vault/lock button |

| Gamdom | DOM-based | Targets save button |

| Shuffle | DOM-based | Targets vault button |

Casinos without a native vault feature are not supported. Rules scoped to unsupported casinos are silently skipped.

---

Architecture


CasinoWinEvent
    |
    v
VaultRuleEngine.evaluate(event)
    |-- filters by casino match
    |-- filters by min_win_amount
    |-- enforces cooldown_ms
    |-- per-rule type logic
    |
    v
VaultActionResult[]
    |
    v
CasinoAdapterRegistry.getAdapterForHost(hostname)
    |
    v
CasinoVaultAdapter.vaultAmount(amount)
    (StakeVaultAdapter | GenericDOMVaultAdapter)

State (running totals, last vault timestamps) persists in chrome.storage.local under vault_rule_state. Session-scoped rules (session_profit_lock) are cleared on session reset.

---

API Reference

List rules


GET /user/:discordId/vault-rules
Authorization: Bearer <token>

Create rule


POST /user/:discordId/vault-rules
Authorization: Bearer <token>
Content-Type: application/json

{
  "type": "percent_of_win",
  "casino": "all",
  "percent": 25,
  "min_win_amount": 2.00,
  "label": "Slots cleanup"
}

Update rule


PATCH /user/:discordId/vault-rules/:ruleId
Authorization: Bearer <token>

{ "enabled": false }

Delete rule


DELETE /user/:discordId/vault-rules/:ruleId
Authorization: Bearer <token>

---

Extension UI

The Vault tab in the extension popup provides:

---

Database Schema


CREATE TABLE user_vault_rules (
    id                UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id           TEXT NOT NULL,
    type              TEXT NOT NULL CHECK (type IN (
                          'percent_of_win', 'fixed_per_threshold',
                          'balance_ceiling', 'session_profit_lock'
                      )),
    enabled           BOOLEAN NOT NULL DEFAULT TRUE,
    casino            TEXT NOT NULL DEFAULT 'all',
    percent           NUMERIC(5,2),
    fixed_amount      NUMERIC(18,8),
    threshold_amount  NUMERIC(18,8),
    ceiling_amount    NUMERIC(18,8),
    profit_target     NUMERIC(18,8),
    min_win_amount    NUMERIC(18,8),
    cooldown_ms       INTEGER,
    label             TEXT,
    created_at        TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at        TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

---

Files

| File | Description |

|------|-------------|

| apps/chrome-extension/src/vault-rule-engine.ts | Core rule evaluation engine |

| apps/chrome-extension/src/casino-vault-adapters.ts | Casino-specific vault execution |

| apps/chrome-extension/src/popup.ts | Vault tab UI controller |

| apps/api/src/routes/user.ts | REST CRUD for vault rules |

| packages/db/src/queries.ts | DB query helpers |

| packages/types/src/index.ts | Shared TypeScript types |

| SCHEMA.sql | DB migration |

---

Limitations