Architecture
WeedSwap separates token budgets, reward policy, user custody, indexing, and presentation.
#System map
flowchart LR
U[Wallet] --> W[Next.js web]
W --> UNI[Uniswap v3]
W --> C[WeedChef]
W --> S[WeedV3Staker]
W --> V[WeedV3Vault]
W --> I[Viem indexer]
I --> P[(PostgreSQL)]
C --> E[EmissionController]
E --> B[FarmingRewardsVault]
C -. isolated hook .-> R[WeedReferral]
R --> RB[ReferralRewardsVault]
T[ProtocolTimelock] --> C
T --> E
G[Guardian] -. narrow pause .-> CThe web is designed to read public chain and indexer data but does not define reward entitlement. Those live read paths are not connected yet. Contracts and their state are authoritative. In live mode, a failed source renders a blank marker and is never replaced with demo data.
#Token flow
WeedToken creates three exact vault allocations. The emission controller releases base WEED from FarmingRewardsVault to WeedChef. WeedChef accounts and transfers base rewards. WeedReferral separately requests commission and boost payments from ReferralRewardsVault.
#Farming reward flow
sequenceDiagram
participant U as User
participant C as WeedChef
participant E as EmissionController
participant B as Base vault
participant R as Referral
U->>C: deposit supported token
C->>C: measure receipt and update debt
U->>C: harvest or withdraw
C->>E: claim bounded base reward
E->>B: release to WeedChef
C->>U: transfer base WEED
C-->>R: isolated referral hook#Liquidity flows
The direct rail transfers a v3 position NFT into WeedV3Staker, validates its pool and range, records the owner, and stakes it in a funded incentive. The vault rail receives two tokens, mints or increases one immutable-range v3 position, and issues fungible shares from actual liquidity.
#Bootstrap flow
LiquidityBootstrapVault currently enforces only two WEED release sub-caps selected by a boolean. Its operator chooses any nonzero recipient. No contract call in that release creates or validates a WEED / USDG or WEED / WETH position, registers the NFT with LiquidityNFTLocker, or proves that the reserve bought liquidity.
#Budget vault initialization
WeedToken sends the complete genesis allocation directly to FarmingRewardsVault, ReferralRewardsVault, and LiquidityBootstrapVault. Each vault later selects budgetAsset through initializeBudget.
#Trust boundaries
- External tokens and Uniswap v3 remain separate systems.
- The indexer stores observations and never authorizes a transfer.
- The guardian pauses narrow activity but has no direct principal-transfer function. A separate same-token Greenhouse administrator-recovery flaw remains a launch blocker.
- Timelocked administration remains powerful within hard contract caps.
- Browser transaction flows must simulate and show exact destinations before enabling writes.
