Skip to content

Architecture

Status: Canonical architecture (mav diagram + Phase-1 reality)
Date: 2026-07-11
Authority: docs/00-product-constitution.md · docs/00-product-scope-correction.md
Brand: DAY · dayprotocol.com · Limitless Labs

Product: agent-native yield router — markets → route → optional Auto Yield → harvest → Auto Pay.
Not product core: vaults / SuperVaults / “deposit into our vault.”


Copy into mermaid.live to render.

flowchart TB
subgraph UserLayer["User / Agent Layer"]
A[AI Agents / Characters]
B[Developers / dApps]
C[SDK - TypeScript / Python]
end
subgraph OrchestratorLayer["Orchestrator Layer (Offchain)"]
D[Orchestrator Agent]
E[Decision Engine<br/>Goal-based Routing]
F[Data Fetcher<br/>Discovery + adapter reads]
AP[Auto Pay policy]
end
subgraph OnchainLayer["Onchain Execution Layer"]
subgraph Sui["Sui Chain — Phase 1 home"]
G1[YieldRouter]
H1[AdapterRegistry]
I1[Adapters<br/>Suilend, NAVI, Scallop, Haedal...]
end
subgraph Solana["Solana Chain — Phase 1 home"]
G2[YieldRouter]
H2[AdapterRegistry]
I2[Adapters<br/>Kamino, marginfi, Jito...]
end
subgraph Base["Base — bridge-in / discovery"]
G3[YieldRouter later]
H3[AdapterRegistry later]
I3[Adapters later<br/>Morpho, Aave...]
end
subgraph Arbitrum["Arbitrum — expansion"]
G4[YieldRouter later]
H4[AdapterRegistry later]
I4[Adapters later]
end
end
subgraph DataLayer["Data Layer"]
J[DefiLlama map optional]
K[Adapter read_apy truth]
X[x402 pay path optional]
end
subgraph CrossChain["Cross-Chain Layer"]
L[Mayan compose<br/>CCTP / Wormhole under the hood]
end
A --> C
B --> C
C --> D
D --> E
E --> F
E --> AP
F --> J
F --> K
AP --> X
E --> G1
E --> G2
E -.->|not Phase-1 home| G3
E -.->|not Phase-1 home| G4
G1 --> H1
H1 --> I1
G2 --> H2
H2 --> I2
G3 --> H3
H3 --> I3
G4 --> H4
H4 --> I4
I1 --> L
I2 --> L
I3 --> L
I4 --> L
L --> G1
L --> G2
classDef user fill:#e3f2fd,stroke:#1976d2
classDef offchain fill:#fff3e0,stroke:#f57c00
classDef onchain fill:#e8f5e9,stroke:#388e3c
classDef data fill:#f3e5f5,stroke:#7b1fa2
classDef xchain fill:#eceff1,stroke:#546e7a
class A,B,C user
class D,E,F,AP offchain
class G1,G2,G3,G4,H1,H2,H3,H4,I1,I2,I3,I4 onchain
class J,K,X data
class L xchain
flowchart LR
SDK["@dayprotocol/sdk"] --> API["DAY API / Orchestrator"]
API --> Disc["Discovery map<br/>DefiLlama"]
API --> Truth["read_apy<br/>venue adapters"]
API --> Plan["prepare plans"]
Plan --> SuiR["Sui YieldRouter path"]
Plan --> SolR["Solana YieldRouter path"]
Base["Base USDC"] -->|Mayan| SuiR
Base -->|Mayan| SolR
SuiR --> AdS["Suilend / NAVI / …"]
SolR --> AdL["Kamino / Jito / …"]
AdS --> Harvest["harvest + fee (see /fees/)"]
AdL --> Harvest
Harvest --> AutoPay["Auto Pay residual"]

LayerComponentsResponsibility
User / AgentSDK, AI agents, dAppsCall DAY without custody
Orchestrator (offchain)Decision engine, data fetcher, Auto Pay policyGoal → route plan; prepare/execute gates
Onchain executionYieldRouter, AdapterRegistry, Adaptersdeposit / withdraw / harvest / fee math
DataDefiLlama map + adapter read_apy; optional x402Discovery ≠ truth
Cross-chainMayan compose (not DIY multi-AMB)Fund Phase-1 homes; credit after delivery

