Skip to main content

Order Execution Overview

The OrderManager contract enables automated order execution strategies for Renesis Stellar DEX Vaults. It supports Time-Weighted Average Price (TWAP) and Volume-Weighted Average Price (VWAP) strategies, allowing large orders to be split into smaller chunks and executed over time to minimize market impact.
This is experimental pilot software. Smart contracts have been audited but are provided as-is. See Disclaimers for details.

Architecture

The OrderManager sits between vault owners and the vault contract, coordinating automated trade execution through a keeper network.
┌─────────────┐     ┌──────────────────┐     ┌───────────────┐     ┌──────────┐
│ Vault Owner │────▶│  OrderManager    │────▶│  Vault        │────▶│ Soroswap │
│             │     │  (TWAP / VWAP)   │     │  (Trader)     │     │ Router   │
└─────────────┘     └──────────────────┘     └───────────────┘     └──────────┘

                    ┌──────┘

              ┌─────────────┐
              │   Keeper     │
              │  (Executor)  │
              └──────────────┘
  • Vault Owner creates orders on the OrderManager, depositing a fee reserve.
  • OrderManager is set as the vault’s trader, allowing it to execute swaps.
  • Keepers monitor active orders and trigger execution when conditions are met.
  • The vault routes swaps through the immutable Soroswap router.

Order Lifecycle

Every order follows a defined lifecycle from creation to completion.
1

Created

The vault owner calls create_twap_order() or create_vwap_order(), specifying parameters like total amount, chunk count, intervals, and price bounds. A fee reserve is transferred from the owner to the OrderManager.
2

Active

The order is stored on-chain with status Active. Keepers can query get_active_order_ids() to discover executable orders.
3

Executing

Keepers call execute_order() (TWAP) or execute_vwap_order() (VWAP) when timing and price conditions are met. Each execution processes one chunk and pays the keeper from the fee reserve.
4

Completed / Cancelled

The order reaches Completed status when all chunks are executed, or Cancelled if the owner cancels. Unused fee reserves are refunded to the owner in both cases.

Keeper Incentive Model

Keepers are incentivized through a fee mechanism built into every order.

Fee Reserve

When creating an order, the owner deposits a fee reserve (in the native fee token, typically XLM). The minimum reserve is min_fee_per_execution * num_chunks.

Per-Chunk Payment

Each time a keeper executes a chunk, they receive fee_reserve / num_chunks as payment. This creates a predictable revenue stream for keepers.

Emergency Pause System

The OrderManager includes an admin-controlled emergency pause mechanism.
When paused, no new orders can be created and no existing orders can be executed. However, owners can still cancel their orders and reclaim unused fee reserves. This ensures user funds are never locked during an emergency.

Supported Strategies