Overview
TED Protocol is built on a modular, upgradeable architecture using the Diamond Pattern (EIP-2535). User transactions flow through a single DiamondProxy entry point, which routes calls to specialized facets:- Swap Facets — FXSwapFacet, CurveAdapter, UniswapV3
- Bridge Facets — CCTPFacet, LayerZeroFacet, WormholeFacet
- Admin Facets — AdminFacet, DiamondCut, DiamondLoupe
Diamond Pattern (EIP-2535)
Why Diamond?
- Modularity — Each feature is a separate facet
- Upgradeability — Update single facets without redeploying entire contracts
- No size limits — Bypasses the 24KB contract limit
- Single address — One entry point for all functions
- Gas efficiency — delegatecall-based routing
Structure
The DiamondProxy contract maps function selectors to facet addresses.- When a function is called, the proxy looks up which facet handles that selector
- Delegates the call to that facet
- Functionality can be added, replaced, or removed without changing the main contract address
Storage Pattern
All facets share diamond storage using a unique storage position (keccak256 hash), preventing storage collisions that can occur with traditional proxy patterns. Storage struct contains:- Facet mappings
- Owner address
- Protocol state such as pause status
Core Facets
FXSwapFacet
Handles stablecoin FX swaps with multi-DEX routing.DEX Adapters
Bridge Facets
Data Flow
Same-Chain Swap
- User calls
swap()with token pair and amount - DiamondProxy routes to FXSwapFacet
- Facet queries all DEX adapters in parallel
- Selects optimal route and executes swap
- Sends output tokens to user
Cross-Chain Swap
Source chain:- User calls
crossChainSwap() - Swap to bridge-compatible token if needed
- Initiate cross-chain transfer via the appropriate bridge facet
- Bridge protocol delivers the message
- Receive tokens
- Swap to target token if needed
- Deliver final tokens to user
Security Architecture
Access Control
All changes flow through:- Multi-sig (3/5 requirement)
- Timelock (48 hours)
- DiamondProxy
Emergency Controls
The Safe is
0x5B72ac1CB423896E372960da7ABF1CFb03e74c2d, the same address on all six chains.
Verify with getOwners() and getThreshold().
TEDP Token Architecture
OFT Standard
TEDP implements LayerZero OFT (Omnichain Fungible Token).- Combined with ERC-20 and ERC-20Permit
- Fixed supply of 1 billion tokens minted at deployment
- Seamless cross-chain transfers
Cross-Chain Flow
- Source chain — TEDP tokens are burned
- Verification — LayerZero DVNs (Decentralized Verifier Networks) verify the burn transaction
- Destination chain — Equivalent TEDP minted to the recipient
Total supply remains constant across all chains.