How enzymefinance/protocol-onyx works
1. What this repository is
- Onyx is an EVM smart-contract system for tokenizing on-chain and off-chain value.
- The architecture is organized as a modular protocol rather than a single monolith: most business logic lives under src/components, with supporting infrastructure, factories, interfaces, and tests around it.
2. Core protocol shape
- The codebase is split into domain components such as issuance, fees, value, lists, roles, shares-transfer validation, and automations.
- This suggests a layered design where a central tokenized-asset protocol composes multiple policy modules instead of embedding all behavior into one contract.
3. Issuance subsystem
- src/components/issuance contains the mint/redeem lifecycle, with separate deposit-handlers and redeem-handlers.
- This is likely the main user-facing state transition path: assets enter through deposit handlers, shares are minted, and later shares are redeemed through redeem handlers.
4. Fee subsystem
- src/components/fees is split into management-fee and performance-fee trackers plus utility code and interfaces.
- The presence of trackers implies fees are accrued via accounting modules that observe positions/value over time, rather than being a simple per-transfer deduction.
- interfaces/ under fees indicates fee logic is pluggable or standardized across contracts.
5. Value and portfolio accounting
- src/components/value and src/components/value/position-trackers appear to handle valuation and position state.
- This is the accounting layer that other subsystems depend on: issuance and fees likely consume value/position data to determine share pricing, performance, or eligibility.
6. Shares and transfer controls
- src/shares and src/components/shares-transfer-validators indicate a dedicated share-token layer with transfer restrictions.
- The transfer validator boundary is important for compliance-style rules: share moves are not just ERC-20 transfers, but are mediated by policy contracts.
7. Lists, roles, and governance-like controls
- src/components/lists, src/infra/lists, and src/components/roles suggest configurable allowlists/denylists and role-based permissions.
- src/infra/lists/address-list looks like a lower-level list primitive used by higher-level policy modules.
- These controls likely gate issuance, redemption, transfers, and automation actions.
8. Automation and oracle integration
- src/components/automations/chainlink-cre suggests integration with Chainlink CRE for automated triggers or off-chain workflow execution.
- src/infra/oracles indicates a separate infrastructure layer for price or value inputs used by accounting or issuance logic.
- These integrations are external-data boundaries: they feed state or triggers into the protocol but are separated from core accounting.
9. Factories and deployable composition
- src/factories implies contracts are deployed through factory patterns, likely to instantiate configurable components or protocol instances.
- This fits the repo’s modular design: core logic is assembled into deployable systems rather than hard-coded as one fixed instance.
10. Shared utilities and global layer
- src/global and src/global/utils appear to provide cross-cutting helpers, constants, or shared abstract behavior.
- src/components/utils and src/utils likely contain reusable internal helpers that are not domain-specific.
- These layers reduce duplication across issuance, fees, lists, and other modules.
11. Interfaces and boundary definition
- src/interfaces and src/interfaces/external define the protocol’s public and third-party integration surfaces.
- This is the main contract boundary layer for architecture diagrams: internal modules call each other through these interfaces, and external integrations are isolated here.
12. Testing and verification
- test/ contains harnesses, mocks, interfaces, and utilities, showing the repo is structured for unit/integration-style contract testing.
- The presence of slither.config.json, slither.db.json, and audit artifacts under audits/ indicates security review is a first-class concern.
13. Tooling and runtime
- The repository is built for Foundry (foundry.toml, forge build, forge test) and uses vendored OpenZeppelin upgradeable contracts.
- That implies the runtime is Solidity/EVM, with upgradeable-contract patterns likely influencing how components are composed and initialized.
14. High-level data flow
- Typical flow appears to be: external actor interacts with issuance or share-transfer entrypoints → permission/list/validator checks run → value/oracle/position data is consulted → shares or assets are minted, redeemed, or transferred → fee trackers update accounting state → automation/oracle hooks may react to events or thresholds.
- For an architecture diagram, the main boundaries are: protocol entrypoints, policy/permission modules, accounting/value modules, and external integration adapters.
15. Operational and project structure
- CI is enforced via GitHub Actions in .github/workflows, and the repo includes security-related documentation and audit records.
- Licensing is source-available BUSL-1.1 for first-party code, with vendored dependencies retaining their original licenses.
Main entry points: issuance Issuance · shares-transfer-validators Transfer guards · fees Fees · value Value
Components 23
Core protocol
Primary tokenized-asset logic and policy modules.
- Issuance · Mint and redeem lifecycle for tokenized value.
src/components/issuance - Deposit hooks · Deposit-side handlers that drive mint entrypoints.
src/components/issuance/deposit-handlers - Redeem hooks · Redeem-side handlers that drive exit entrypoints.
src/components/issuance/redeem-handlers - Fees · Management and performance fee accounting.
src/components/fees - Mgmt trackers · Tracks management-fee accrual over time.
src/components/fees/management-fee-trackers - Perf trackers · Tracks performance-fee accrual from value changes.
src/components/fees/performance-fee-trackers - Value · Portfolio and pricing inputs used across the protocol.
src/components/value - Position trackers · Maintains position-level accounting state.
src/components/value/position-trackers - Transfer guards · Validates share transfers against protocol rules.
src/components/shares-transfer-validators - Lists · Allowlist and denylist style controls.
src/components/lists - Roles · Role-based permissions for privileged actions.
src/components/roles - Chainlink CRE · Automation trigger integration for off-chain or scheduled workflows.
src/components/automations/chainlink-cre
Support layer
Shared infrastructure, adapters, factories, and interfaces.
- Shares · Share token and transfer surface for the protocol.
src/shares - Factories · Deploys configurable protocol instances and components.
src/factories - Interfaces · Internal protocol interfaces and shared contract definitions.
src/interfaces - External APIs · Third-party and externally consumed interfaces.
src/interfaces/external - Oracles · External pricing and value feeds used by accounting and issuance.
src/infra/oracles - Address list · Low-level list primitive used by higher-level policy modules.
src/infra/lists/address-list - Comp utils · Reusable helpers shared across protocol components.
src/components/utils - Global · Cross-cutting constants and shared abstractions.
src/global - Global utils · Common utilities shared across the codebase.
src/global/utils
Connections 30
- Issuance → Deposit hooks: uses · Deposit handlers implement mint entrypoints.
- Issuance → Redeem hooks: uses · Redeem handlers implement exit entrypoints.
- Issuance → Value: prices with · Issuance consults valuation for share pricing.
- Issuance → Lists: gates by · Entry and exit paths can be restricted by list policy.
- Issuance → Roles: requires · Privileged issuance actions depend on roles.
- Issuance → Fees: accrues · Mint and redeem flows update fee accounting.
- Fees → Mgmt trackers: tracks · Management fees are accumulated by dedicated trackers.
- Fees → Perf trackers: tracks · Performance fees are accumulated by dedicated trackers.
- Fees → Value: reads · Fee logic depends on portfolio value and performance.
- Value → Position trackers: maintains · Valuation uses position-level accounting state.
- Value → Oracles: consumes · External price feeds inform valuation.
- Transfer guards → Shares: guards · Transfers are mediated through share-token boundaries.
- Transfer guards → Lists: checks · Transfer policy can reference allow/deny lists.
- Transfer guards → Roles: checks · Role constraints can affect transfer permissioning.
- Transfer guards → Value: consults · Validation may depend on account or portfolio state.
- Lists → Address list: built on · Higher-level list policy uses address-list primitives.
- Chainlink CRE → Oracles: reacts to · Automation is driven by external data or conditions.
- Factories → Issuance: deploys · Factories assemble issuance-capable protocol instances.
- Factories → Fees: deploys · Factories wire fee modules into deployments.
- Factories → Transfer guards: deploys · Factories configure transfer policy modules.
- Interfaces → Issuance: defines · Interfaces describe protocol contracts and boundaries.
- Interfaces → Fees: defines · Interfaces describe fee-module contracts.
- Interfaces → Transfer guards: defines · Interfaces describe transfer-validator boundaries.
- External APIs → Oracles: adapts · External integration surfaces include oracle-style contracts.
- Comp utils → Issuance: supports · Shared helpers reduce duplication in core modules.
- Comp utils → Fees: supports · Shared helpers reduce duplication in fee modules.
- Global → Global utils: contains · Global layer provides reusable utility functions.
- Tests → Interfaces: verifies · Tests exercise the public contract surfaces.
- Tests → Issuance: verifies · Tests cover mint and redeem flows.
- Audits → Transfer guards: reviews · Audit artifacts focus on policy and validator behavior.