Policies
Policies are rule-based controls that govern transaction execution. They can allow, deny, or require approval for intents based on flexible criteria.Policy Structure
Policy Rules
Agentic Wallet supports 11 rule types:Spending Limits
maxLamportsPerTx: Hard limit, transaction denied if exceededmaxLamportsPerDay: Cumulative daily limit, resets at UTC midnightrequireApprovalAboveLamports: Moves toapproval_gatestatus if exceeded
Address Controls
Address Allowlist
Only allow transfers to specific addresses.
Address Blocklist
Deny transfers to specific addresses.
Program and Token Controls
Program Allowlist
Restrict which Solana programs can be invoked.
Token Allowlist
Restrict token transfers to specific mints.
Protocol Allowlist
Rate Limiting
Time Windows
Slippage Control
Protocol Risk Rules
- maxSlippageBps: Protocol-specific slippage limit
- maxPoolConcentrationBps: Reject if pool is too concentrated
- allowedPools: Whitelist specific liquidity pools
- allowedPrograms: Restrict program IDs for this protocol
- oracleDeviationBps: Compare quoted price vs oracle, require approval if deviation exceeds threshold
Portfolio Risk Rules
- maxDailyLossLamports: Deny if projected loss exceeds limit
- maxDrawdownLamports: Deny if drawdown from high-water mark exceeds limit
- maxExposureBpsPerToken: Require approval if token concentration > limit (in bps)
- maxExposureBpsPerProtocol: Require approval if protocol exposure > limit
Portfolio risk checks require the caller to compute projected values and pass them in the evaluation request.
Policy Evaluation
Policies are evaluated before transaction execution:Evaluation Response
Evaluation Flow
Risk Tier Deduction
require_approval.
Policy Versioning
Policies use incremental versioning:Listing Versions
Retrieving Specific Version
Policy Migration
Migrate policies to new versions with transformations:Migration Modes
normalize (default)
normalize (default)
Validate and normalize existing rules without adding new ones.
add_default_risk_rules
add_default_risk_rules
Add default
protocol_risk and portfolio_risk rules if missing:Approval Gates
When a policy returnsrequire_approval, the transaction enters approval_gate status:
Manual Approval
failed status.
Pending Approvals
List all transactions awaiting approval:Compatibility Check
Validate rule compatibility before creating policies:Policy State Management
The policy evaluator maintains state for stateful rules:- rateLimitEvents: Rolling window of transaction timestamps per wallet/agent
- dailySpendByWallet: Cumulative spending per wallet per day (keyed by
walletId:YYYY-MM-DD)
Best Practices
Production Policies
Production Policies
- Always set spending limits for autonomous wallets
- Use address allowlists for high-value recipient addresses
- Combine multiple rule types for defense in depth
- Set rate limits to prevent runaway execution
- Use time windows for scheduled operations
- Enable protocol_risk rules for DeFi operations
- Monitor approval queue length
Policy Design
Policy Design
- Start with strict policies and relax as needed
- Use
requireApprovalAboveLamportsfor human oversight - Test policies with paper trades before live execution
- Version policies on every change for audit trail
- Document policy intent in the
namefield - Combine protocol_allowlist with protocol_risk for granular control
Security
Security
- Never disable all policies on production wallets
- Use program_allowlist to prevent malicious contract calls
- Set conservative oracle deviation thresholds
- Implement portfolio exposure limits
- Require approval for critical risk tier operations
- Audit policy changes and maintain version history
Source Code Reference
Policy functionality is implemented in:services/policy-engine/src/engine/policy-evaluator.ts- Evaluation engine (services/policy-engine/src/engine/policy-evaluator.ts:1)services/policy-engine/src/index.ts- Policy API (services/policy-engine/src/index.ts:1)packages/common/src/schemas/policy.ts- Rule type definitions (packages/common/src/schemas/policy.ts:1)