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

# Policies

A Policy is a lightweight contract that can inspect a node call and revert if a rule is violated (e.g., pause, cap, whitelist). Policies are attached to specific function selectors on a node. Whenever that selector executes, the node calls `policy.onCheck(caller, msg.data)`. Any revert in the policy reverts the underlying node call.

Which Policy contracts may be attached is controlled by the `NodeRegistry` via a Merkle root. Node owners can only attach policies included in that root for the given selector.

### Managing Policies on a Node

1. **Authorization:** The protocol owner sets `NodeRegistry.policiesRoot`, a Merkle root over `(function selector, policy address)` pairs. A node owner must supply a valid Merkle multi-proof when attaching policies.
2. **Attach:** `Node.addPolicies(proof, proofFlags, sigs, policies)` (owner only) validates the proof against the registry root and appends each policy under its selector. `PolicyAdded` events are emitted and `sigPolicy` is flagged.
3. **Detach:** `Node.removePolicies(sigs, policies)` (owner only) removes the mapping and emits `PolicyRemoved`.
4. **Inspect:** `Node.getPolicies(selector)` returns the ordered list of policies for a selector; `Node.isSigPolicy(selector, policy)` returns a boolean.
5. **Provide user data:** If a policy expects auxiliary data (e.g., Merkle proofs for whitelist), users call `Node.submitPolicyData(selector, policy, abi.encode(payload))` once. The policy caches the payload for that user/node pair and uses it on subsequent checks.

#### Commonly Guarded Node Functions

The current set of policies can fire on:

* `deposit`, `mint`, `requestRedeem`, `redeem`, `withdraw`
* `transfer`, `approve`, `transferFrom`
* `startRebalance`, `execute`, `payManagementFees`, `subtractProtocolExecutionFee`, `updateTotalAssets`
* `fulfillRedeemFromReserve`, `finalizeRedemption`, `setOperator`


---

# 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://nashpoint.gitbook.io/nashpoint/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.
