Natural-language compliance for cross-chain DeFi treasuries
"If utilization exceeds 85% or stablecoin deviation is above 2%, immediately withdraw and rebalance to the safest chain."
That sentence is all you need. Policy2Protocol turns it into a live, autonomous, cross-chain enforcement workflow.
Multi-chain treasuries are everywhere. The tooling isn't.
- Passive dashboards show numbers but don't act.
- Governance is slow — by the time a vote passes, the opportunity (or the risk) is gone.
- No verifiable compliance layer exists that autonomously monitors utilization, deviation, TVL, and APY across chains and acts when thresholds are breached.
Policy2Protocol lets DAOs and protocols describe treasury risk policies in plain English and converts them into autonomous, consensus-backed, cross-chain enforcement.
Plain English Policy
|
AI Parser (Claude)
|
Structured JSON Config
|
CRE Workflow (DON consensus)
|
On-chain Execution (CCIP cross-chain)
|
Verifiable Compliance Logs
A DAO risk manager types a policy in plain English:
"Monitor every 5 minutes. Rebalance to the highest-APR chain when the difference exceeds 50 basis points."
The AI layer (Claude) parses the natural language into a structured CRE workflow config — extracting schedule, thresholds, metrics, and whitelisted actions. Falls back to a deterministic rule-based parser if no API key is set.
The generated config drives a Chainlink Runtime Environment workflow:
- Cron-triggered on a schedule (e.g., every 5 minutes)
- Reads
currentLiquidityRatefrom lending pools on each configured chain - DON consensus evaluates whether policy conditions are met
- Encodes a
RebalanceParamsreport when thresholds are breached
The ProtocolSmartWallet receives the CRE report via Keystone forwarder:
- Withdraws funds from the source pool
- Sends cross-chain via CCIP to the destination chain
- Destination PSW automatically deposits into the higher-yield pool
Every action emits on-chain events (ReportReceived, MessageSent, MessageReceived) — queryable, immutable compliance logs.
+-------------------+
| Next.js Frontend |
| (Policy Input) |
+--------+----------+
|
POST /api/parse-policy
|
+--------v----------+
| AI Parser |
| (Claude / Rules) |
+--------+----------+
|
CRE Config JSON
|
+--------------+--------------+
| |
+--------v--------+ +--------v--------+
| CRE Workflow | | POST /api/deploy |
| (DON Consensus) | | (cre CLI) |
+--------+---------+ +-----------------+
|
Read APR per chain
Evaluate thresholds
Encode RebalanceParams
|
+--------v---------+
| PSW.onReport() |
| Withdraw from Pool|
+--------+----------+
|
CCIP Transfer
|
+--------v-----------+
| Destination PSW |
| Deposit into Pool |
+---------------------+
chainlink-cre/
├── frontend/ Next.js app — policy input, AI parse, deploy, logs, settings
├── contracts/ Foundry — MockPool, ProtocolSmartWallet, CCIP integration
├── workflow-ts/ CRE TypeScript workflow — cron, metrics, cross-chain rebalance
└── DEMO_GUIDE.md Step-by-step demo runbook
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, TypeScript, Tailwind CSS v4, RainbowKit, Wagmi |
| AI | Anthropic Claude (structured policy parsing) |
| Workflow | Chainlink CRE SDK, Bun, Viem, Zod |
| Contracts | Solidity 0.8.26, Foundry, OpenZeppelin 5.x |
| Cross-chain | Chainlink CCIP (token transfers + messaging) |
| Testnets | Ethereum Sepolia, Base Sepolia |
cd frontend
npm install
npm run dev
# Open http://localhost:3000Set environment variables in frontend/.env.local:
ANTHROPIC_API_KEY=sk-ant-... # optional — enables AI parsing
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=... # required — get one at cloud.walletconnect.comcd contracts
forge test -vvDeploy to testnets:
export PRIVATE_KEY=0x...
forge script scripts/multi-chain-token-manager/DeployTokenManagerContracts.s.sol \
--multi --broadcast --verify# Install CRE CLI
curl -sSL https://cre.chain.link/install.sh | bash
cd workflow-ts/workflow && bun install
cd ..
cre workflow simulate ./workflow --target staging-settings # test
cre workflow deploy ./workflow --target staging-settings # deploy| Chain | MockPool | ProtocolSmartWallet |
|---|---|---|
| Ethereum Sepolia | 0xC0a2EF140487C69B46eEC6e150018b82F791984e |
0x4561aAB2113F52Ae15063720fd771E17BF505B29 |
| Base Sepolia | 0xB4467F6331f0228Af9985f6bA2AF788FFdB880d9 |
0xb1D927779797E085De790f4bdf6Cb02da1fC8760 |
Asset: CCIP-BnM token | Deployer: 0xE2b39f4cfFA5B17434e47Ab5F54b984155e4b7aD
| Page | Route | What It Does |
|---|---|---|
| Landing | / |
Hero, protocol flow visualization, architecture cards, feature breakdown |
| Get Started | /get-started |
3-step flow: type policy in English -> review generated CRE config -> deploy workflow |
| Compliance Logs | /logs |
Live on-chain events from PSW contracts (ReportReceived, MessageSent, MessageReceived) |
| Settings | /settings |
Toggle chains and metric thresholds (persisted to localStorage) |
| Endpoint | Method | Purpose |
|---|---|---|
/api/parse-policy |
POST | Parses natural language policy into CRE workflow config JSON |
/api/policy-to-strategy |
POST | Converts structured policy JSON into CRE config with implementation steps |
/api/logs |
GET | Fetches real on-chain events from PSW contracts on all configured chains |
/api/deploy-workflow |
POST | Writes config and runs cre workflow deploy (local dev only) |
| Feature | Traditional | Policy2Protocol |
|---|---|---|
| Policy definition | Code or governance proposals | Plain English |
| Monitoring | Manual dashboards | Autonomous CRE cron |
| Decision making | Human or centralized bot | DON consensus (decentralized) |
| Execution | Single-chain scripts | Cross-chain via CCIP |
| Audit trail | Off-chain logs | On-chain events (verifiable) |
| Speed | Hours/days (governance) | Minutes (automated) |
This is a hackathon project / educational demo. Not production-ready.
- Contracts are unaudited examples — use audited contracts for production
- Keep API keys and private keys out of version control
- Use your own RPC endpoints for stable CRE deployment
- The AI parser is constrained to whitelisted metrics and actions only
MIT
Built with Chainlink CRE, CCIP, and Keystone