Architecture
Contract Layers
┌─────────────────────────────────────────────────────────────────────────┐
│ USER LAYER │
│ (External Applications/Users) │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ PERIPHERY LAYER │
│ ┌─────────────────┐ ┌───────────────────────┐ ┌─────────────────┐ │
│ │ SwapRouter │ │ NonfungiblePosition │ │ VinuSwapQuoter │ │
│ │ │ │ Manager │ │ │ │
│ │ - exactInput │ │ - mint/burn │ │ - quoteExact │ │
│ │ - exactOutput │ │ - increase/decrease │ │ - estimate gas │ │
│ │ - multi-hop │ │ - collect/lock │ │ │ │
│ └─────────────────┘ └───────────────────────┘ └─────────────────┘ │
│ │
│ ┌─────────────────┐ ┌───────────────────────┐ │
│ │ Controller │ │ PositionDescriptor │ │
│ │ - createPool │ │ - tokenURI │ │
│ │ - collectFees │ │ - SVG generation │ │
│ │ - distribute │ │ │ │
│ └─────────────────┘ └───────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ CORE LAYER │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ VinuSwapFactory │ │
│ │ - createPool(tokenA, tokenB, fee, tickSpacing, feeManager) │ │
│ │ - getPool(tokenA, tokenB, fee) │ │
│ │ - Ownership control │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │ creates │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ VinuSwapPool │ │
│ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │ │
│ │ │ Slot0 │ │ Positions │ │ Observations │ │ │
│ │ │ sqrtPrice │ │ liquidity │ │ TWAP Oracle Data │ │ │
│ │ │ tick │ │ feeGrowth │ │ │ │ │
│ │ │ feeProtocol │ │ │ │ │ │ │
│ │ └─────────────┘ └──────────────┘ └──────────────────────────┘ │ │
│ │ │ │
│ │ Functions: initialize, mint, burn, swap, collect, observe │ │
│ └───────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ FEE MANAGEMENT LAYER │
│ ┌─────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ TieredDiscount │ │OverridableFeeManager│ │ NoDiscount │ │
│ │ Balance-based │ │ Per-pool overrides │ │ Passthrough │ │
│ │ fee discounts │ │ │ │ │ │
│ └─────────────────┘ └─────────────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘Core Contracts
VinuSwapFactory
VinuSwapPool
Component
Purpose
VinuSwapPoolDeployer
Periphery Contracts
SwapRouter
NonfungiblePositionManager
VinuSwapQuoter
Controller
Fee Management
IFeeManager Interface
TieredDiscount
OverridableFeeManager
Data Flow
Swap Flow
Mint Flow
Fee Collection Flow
Library Dependencies
Core Libraries (from Uniswap V3)
Library
Purpose
Periphery Libraries
Library
Purpose
Security Model
Access Control
Contract
Owner Functions
Protection Mechanisms
Next Steps
Last updated