Introduction
Automated Orders
This section explains how to implement basic automated Orders—smart contracts that monitor prices and execute token swaps on Uniswap based on simple price thresholds, signing transactions with Keychains. This Order type serves as a foundation for building more advanced Orders with price prediction.
You'll implement the core logic in the BasicOrder
contract, implement the creation of Orders in BasicOrderFactory
, and finally deploy an Order. To learn about the full architecture of this project, refer to the main introduction.
Please note that the articles in this section typically contain only fragments of code.
You can find the full code of the example on GitHub: /orders
Key features
Automated Orders provide the following key features:
- Price threshold monitoring
- Single price source integration
- Direct Uniswap interactions
- Basic execution security
User flow
A user can create and manage multiple automated Orders. The user flow includes the following steps:
- The user specifies the Order input with these details:
- The price threshold and condition (greater/less than)
- The token pair to monitor
- Swap details such as amount, path, recipient, deadline
- Transaction signing details
- The
OrderFactory
contract callsBasicOrderFactory
, which deploys a newBasicOrder
contract (Order) and registers it in the registry. - The Order continuously monitors prices using Slinky.
- When the price threshold is met, the Order executes a swap:
- Transaction details are stored in the registry.
Get started
To get started with automated Orders, take the following steps: