Configure and deploy onchain limit order strategies using time or price triggers with 1inch Protocol
🌀 Sway: Smarter, Multi-Phase On-Chain Trade Execution Sway is a decentralized trading application that empowers users to execute complex, customizable strategies on-chain. Rather than locking into a single execution style—like TWAP, Dutch auction, or fixed price—Sway enables users to define multi-phase execution plans that can adapt over time or based on real-time market conditions.
🎯 Example Execution Strategy Let’s say a user wants to sell 10,000 DAI for WETH. They configure the following execution phases:
Phase 1 (TWAP): Over the first 20 minutes, the order is split into smaller chunks and filled gradually to reduce market impact.
Phase 2 (Dutch Auction): If there’s leftover inventory, the price starts decreasing over 10 minutes to increase urgency.
Phase 3 (OTC): If unfilled after the auction, the remainder is offered at a fixed discount to a pre-approved list of OTC dealers.
Each phase can be customized through parameters (e.g., chunk size, discount rate, minimum fill quantity).
🖥️ User Experience Users configure and preview their execution strategy through a React + Vite frontend, with a streamlined interface for selecting phases and tuning parameters. Once ready, clicking “Execute Strategy”:
Builds a makerTraits object with the encoded MultiPhaseAmountCalculator logic,
Signs the order using the connected wallet,
(In production) would submit it to the 1inch Limit Order API—currently disabled per hackathon rules.
The app also includes an Execution Monitor Panel, a visual dashboard to track order fills in real time. Users can inspect:
Fill chart: Tracks time-series fills, prices, and quantities.
Hover insights: Show which strategy calculated the fill price, enabling post-trade analysis and transparency.
đź”§ How It Works: The Smart Contract Architecture At the heart of Sway is a custom smart contract extension to the 1inch Limit Order Protocol, called the MultiPhaseAmountCalculator. This contract implements the IAmountGetter interface and orchestrates a sequence of modular pricing strategies, or phases, each defined by:
When a taker attempts to fill the order, MultiPhaseAmountCalculator determines which phase is currently active (getCurrentPhase function in MultiPhaseAmountCalculator) and applies the appropriate logic to calculate the order's price or amount.
Sway currently supports three custom calculators:
For an example of how these are put together into building an order, please refer to MultiPhaseAmountCalculator.js in test directory of the limit-order-protocol directory.

