Tethra
Perpetual futures trading dApp on Base with Chainlink Price Feeds and CRE-powered automation
What it is
Tethra Trade is a fully functional perpetual futures trading dApp built on Base that leverages Chainlink infrastructure for trustless price data and decentralized automation.
The platform allows users to trade crypto perpetual contracts with up to 100x leverage, using real-time Chainlink Price Feeds (BTC, ETH, SOL) for accurate on-chain price verification. It supports advanced order types including limit orders, stop-loss, take-profit, and grid trading strategies.
What makes Tethra Trade unique is its deep Chainlink CRE integration. Instead of relying on centralized backend keepers, the protocol uses two CRE workflows:
Keeper Workflow ā Automatically monitors and executes pending limit orders, liquidates unhealthy positions, and streams surplus funds from the StabilityFund to the VaultPool on a scheduled basis. All price checks are performed against Chainlink Price Feeds on Base Mainnet.
OTP Settler Workflow ā Handles the One Tap Profit feature, a short-term price prediction game (30sā5min). Users submit encrypted predictions with commitments. The CRE workflow scans expired predictions, fetches encrypted payloads via authenticated HTTP, verifies commitments, evaluates outcomes using Chainlink feeds, and batch-resolves results on-chain ā ensuring tamper-proof and trust-minimized settlement.
The platform also features gasless UX through Account Abstraction (USDC gas payments), Privy-powered embedded wallets for seamless onboarding via email/social login, a dual token economy (USDC for trading, TETH for governance and staking), and a share-based liquidity vault where LPs earn from trading fees.
Tethra Trade solves the problem of centralized execution risk in DeFi trading platforms by offloading critical keeper and settlement logic to Chainlink CRE, making the protocol more decentralized, reliable, and censorship-resistant.
How it Works
Tethra Trade is a full-stack dApp consisting of four components:
Smart Contracts (Solidity 0.8.20 + Foundry):
- 11 contracts deployed on Base Sepolia covering position management, market/limit execution, risk management, a StabilityFund (first-loss buffer + fee splitter), VaultPool (share-based LP), TETH staking, OneTapProfit, and a USDC Paymaster for Account Abstraction.
- All contracts use OpenZeppelin libraries (AccessControl, ReentrancyGuard, SafeERC20) and ECDSA-signed price verification with 5-minute validity windows.
Backend (Node.js + Express + TypeScript):
- Reads Chainlink Price Feeds from Base Mainnet (BTC, ETH, SOL) and signs prices with ECDSA for on-chain verification.
- Provides WebSocket real-time price streaming, a relay service for gasless transactions, and trading automation monitors (limit orders, TP/SL, grid trading, position liquidation).
- Exposes CRE-authenticated endpoints for the settlement workflow.
- Supports CRE Keeper Mode (USE_CRE_KEEPER=true) to disable local keepers and delegate execution to Chainlink CRE.
Chainlink CRE Workflows (TypeScript):
- Keeper Workflow: Reads on-chain state (pending orders, open positions, stability fund balance), fetches Chainlink prices from Base Mainnet feeds, and executes limit orders, liquidations, and stability fund streaming via broadcast transactions on Base Sepolia.
- OTP Settler Workflow: Scans active predictions using a sliding window, fetches encrypted payloads from backend via authenticated HTTP, verifies commitments, evaluates outcomes against Chainlink price feeds, and batch-resolves results on-chain through CRE report writes.
- Both workflows use secrets.yaml for secure key management and support staging/production profiles.
Frontend (Next.js 15 + React 19 + TailwindCSS 4):
- Professional trading interface with TradingView charts and Chainlink oracle price overlay.
- Privy integration for email/social login with embedded smart wallets.
- Wagmi + Viem for Web3 interactions, USDC gas payments via Account Abstraction.
- Real-time WebSocket price updates and live PnL calculation.
Links
Created by
- Fawwaz Naufal
- Ini Ferdin
- Bagas Gunardi
- Abiyyu Faisal