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
- Ender13120
20 contributions