reallocate, a curator-only MetaMorpho action. End-user deposits and withdrawals continue through the normal Morpho vault flow.
What This Demonstrates
- Exact calldata binding: the attestation is bound to the exact
reallocatecalldata your app encodes. - Composite policy checks: one Shield can enforce a Vaults.fyi-only policy or a Vaults.fyi + Chainalysis policy in a single evaluation.
- Onchain policy parameters:
setParams(...)writes the curator’s thresholds into the Shield-bound policy manifest. - Manager-action gating: the Shield clone must hold a MetaMorpho role that can call
reallocate.
Target Network
The public end-to-end Morpho examples use Base Sepolia (84532) with Newton prod, also called testnet production. Base Sepolia is used because the MetaMorpho V1.1 factory is deployed there for testnet curator flows.
Newton environments are separate stacks. Create the key from the Newton dashboard for the same environment your Shield uses. The public Base Sepolia example uses prod.
Install Packages
Every VaultKit Morpho integration needs VaultKit, Viem, policy-pack shared helpers, the policy packs you plan to enforce, and Morpho’s SDK:sendCall(...) escape hatch can encode calldata themselves, but the typed path below uses shield.morpho.reallocate(...).
Build the Composite Policy Pack
UsedefineComposite(...) with the modules deployed in your Newton policy. A Vaults.fyi-only policy looks like this:
getPolicyData() exactly. If the Shield is configured with a policy address that references a different module set, the SDK raises a typed configuration error before executing a vault action.
Create or Attach to a Shield
Create one Shield for the curator, vault, chain, policy pack, and version slot:createShield(...) is idempotent. It attaches to an existing compatible clone or deploys a new clone through ShieldFactory. If a previous run deployed a clone but did not finish writing policy params, pass a new version for a fresh clone or use skipPolicyBindingCheck only for a recovery run that immediately calls setParams(...).
Configure Params and Secrets
Write policy thresholds onchain and upload oracle secrets through Newton Gateway:Grant the Shield a Morpho Role
The Shield has two separate authorization gates:- Shield’s delegate gate controls who can call
executeorexecuteDirect. - MetaMorpho’s manager roles control what the forwarded call can do on the vault.
reallocate with its allocator-role check. The Shield clone must be one of:
- the vault curator,
- the vault owner, or
- an approved allocator.
setCurator(shield.policyClientAddress) or setIsAllocator(shield.policyClientAddress, true).
If the Shield can configure policy params but reallocate reverts, check this role first. Newton can approve the intent, but MetaMorpho will still reject the forwarded call if the Shield clone is not authorized on the vault.
Execute reallocate
With the Morpho overlay attached, call the typed action:
reallocate takes positional arguments: (vault, allocations, options?). Each allocation uses Morpho’s marketParams shape plus assets. For a Vaults.fyi + Chainalysis composite, include the per-call screening input your deployed pack expects under prepareQueryOptions.chainalysis. Omit it for a Vaults.fyi-only policy.
The returned result includes the onchain transaction hash and Newton task context. A successful run with allow: true means the full path worked: exact calldata, policy evaluation, attestation, and Shield execution.
Use shield.sendCall(...) only as an escape hatch for vendors or actions that VaultKit does not wrap yet. With sendCall, your integration owns calldata integrity.
Read-Only Versus Full Reproduce
You can validate most of a Morpho integration before granting a vault role:Vaults.fyi Testnet Data
Vaults.fyi indexes production networks, not testnets. When testing a Shield on Base Sepolia, a Vaults.fyi policy can fail closed because there is no testnet vault data for the lookup target. For demos, point the Vaults.fyi lookup at a real mainnet vault through the policy pack’s data-source override fields while the Shield still executes on Base Sepolia. In production, remove the override so the policy describes the same vault the Shield gates.Troubleshooting
Getting Started
Install VaultKit, configure a Shield, and execute a policy-gated vault action.
Errors
Review typed errors and retry guidance.