Dynamic pricing for limit orders based on real-time market volatility.
VolatilitySpreadCalculator
: is a smart contract extension for the 1inch Limit Order Protocol that introduces risk-adjusted dynamic pricing to decentralized trading.
The Problem We Solve:
Current DeFi limit orders use fixed prices (e.g., "1 ETH for 3000 USDC") regardless of market conditions. This creates a fundamental mismatch between risk and reward - market makers face the same compensation whether they're trading during calm periods or extreme volatility. During events like March 2020's Black Thursday (50% ETH crash), fixed-fee DEX market makers lost millions because their 0.3% fees couldn't cover impermanent loss from massive price swings.
Our Solution:
We built an intelligent pricing layer that automatically adjusts order prices based on real-time volatility data. Market makers can now create "smart orders" that protect them during volatile periods while remaining competitive during calm markets.
How It Works:
Real-time Data Integration
: Created a Volatility calculator Fetches on the top of Chainlink price feeds
Dynamic Calculation: Applies formula: Final Price = Base Price + (Volatility × Risk Multiplier)
Automatic Adjustment
: When orders execute, the contract calculates current volatility and adjusts the final amount
Risk Protection
: Maximum spread caps prevent excessive pricing during black swan events
Technical Implementation
:
Core Contract
: VolatilitySpreadCalculator implementing 1inch's IAmountGetter
interface
Volatility Engine
: Custom ChainlinkVolatilityLib for multi-timeframe volatility calculation
Seamless Integration
: Zero changes needed to existing 1inch protocol - pure extension
Flexible Parameters
: Configurable base spreads, volatility multipliers, and time windows
Example Usage
:
A trader creates an order: "Sell 1 ETH for ~3000 USDC with dynamic pricing"
Calm market (5% volatility): Taker pays 3018 USDC (0.6% adjustment) Volatile market (30% volatility): Taker pays 3060 USDC (2% adjustment, capped).
https://dashboard.tenderly.co/explorer/vnet/be5ae2b9-fc3c-44d8-9aa0-af465f26db03/transactions
We built a system that automatically adjusts limit order prices based on market volatility. Think of it like a smart market maker that widens spreads when markets are crazy and tightens them when things are calm. Here's how we put it all together:
Traditional limit orders on 1inch use fixed prices. We added a "brain" that watches market volatility and adjusts prices in real-time. When someone fills the order, our system calculates the exact price based on current market conditions, not the conditions when the order was created.
We created a VolatilitySpreadCalculator contract that acts as a pricing oracle for limit orders. This contract:
1inch's TypeScript SDK is built in a modular way and has support for extending its functionality to support any extension . The SDK has an example for extensions that receive and distribute tokens (like fee collectors), but our extension only calculates amounts. We created three new components: