1Twap

Onchain Adaptive TWAP built on 1inch — chunked execution, price protection, and auto-fills.

Repo
1Twap banner

About

CTWAP: Conditional Time-Weighted Average Price with Volatility Awareness What We Built CTWAP is a volatility-aware execution strategy for the 1inch Limit Order Protocol. It adds conditional logic to traditional TWAP orders, allowing trades to execute only when market volatility falls within user-specified ranges. The system reads real-time volatility from Chainlink price oracles or dedicated volatility feeds, calculates annualized volatility from recent price movements, and gates order execution based on these metrics. It's implemented as pre/post-interaction hooks that integrate seamlessly with 1inch's existing infrastructure. Why We Built It Traditional TWAP executes on a fixed schedule regardless of market conditions. This creates several problems:

Execution during extreme volatility leads to poor fills and high slippage Trading in dead markets wastes gas on minimal price improvements No adaptation to market regime changes - same strategy whether markets are calm or chaotic

We observed that sophisticated traders manually pause their TWAP strategies during unfavorable conditions but resume when volatility normalizes. CTWAP automates this decision-making process. The Opportunity DeFi lacks sophisticated execution tools that institutional traders take for granted in traditional finance. While TradFi has volatility-targeted algorithms, conditional orders, and adaptive execution, DeFi users are limited to basic time-based strategies. The market opportunity includes:

Treasury managers holding billions in stablecoins need better conversion strategies DAOs accumulating strategic positions want to avoid volatile periods Traders seeking to optimize entry/exit points based on market conditions Market makers requiring volatility-aware liquidity provision

Technical Implementation

Core Components:

Volatility Calculation Engine

Fetches latest and historical prices from Chainlink oracles Calculates instant returns between price updates Annualizes volatility using standard deviation of returns Falls back to reasonable defaults when data is insufficient

Conditional Execution Logic

User sets min/max volatility thresholds (e.g., 20% - 80% annualized) Each chunk checks current volatility before execution Blocks execution outside specified ranges Maintains standard TWAP intervals when conditions are met

State Management

Tracks executed chunks and remaining amounts Records volatility at each execution for analysis Handles order completion and partial fills

Key Parameters:

minVolatility / maxVolatility: Execution bounds in basis points volatilityWindow: Lookback period for calculations adaptiveChunkSize: Optional scaling based on volatility continuousMode: Rapid execution when conditions are favorable

Benefits to Users

For Large Traders:

Execute sizeable orders without monitoring markets constantly Avoid trading during flash crashes or extreme pumps Reduce overall execution costs through better timing

For DAOs and Treasuries:

Implement policy-based trading (e.g., "only convert reserves during normal markets") Create audit trails showing execution happened within risk parameters Delegate execution to keepers while maintaining control over conditions

For Retail Users:

Access institutional-grade execution strategies Set-and-forget orders that respect market conditions Better average prices by avoiding extreme volatility periods

For Market Makers:

Provide liquidity only when spreads are favorable Reduce inventory risk during volatile periods Optimize capital efficiency

Real Usage Example

A DAO wants to convert 1,000,000 USDC to ETH over 24 hours: Traditional TWAP: Buys 41,666 USDC worth every hour, regardless of conditions CTWAP Configuration:

Total: 1,000,000 USDC → ETH

Chunks: 24 (hourly) Volatility Range: 30% - 90% (typical ETH range) Duration: 24-48 hours (flexible based on conditions)

Result: Executes only during favorable volatility, potentially completing in 30 hours but with better average pricing and reduced slippage. Technical Advantages

No Protocol Modifications: Works with existing 1inch infrastructure Gas Efficient: Volatility calculations use existing oracle data Composable: Can be combined with other 1inch features Chain Agnostic: Deployed on Base, works on any EVM chain with oracles

CTWAP solves a real problem in DeFi execution - the inability to condition trades on market state. By adding volatility awareness to TWAP, users get better execution without sacrificing the benefits of automated trading.

This implementation enhances traditional TWAP logic by introducing:

Volatility-aware chunk sizing

Gas-aware execution deferment

Chainlink oracle integrations

Batched multi-order execution support for relayers

The goal is to maximize execution efficiency, minimize slippage, and provide a safe and programmable experience for both users and resolvers.

Features

  • TWAP Execution Logic.
  • Volatility-Aware Chunk Sizing (via Chainlink).

3. Gas-Aware Deferment

4. Batched Multi-TWAP Execution

From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

Danify

Advanced TWAP, DCA, grid trading & vesting with 1inch LOP – gasless execution & smart automation

StratosFi

Advanced DeFi strategies for 1inch: TWAP, Options & Concentrated Liquidity with MEV protection

Dripify

A full-stack dApp for executing large, non-custodial TWAP orders on the 1inch LOP