117 lines
2.6 KiB
Markdown
117 lines
2.6 KiB
Markdown
|
|
# ASLE Architecture Documentation
|
||
|
|
|
||
|
|
## System Architecture
|
||
|
|
|
||
|
|
### Overview
|
||
|
|
ASLE uses a modular Diamond (ERC-2535) architecture with multiple facets handling different functionalities.
|
||
|
|
|
||
|
|
### Smart Contract Architecture
|
||
|
|
|
||
|
|
#### Core Components
|
||
|
|
- **Diamond.sol** - Main proxy contract using ERC-2535 standard
|
||
|
|
- **DiamondCutFacet** - Manages facet additions/updates/removals
|
||
|
|
- **DiamondInit** - Initialization contract
|
||
|
|
|
||
|
|
#### Feature Facets
|
||
|
|
- **LiquidityFacet** - DODO PMM implementation
|
||
|
|
- **VaultFacet** - ERC-4626 and ERC-1155 vaults
|
||
|
|
- **ComplianceFacet** - Multi-mode compliance system
|
||
|
|
- **CCIPFacet** - Cross-chain messaging
|
||
|
|
- **GovernanceFacet** - DAO governance
|
||
|
|
- **SecurityFacet** - Emergency controls
|
||
|
|
- **RWAFacet** - Real-world asset tokenization
|
||
|
|
|
||
|
|
#### Libraries
|
||
|
|
- **LibDiamond** - Diamond storage management
|
||
|
|
- **LibAccessControl** - Role-based access control
|
||
|
|
- **LibReentrancyGuard** - Reentrancy protection
|
||
|
|
- **PMMMath** - DODO PMM calculations
|
||
|
|
|
||
|
|
### Backend Architecture
|
||
|
|
|
||
|
|
#### API Layer
|
||
|
|
- REST API (Express.js)
|
||
|
|
- GraphQL API (Apollo Server)
|
||
|
|
- WebSocket for real-time updates
|
||
|
|
|
||
|
|
#### Service Layer
|
||
|
|
- ComplianceService - KYC/AML/OFAC
|
||
|
|
- CCIPService - Cross-chain tracking
|
||
|
|
- MonitoringService - Health and metrics
|
||
|
|
- MultiJurisdictionService - Regulatory compliance
|
||
|
|
- CustodialService - Wallet management
|
||
|
|
- BankService - SWIFT/ISO 20022
|
||
|
|
|
||
|
|
#### Data Layer
|
||
|
|
- PostgreSQL database
|
||
|
|
- Prisma ORM
|
||
|
|
- Redis for caching
|
||
|
|
|
||
|
|
### Frontend Architecture
|
||
|
|
|
||
|
|
#### Framework
|
||
|
|
- Next.js 16 (App Router)
|
||
|
|
- React 19
|
||
|
|
- TypeScript
|
||
|
|
|
||
|
|
#### Key Libraries
|
||
|
|
- Wagmi/Viem for Web3
|
||
|
|
- React Query for data fetching
|
||
|
|
- Tailwind CSS for styling
|
||
|
|
- Recharts for visualizations
|
||
|
|
|
||
|
|
### Cross-Chain Architecture
|
||
|
|
|
||
|
|
#### CCIP Integration
|
||
|
|
- Chainlink CCIP for messaging
|
||
|
|
- Multi-chain state synchronization
|
||
|
|
- Liquidity pool syncing
|
||
|
|
- Vault rebalancing
|
||
|
|
|
||
|
|
## Data Flow
|
||
|
|
|
||
|
|
### Pool Creation Flow
|
||
|
|
1. User submits pool creation via frontend
|
||
|
|
2. Frontend sends transaction to LiquidityFacet
|
||
|
|
3. Contract validates and creates pool
|
||
|
|
4. Event emitted and indexed
|
||
|
|
5. Backend updates database
|
||
|
|
6. Frontend refreshes pool list
|
||
|
|
|
||
|
|
### Compliance Flow
|
||
|
|
1. User requests compliance mode change
|
||
|
|
2. Frontend calls ComplianceFacet
|
||
|
|
3. Contract validates permissions
|
||
|
|
4. Backend service verifies KYC/AML
|
||
|
|
5. Compliance status updated
|
||
|
|
6. Audit trail recorded
|
||
|
|
|
||
|
|
## Security Model
|
||
|
|
|
||
|
|
### Access Control
|
||
|
|
- Role-based permissions
|
||
|
|
- Multi-sig support
|
||
|
|
- Timelock for upgrades
|
||
|
|
|
||
|
|
### Security Features
|
||
|
|
- Reentrancy guards
|
||
|
|
- Circuit breakers
|
||
|
|
- Emergency pause
|
||
|
|
- Price deviation monitoring
|
||
|
|
|
||
|
|
## Deployment Architecture
|
||
|
|
|
||
|
|
### Networks
|
||
|
|
- Ethereum Mainnet
|
||
|
|
- Polygon
|
||
|
|
- Arbitrum
|
||
|
|
- Optimism
|
||
|
|
- Base
|
||
|
|
|
||
|
|
### Infrastructure
|
||
|
|
- Docker containers
|
||
|
|
- Kubernetes-ready
|
||
|
|
- Load balanced
|
||
|
|
- Monitored
|
||
|
|
|