# SDK Concepts \[How VaultKit 3.0 models policies, resolved modules, vendor extensions, intents, and verification.]

## Policy Sets

A Shield is gated by a policy set (Newton protocol 0.7): 1 to 8 `NewtonPolicy` contracts, each one Rego program plus at most one WASM oracle, evaluated as a fail-closed AND. A composite gives each oracle module its own policy, plus an optional pure-Rego `_policy` gate. A pack is an ingredient of a policy set, never an alternative to one.

## Policy Inputs and Resolved Policies

`createShield(...)` accepts either a `PolicyDraft` created with `definePolicy({ chainId, env }).with(...)`, together with each module's deployed policy in `policies`, or a `BarePolicy` created with `policyFromAddress(...)`.

After onchain resolution, both become a `ResolvedPolicy` exposed as `client.policy`. It contains the chain, the environment, the bound set as `policies` (`{ id, address }[]`, in set order), `modules`, and a bare policy's optional params codec.

## Policy Packs and Oracles

A policy pack is a typed TypeScript wrapper for one policy-data oracle. It provides schemas, deployment records, `prepareQuery(...)`, and metadata. Published `@newton-xyz/policy-pack-*` packages and locally authored `defineOracle(...)` values share this interface.

The pack npm packages ship only JavaScript, with no Rego or schemas. Each pack publishes its WASM per `(chainId, env)`, and you deploy each module's `NewtonPolicy` yourself from the pack's reference Rego and that WASM.

## Params, Secrets, and `wasmArgs`

* Params are curator-controlled configuration. Each policy stores its own slice onchain as that policy's `policyParams`.
* Secrets are encrypted locally and uploaded per module, scoped to that module's policy.
* `wasmArgs` are per-call evaluation inputs produced by each oracle's `prepareQuery(...)`. Each policy gets its own `wasm_args` entry; the gate gets `0x`.

Callers pass typed overrides under `prepareQueryOptions.<shortId>`. The policy pack, not the vendor module, owns the resulting `wasmArgs`.

## Vendor Modules and `.extend(...)`

```typescript
import { morphoActions } from '@newton-xyz/vaultkit/vendors/morpho'

const client = (await createShield(config)).extend(morphoActions)
await client.morpho.reallocate(vault, allocations)
```

| Import | Namespace | Scope |
| --- | --- | --- |
| `vendors/morpho` | `client.morpho.*` | MetaMorpho curator and allocator actions |
| `vendors/morpho-blue` | `client.morphoBlue.*` | Morpho Blue position operations for managed sleeves |
| `vendors/euler` | `client.euler.*` | Euler Earn manager and allocator actions |
| `vendors/euler-vault` | `client.eulerVault.*` | EVault governor actions |
| `vendors/superform` | `client.superform.*` | SuperVault strategy-manager actions and typed hooks |

`euler` and `eulerVault` are distinct APIs. Likewise, `morpho` targets MetaMorpho aggregation vaults while `morphoBlue` targets the Morpho Blue singleton.

## Generic Calls

`sendCall(...)` is the escape hatch for an unwrapped action:

```typescript
await client.sendCall({
  to,
  data,
  value,
  functionSignature: 'someManagerAction(uint256)',
  prepareQueryOptions,
})
```

With this method, your integration owns calldata integrity.

## Intent

An `Intent` binds the caller, target, value, calldata, chain, and human-readable function signature. Operators evaluate that exact action; the SDK rejects task and response data that do not match.

## Verification Ladder

Attachment verification is monotonic:

1. The clone's policy set is exactly the declared policies, matched by membership
2. Each module policy's WASM identity
3. Per-policy parameter decoding
4. Canonical byte equality against `expectedParams`

`client.verification` is a snapshot. Call `client.reverify()` after configuration changes; it also adopts the set's current order. A bare policy with no modules can satisfy the set and codec checks but does not prove that an oracle set exists.

## Blocked-Intent Assertions

`assertIntentBlocked(...)` expects a policy denial and confirms through `eth_call` that the denied attestation cannot execute. It is a negative assertion for integration tests and monitoring, not a transaction.

## Browser Safety

VaultKit core avoids `node:*` imports. A vendor SDK or custom oracle helper may introduce its own runtime requirements; check those dependencies before bundling for the browser.
