Institutional-grade compliance layer for a regulated zk-validium blockchain built on Polygon CDK / zkSync-style stack.
Lunos implements token-scoped compliance enforcement entirely at the smart contract layer. No modifications to the EVM execution engine, zk circuits, sequencer, or prover are required.
┌─────────────────────────────────────────────────────────────────┐
│ Governance Multisig │
│ (GovernanceExecutor) │
└──────┬──────────────┬──────────────────┬───────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────────┐
│ Jurisdiction │ │ Approved │ │ Compliance │
│ Registry │ │ Attestors │ │ Registry │
│ │ │ │ │ │
│ jurisdiction │ │ attestor │ │ wallet→juris→cred │
│ IDs (1=EU…) │ │ whitelist │ │ + pending updates │
└──────────────┘ └──────────────┘ └────────┬──────────┘
│
▼
┌─────────────────┐
│ Compliance │
│ Manager │
│ │
│ validateTransfer│
│ (view only) │
└────────┬────────┘
│
┌────────────────────────┤
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ RestrictedToken │ │ TokenTransfer │
│ │◄──│ Matrix │
│ ERC20 + compliance│ │ │
│ _update() hook │ │ from→to→allowed │
└──────────────────┘ └──────────────────┘
▲
│
┌──────────────────┐
│ RestrictedToken │
│ Factory │
│ │
│ deploys proxies │
└──────────────────┘
| Contract | Path | Responsibility |
|---|---|---|
| JurisdictionRegistry | contracts/core/ |
Canonical jurisdiction IDs (immutable once created) |
| ApprovedAttestors | contracts/core/ |
Whitelisted KYC provider addresses |
| ComplianceRegistry | contracts/core/ |
Wallet credentials with timelocked updates |
| ComplianceManager | contracts/core/ |
View-only transfer validation engine |
| Contract | Path | Responsibility |
|---|---|---|
| RestrictedToken | contracts/token/ |
ERC20 with compliance in _update() |
| TokenTransferMatrix | contracts/token/ |
Jurisdiction-to-jurisdiction compatibility |
| RestrictedTokenFactory | contracts/token/ |
Deploys new token + matrix proxy pairs |
| Contract | Path | Responsibility |
|---|---|---|
| GovernanceExecutor | contracts/governance/ |
Multisig execution wrapper for system calls |
| Contract | Path | Responsibility |
|---|---|---|
| DIDRegistry | contracts/did/ |
Optional decentralized identity anchor |
| FeeManager | contracts/fees/ |
Future fee routing (issuer, attestation, protocol) |
- Governance adds jurisdiction IDs via
JurisdictionRegistry.addJurisdiction() - Governance approves attestors via
ApprovedAttestors.addAttestor() - Attestor submits credential via
ComplianceRegistry.submitCredential() - Credential enters pending state:
effectiveBlock = block.number + globalCredentialDelay - After delay,
resolveCredential()activates the credential
When RestrictedToken.transfer() is called:
_update()is invoked (OpenZeppelin ERC20 hook)_enforceCompliance(from, to)executes before balance mutation- Pending credentials are resolved lazily via
ComplianceRegistry.resolveCredential() - Wallet jurisdictions are looked up from
walletJurisdictionmapping - Token checks both jurisdictions are in
acceptedJurisdictions ComplianceManager.validateTransfer()checks:- Credentials active
- Credentials not expired (
block.timestamp < expiry) - Credential levels ≥
requiredLevel - Jurisdictions registered
TokenTransferMatrix.matrixAllows()checks jurisdiction compatibility- If any check fails →
ComplianceCheckFailedevent + revert - If all pass →
super._update()executes the balance mutation
Hierarchical levels stored as uint8:
- 1 = Retail
- 2 = Accredited
- 3 = Institutional
Higher levels satisfy lower requirements (e.g., Institutional satisfies Accredited).
| Domain | Controller | Applies To |
|---|---|---|
| Global Delay | Governance | Credential issuance, updates, revocations |
| Token Delay | Issuer | Matrix updates, token-specific rules |
Resolution: effectiveBlock = block.number + delay
Pending updates activate lazily during reads.
User Transfer → RestrictedToken._update()
│
├── ComplianceRegistry.resolveCredential(sender)
├── ComplianceRegistry.resolveCredential(receiver)
├── Check acceptedJurisdictions
├── ComplianceManager.validateTransfer()
│ ├── ComplianceRegistry.getCredential(sender)
│ ├── ComplianceRegistry.getCredential(receiver)
│ ├── Check active, expiry, level
│ └── JurisdictionRegistry.jurisdictionExists()
├── TokenTransferMatrix.matrixAllows()
└── super._update() [balance mutation]
- Compliance before mutation — All checks execute before
super._update() - Irreversible compliance —
complianceEnabledcannot be set to false - Timelock enforcement — All credential/matrix changes respect delays
- Attestor exclusivity — Only approved attestors issue credentials
- Expiry enforcement — Expired credentials always fail validation
- O(1) lookups — No loops, all checks via mapping lookups
- zk-compatible — No oracles, no async, deterministic execution only
contracts/
├── core/
│ ├── ComplianceManager.sol
│ ├── ComplianceRegistry.sol
│ ├── JurisdictionRegistry.sol
│ └── ApprovedAttestors.sol
├── token/
│ ├── RestrictedToken.sol
│ ├── TokenTransferMatrix.sol
│ └── RestrictedTokenFactory.sol
├── governance/
│ └── GovernanceExecutor.sol
├── did/
│ └── DIDRegistry.sol
├── fees/
│ └── FeeManager.sol
└── interfaces/
├── IComplianceManager.sol
├── IComplianceRegistry.sol
├── IJurisdictionRegistry.sol
├── IRestrictedToken.sol
└── IAttestor.sol
test/
├── compliance/
│ ├── ComplianceRegistry.t.sol
│ └── ComplianceManager.t.sol
└── tokens/
├── RestrictedToken.t.sol
└── TokenTransferMatrix.t.sol
script/
├── DeployCore.s.sol
└── DeployToken.s.sol
audit/
├── checklist.md
├── invariants.md
└── known-risks.md
forge install OpenZeppelin/openzeppelin-contracts-upgradeable
forge install foundry-rs/forge-stdforge buildforge test# Deploy core infrastructure
forge script script/DeployCore.s.sol --rpc-url <RPC_URL> --broadcast
# Deploy token infrastructure
forge script script/DeployToken.s.sol --rpc-url <RPC_URL> --broadcastEnterprise nodes should index these events for compliance monitoring:
| Event | Contract | Purpose |
|---|---|---|
CredentialScheduled |
ComplianceRegistry | New/updated credential pending |
CredentialActivated |
ComplianceRegistry | Credential became active |
CredentialRevoked |
ComplianceRegistry | Credential revocation scheduled |
MatrixUpdateScheduled |
TokenTransferMatrix | Matrix change pending |
MatrixUpdateActivated |
TokenTransferMatrix | Matrix change activated |
RestrictedTokenTransfer |
RestrictedToken | Compliant transfer completed |
ComplianceCheckFailed |
RestrictedToken | Transfer rejected |