← Back to home

Smart TWAPer

Smart TWAPer splits big swaps into secure, automated trades using 1inch and EIP-7702 smart accounts.

Problem Statement

🌐 Smart TWAPerSmart 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 leveragingEIP-7702smart accounts alongsideERC-1271signatures, 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 atime-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 liquidityfor optimal routing and best pricesEIP-7702 smart accountsfor programmable and gas-efficient trade managementERC-1271 signaturesfor 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 slippagecan erode returns by worsening the execution priceMarket impactoften moves the price unfavorably during executionVisibility to botsopens up the risk of front-running and MEV (maximum extractable value) attacksManual execution burdensforce traders to constantly watch the market to avoid missed opportunities or mistakesSmart TWAPer addresses these pain points by providing a secure, automated execution layer that:Minimizes slippageReduces MEV risksOptimizes trade outcomesGives the user full control through a programmable smart account⚙ How Does It Work?Smart Account SetupThe 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 OrderThe user defines the swap details:Which tokens to swapHow much to tradeOver what duration and frequencyUnder what price or slippage conditionsSign Once, Execute ManyInstead 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 ExecutionSmart 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 SettlementAfter 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 BenefitsBetter Prices, Less Slippage→ Breaking up large trades into smaller pieces reduces price impactMEV and Front-Running Resistance→ Smaller, less predictable orders lower the risk of exploitationNon-Custodial, User-Controlled→ Smart accounts hold the assets, ensuring users remain in full control at all timesGas-Efficient Execution→ ERC-1271 signatures eliminate the need for repetitive on-chain approvalsDeep Liquidity Access→ 1inch’s sophisticated routing delivers the best aggregated prices across the DeFi landscapeHands-Off Automation→ Once configured, execution runs automatically without requiring constant user oversight

Solution

🔧 Technical Deep DiveSmart Contract InfrastructureAt the heart of Smart TWAPer is our flagshipDelegatedWalletcontract (1,674 lines of behemoth Solidity), providing the backbone for execution:EIP-1271 integrationfor smart contract signatures enabling seamless 1inch limit order creationDutch Auction Enginefor sophisticated price discovery and optimal executionBatch Swap Orchestrationto split large trades into customizable chunksOn-Chain TWAP Registryfor fully decentralized order management and transparent execution trackingEIP-7702: The Game ChangerTurns EOAs intoprogrammable smart walletswithout giving up custodyOne-time signature enables repeatedTWAP strategy executionSponsors can subsidize gasfor a truly gasless user experienceContract state lives directly at theuser’s address, preserving full self-sovereignty🤝 Partner Technology Integration1inch Limit Order ProtocolDirect integration withOrderRegistrator(0x2339f78e2Ec15C47Cf042F2460C532C0D7ff1CCE)Smart contract acts as anadvanced market makerEach TWAP slice becomes anindependent, incentivized limit orderDual execution:On-chain viaAggregationRouterV6Off-chain viaOrderRegistratorDevelopment StackFoundry/Forgefor blazing-fast development and testing1inch APIto integrate real-time price feeds during order executionsAutomation botsfor monitoring and execution triggersBlockscout integrationfor enhanced EIP-7702 transaction visibility and tracking🚀 Notable Technical InnovationsReal-Time Price Integration (FFI)Just-In-Time Token ApprovalsDynamic Order Generation:Precision-calculatedexecutor incentivesTime-windowed execution constraintsPrice deviation protectionrelative to benchmarksCryptographically unique saltsto prevent order collisions🔄 Execution FlowDelegation→ User authorizes DelegatedWallet (one-time EIP-7702 setup)Registration→ TWAP parameters committed on-chainMonitoring→ Decentralized executor network scans for opportunitiesExecution→ Time-triggered 1inch limit ordersSettlement→ Orders filled through 1inch liquidityTracking→ Full on-chain event logging for transparency🛡️ Security ArchitectureReplay protectionusing unique nonces for each orderTime-based distributionto prevent front-running attacksPrice oraclesto verify market conditions and protect against manipulationEconomic incentivesrewarding reliable executor behaviorEIP-7702 guarantees full custodystays with the user at all times🌟 Why This MattersSmart TWAPer represents aparadigm shiftin DeFi execution:Zero custody risk→ assets never leave the user’s controlGasless trading→ made possible through sponsor subsidiesMEV protection→ limit orders provide robust execution guaranteesDecentralized execution→ anyone can be a resolver, no central authority requiredWallet agnostic→ works with any EOA, no migration neededBy combining EIP-7702’s delegation powers with 1inch’s proven limit order protocol, we’ve built atrustless execution layerthat 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 FlexibilityOn-chain executionvia AggregationRouterV6 for atomic swapsOff-chain executionvia OrderRegistrator for gas-efficient limit ordersResolvers can dynamically choose the best execution path based on prevailing market conditions, ensuring optimal outcomes for users.

Hackathon

ETHGlobal Prague

2025

Prizes

  • 🏆

    Extend Limit Order Protocol1st place

    1inch

Contributors