> For the complete documentation index, see [llms.txt](https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/core-concepts/policies.md).

# Policies

Policies are the heart of Black Sheep. Without them, an agent wallet is just a wallet. With them, it's a **budget**.

## Schema

```ts
type Policy = {
  daily_limit_usdc: number;        // 0–1,000,000
  max_tx_usdc: number;             // 0–1,000,000
  approval_threshold_usdc: number; // 0–1,000,000
  allowlist: string[];             // up to 50 base58 addresses; [] = any
};
```

## Evaluation order

For every `send` call, the server evaluates in this exact order. The **first** matching rule wins.

```
1. amount > max_tx_usdc                    → DENY
2. allowlist non-empty AND to ∉ allowlist  → DENY
3. sum(last 24h sends) + amount > daily    → DENY
4. amount ≥ approval_threshold_usdc        → REQUIRE_APPROVAL
5. otherwise                                → ALLOW
```

This evaluation runs **inside a server function with the wallet's owner context**. It cannot be bypassed by malformed clients, manipulated request bodies, or LLM prompt injection — the LLM only ever calls `send(to, amount)`. The numbers come from the database.

## Examples

### "Research bot" — small, frequent purchases

```ts
{
  daily_limit_usdc: 50,
  max_tx_usdc: 5,
  approval_threshold_usdc: 5,  // = max_tx → never auto-sends, every spend approved
  allowlist: [],
}
```

### "Vendor payer" — large but constrained

```ts
{
  daily_limit_usdc: 10_000,
  max_tx_usdc: 2_500,
  approval_threshold_usdc: 500,
  allowlist: ["7xKX...vendor1", "9pQR...vendor2"],
}
```

### "Auto-pilot" — fully autonomous (use with care)

```ts
{
  daily_limit_usdc: 200,
  max_tx_usdc: 25,
  approval_threshold_usdc: 1_000_000, // effectively off
  allowlist: ["7xKX...known-good"],
}
```

## Updating

Policies update **immediately**. In-flight approvals are not re-evaluated — they still settle against the policy that was in force when they were created.

## Edge cases

* `daily_limit_usdc = 0` blocks everything.
* `approval_threshold_usdc > max_tx_usdc` means approvals never trigger — every allowed tx auto-sends.
* Allowlist matches are exact, case-sensitive base58. No prefix or wildcard matching.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/core-concepts/policies.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