ComponentDescriptionWhere
YieldRouterEntry for route/stake/unstake/harvest under owner policyOnchain per execution home (Sui, Sol first)
AdapterRegistryAllowlisted protocols + readinessOnchain + offchain registry mirror (form-registry)
Adapters (Forms)Thin connectors to venuesOnchain wrappers + offchain planners today
OrchestratorGoal-based routing, enablement, kill switchOffchain (/api/day/*)
Auto PayPost-fee residual → storage / inference / x402Offchain policy + optional pay rails
Gas sponsorPlan/size gas fronting for agent txsOffchain plan → onchain when enabled
BridgeMayan Base/Eth/Sol/Sui → Sui|SolPlan + delivery + rescue (S7/S8)
SwapTurbos (Sui), Jupiter (Sol)Plan now; live when wired

4. Alignments / corrections vs first sketch

Section titled “4. Alignments / corrections vs first sketch”
SketchDAY reality
Wormhole / LayerZero as product layerCompose Mayan (uses CCTP/Wormhole under the hood). Do not reimplement multi-AMB.
Base + Arbitrum as full homesPhase 1 execution homes = Sui + Solana. Base = bridge-in / treasury. Arb = expansion backlog.
x402 as primary yield data busDiscovery = DefiLlama map; truth = adapter read_apy. x402 = payments / optional paid data.
Vault productOut of scope — see docs/00-product-scope-correction.md
CharactersConsumers of DAY, not the product core

5.1 Deposit / route (Auto Yield OFF default)

Section titled “5.1 Deposit / route (Auto Yield OFF default)”
sequenceDiagram
participant Agent
participant SDK
participant Orch as Orchestrator
participant Router as YieldRouter
participant Reg as AdapterRegistry
participant Ad as Adapter Form
participant Venue as External venue
Agent->>SDK: goal + amount + policy
SDK->>Orch: preview / prepare
Orch->>Orch: allowlist + readiness + read_apy
Orch-->>SDK: plan (no invent APY)
Agent->>SDK: execute (owner opt-in if stake)
SDK->>Router: deposit/route
Router->>Reg: resolve adapter
Reg->>Ad: supply
Ad->>Venue: protocol supply
Venue-->>Agent: position at venue / receipt
sequenceDiagram
participant Anyone as Keeper / agent
participant Orch as Orchestrator
participant Router as YieldRouter
participant Ad as Adapter
participant Venue
Anyone->>Orch: harvest trigger
Orch->>Router: harvest plan
Router->>Ad: claim / realize yield
Ad->>Venue: claim_yield / exchange rate
Venue-->>Router: gross yield
Router->>Router: apply fee schedule (see /fees/)
Router->>Router: survival bills optional
Router-->>Orch: residual
Orch->>Orch: Auto Pay residual only
sequenceDiagram
participant Owner
participant Orch
participant Mayan
participant Home as YieldRouter home
Owner->>Orch: bridge plan Base→Sui|Sol
Orch->>Mayan: compose rail
Mayan-->>Home: delivery
Orch->>Orch: actualReceived vs minOut
alt actual >= minOut
Orch->>Home: credit actual
else under minOut / failed
Orch->>Owner: rescue destination = owner
end

Diagram pieceCode today
SDKpackages/sdk @dayprotocol/sdk
Orchestrator / APIapi/server.mjs, api/handlers.mjs
Decision / scorerruntime/scorer/*, runtime/discovery/*
Adapter registryruntime/adapters/form-registry.mjs
Venue adaptersruntime/adapters/*, XEL suilend/navi live path
Bridge / swap / gasruntime/bridge/*, runtime/gas/*
Auto Payruntime/payments/auto-pay.mjs
Onchain YieldRouterSui mainnet live + Solana program live + Base/Arb DayRegistry — see docs/30-deployed-package-ids.md

  • No vault farm product / SuperVault core
  • No team custody of principal
  • No fee on deposit/withdraw
  • No multi-AMB reimplementation
  • No contract lock / UpgradeCap burn until explicit go

DocRole
docs/00-product-constitution.mdPrinciples
docs/00-product-scope-correction.mdNo vaults
docs/09-fee-model.mdsee Fees
docs/22-versioning-strategy.mdPackage versions (unlock for now)
docs/29-architecture-implementation.mdRails inventory
docs/33-full-e2e-test-plan.mdTest matrix