Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tedprotocol.io/llms.txt

Use this file to discover all available pages before exploring further.

Technical architecture of TED Protocol smart contracts and systems.

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.
  1. When a function is called, the proxy looks up which facet handles that selector
  2. Delegates the call to that facet
  3. 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.
FunctionDescription
swap()Execute token exchanges
getQuote()Return expected output, price impact, route details, and gas estimates

DEX Adapters

AdapterTargetFeatures
CurveAdapterCurve FinanceOptimized for stablecoin pools and meta pools
UniswapAdapterUniswap V3Concentrated liquidity
PancakeAdapterPancakeSwap V3BSC pools
DragonSwapAdapterDragonSwapKaia pools

Bridge Facets

FacetBridgeSupported Tokens
CCTPFacetCircle CCTPUSDC
LayerZeroFacetLayerZero V2USDT, TEDP (OFT)
WormholeFacetWormholeGeneral tokens

Data Flow

Same-Chain Swap

  1. User calls swap() with token pair and amount
  2. DiamondProxy routes to FXSwapFacet
  3. Facet queries all DEX adapters in parallel
  4. Selects optimal route and executes swap
  5. Sends output tokens to user

Cross-Chain Swap

Source chain:
  1. User calls crossChainSwap()
  2. Swap to bridge-compatible token if needed
  3. Initiate cross-chain transfer via the appropriate bridge facet
Bridge:
  • Bridge protocol delivers the message
Destination chain:
  1. Receive tokens
  2. Swap to target token if needed
  3. Deliver final tokens to user

Security Architecture

Access Control

All changes flow through:
  1. Multi-sig (3/5 requirement)
  2. Timelock (48 hours)
  3. DiamondProxy
This ensures no single party can make changes, and users have time to react to proposed modifications.

Emergency Controls

ActionRequired SignaturesPurpose
Pause2-of-5Stop all operations
Unpause3-of-5Resume operations
Upgrade3-of-5 + timelockDeploy new facets
Emergency4-of-5Bypass timelock for critical fixes

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

  1. Source chain — TEDP tokens are burned
  2. Verification — LayerZero DVNs (Decentralized Verifier Networks) verify the burn transaction
  3. Destination chain — Equivalent TEDP minted to the recipient
Total supply remains constant across all chains.

External Integrations

DEX Contracts

DEXContractsNotes
CurvePool-specific routers + registryFor pool discovery
Uniswap V3SwapRouter02 + UniswapV3Factory-
PancakeSwapSmartRouter + V3FactoryBSC

Bridge Contracts

BridgeContracts
Circle CCTPTokenMessenger, MessageTransmitter
LayerZeroEndpoint, DVN, Executor
WormholeCore Bridge, Token Bridge

Gas Optimization

Optimization Techniques

TechniqueSavings
Batch operations30-50%
Storage packing20-40%
Assembly optimization10-20%
Minimal proxy patterns50%+ on deployment

Typical Gas Costs

OperationGas (Ethereum/L2)
Simple swap~150k
Multi-hop swap~300k
Cross-chain initiation~200k (source chain)