๐ Smart TWAPer
Smart TWAPer is a decentralized application (dApp) proof of concept designed to empower DeFi users to execute large token swaps intelligently by splitting them into smaller, time-scheduled trades. Built atop the robust 1inch limit order protocol and leveraging EIP-7702 smart accounts alongside ERC-1271 signatures, Smart TWAPer delivers secure, efficient, and automated trade execution crafted specifically for todayโs dynamic DeFi ecosystem.
๐ก What is Smart TWAPer?
Smart TWAPer allows users to swap large amounts of tokens over time, following a time-weighted average price (TWAP) strategy. Instead of performing a single, potentially market-disrupting transaction, the system breaks the trade into smaller limit orders placed at regular intervals. These scheduled trades run automatically through smart account logic, eliminating the need for users to monitor or sign each individual step.
At its core, Smart TWAPer integrates:
- 1inchโs deep aggregated liquidity for optimal routing and best prices
- EIP-7702 smart accounts for programmable and gas-efficient trade management
- ERC-1271 signatures for secure off-chain authorization without requiring repetitive on-chain approvals
๐ Why Does It Matter?
In todayโs fast-paced DeFi markets, executing large trades comes with several challenges:
- High slippage can erode returns by worsening the execution price
- Market impact often moves the price unfavorably during execution
- Visibility to bots opens up the risk of front-running and MEV (maximum extractable value) attacks
- Manual execution burdens force traders to constantly watch the market to avoid missed opportunities or mistakes
Smart TWAPer addresses these pain points by providing a secure, automated execution layer that:
- Minimizes slippage
- Reduces MEV risks
- Optimizes trade outcomes
- Gives the user full control through a programmable smart account
โ How Does It Work?
-
Smart Account Setup
The user connects their wallet and either deploys or links an EIP-7702 smart account, a programmable on-chain entity capable of holding tokens and executing advanced logic.
-
Configure TWAP Order
The user defines the swap details:
- Which tokens to swap
- How much to trade
- Over what duration and frequency
- Under what price or slippage conditions
-
Sign Once, Execute Many
Instead of manually signing every individual trade, the user signs a master intent or authorization. The smart account verifies this using ERC-1271, enabling secure off-chain signature validation.
-
Automated Execution
Smart TWAPer executes each scheduled trade chunk via the 1inch limit order protocol, checking current market prices and conditions at every interval. Execution can be triggered by backend bots or decentralized automation networks like Gelato or Chainlink Automation.
-
Completion and Settlement
After the TWAP schedule completes, the swapped tokens are collected and (optionally) sent back to the userโs main wallet. Users can monitor, adjust, or cancel the strategy at any time.
๐ Key Benefits
- Better Prices, Less Slippage โ Breaking up large trades into smaller pieces reduces price impact
- MEV and Front-Running Resistance โ Smaller, less predictable orders lower the risk of exploitation
- Non-Custodial, User-Controlled โ Smart accounts hold the assets, ensuring users remain in full control at all times
- Gas-Efficient Execution โ ERC-1271 signatures eliminate the need for repetitive on-chain approvals
- Deep Liquidity Access โ 1inchโs sophisticated routing delivers the best aggregated prices across the DeFi landscape
- Hands-Off Automation โ Once configured, execution runs automatically without requiring constant user oversight
๐ง Technical Deep Dive
Smart Contract Infrastructure
At the heart of Smart TWAPer is our flagship DelegatedWallet contract (1,674 lines of behemoth Solidity), providing the backbone for execution:
- EIP-1271 integration for smart contract signatures enabling seamless 1inch limit order creation
- Dutch Auction Engine for sophisticated price discovery and optimal execution
- Batch Swap Orchestration to split large trades into customizable chunks
- On-Chain TWAP Registry for fully decentralized order management and transparent execution tracking
EIP-7702: The Game Changer
- Turns EOAs into programmable smart wallets without giving up custody
- One-time signature enables repeated TWAP strategy execution
- Sponsors can subsidize gas for a truly gasless user experience
- Contract state lives directly at the userโs address, preserving full self-sovereignty
๐ค Partner Technology Integration
1inch Limit Order Protocol
- Direct integration with OrderRegistrator (
0x2339f78e2Ec15C47Cf042F2460C532C0D7ff1CCE
)
- Smart contract acts as an advanced market maker
- Each TWAP slice becomes an independent, incentivized limit order
- Dual execution:
- On-chain via AggregationRouterV6
- Off-chain via OrderRegistrator
Development Stack
- Foundry/Forge for blazing-fast development and testing
- 1inch API to integrate real-time price feeds during order executions
- Automation bots for monitoring and execution triggers
- Blockscout integration for enhanced EIP-7702 transaction visibility and tracking
๐ Notable Technical Innovations
- Real-Time Price Integration (FFI)
- Just-In-Time Token Approvals
- Dynamic Order Generation:
- Precision-calculated executor incentives
- Time-windowed execution constraints
- Price deviation protection relative to benchmarks
- Cryptographically unique salts to prevent order collisions
๐ Execution Flow
- Delegation โ User authorizes DelegatedWallet (one-time EIP-7702 setup)
- Registration โ TWAP parameters committed on-chain
- Monitoring โ Decentralized executor network scans for opportunities
- Execution โ Time-triggered 1inch limit orders
- Settlement โ Orders filled through 1inch liquidity
- Tracking โ Full on-chain event logging for transparency
๐ก๏ธ Security Architecture
- Replay protection using unique nonces for each order
- Time-based distribution to prevent front-running attacks
- Price oracles to verify market conditions and protect against manipulation
- Economic incentives rewarding reliable executor behavior
- EIP-7702 guarantees full custody stays with the user at all times
๐ Why This Matters
Smart TWAPer represents a paradigm shift in DeFi execution:
- Zero custody risk โ assets never leave the userโs control
- Gasless trading โ made possible through sponsor subsidies
- MEV protection โ limit orders provide robust execution guarantees
- Decentralized execution โ anyone can be a resolver, no central authority required
- Wallet agnostic โ works with any EOA, no migration needed
By combining EIP-7702โs delegation powers with 1inchโs proven limit order protocol, weโve built a trustless execution layer that makes sophisticated trading strategies simple, secure, and accessible. Users sign once, and the protocol handles everything else โ all while the user retains complete control.
๐ Execution Flexibility
- On-chain execution via AggregationRouterV6 for atomic swaps
- Off-chain execution via OrderRegistrator for gas-efficient limit orders
Resolvers can dynamically choose the best execution path based on prevailing market conditions, ensuring optimal outcomes for users.