Autonomous trading agents for decentralized finance on AO
Execute limit orders, stop-losses, and DCA strategies without centralized intermediaries
Features β’ Architecture β’ Strategies β’ Getting Started β’ License
β οΈ ARCHIVED PROJECTThis project is archived and no longer maintained. It is provided as-is for educational and reference purposes. No support, updates, or bug fixes will be provided.
Originally developed by Autonomous Finance
|
Execute trades at your target price or better. Supports partial fills across multiple swaps with eager execution. |
Protect your positions with stop-loss triggers. Choose between market or limit execution when thresholds are hit. |
|
Dynamic stop prices that follow favorable price movements, automatically locking in profits while limiting downside. |
Dollar-cost averaging with configurable intervals. Automatically distribute capital across time-based executions. |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FACTORY PROCESS β
β β’ Spawns & tracks agents β’ Manages subscriptions β
β β’ Stores configurations β’ Handles lifecycle events β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββ
β AGENT 1 β β AGENT 2 β β AGENT N β
β Limit β β Stop β β DCA β
β Order β β Order β β Order β
βββββββββββββ βββββββββββββ βββββββββββββ
β β β
βββββββββββββββΌββββββββββββββ
βΌ
βββββββββββββββββββββββββββ
β AMM PRICE FEEDS β
β (Dexi Subscriptions) β
βββββββββββββββββββββββββββ
- Factory creates agent processes with specific trading configurations
- Agents subscribe to real-time AMM price updates
- When conditions are met, agents autonomously execute trades
- Upon completion, agents finalize and return funds to the owner
A limit order fills your trade at a specific price or better:
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Input: 100 TOKEN_A β
β Min Output: 500 TOKEN_B β
β βββββββββββββββββββββββββββββ β
β β Partial fills supported β
β β Eager execution on favorable prices β
β β Optional stop-loss attachment β
ββββββββββββββββββββββββββββββββββββββββββββββββ
Triggers when price crosses your threshold:
| Type | Behavior |
|---|---|
| Stop-Market | Immediate swap at current price |
| Stop-Limit | Places limit order when triggered |
| Trailing Stop | Dynamic threshold follows price |
Automated periodic trading:
Day 1 Day 2 Day 3 Day 4 Day 5
β β β β β
βΌ βΌ βΌ βΌ βΌ
βββββ βββββ βββββ βββββ βββββ
β$20β β$20β β$20β β$20β β$20β = $100 total
βββββ βββββ βββββ βββββ βββββ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β CREATION ββββββΆβ DEPOSIT ββββββΆβ SUBSCRIPTIONβ
β β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β READY ββββββΆβ SWAPPING ββββββΆβ FINALIZED β
β Monitoring β β Executing β β Complete β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
| State | Description |
|---|---|
AwaitingStrategyConfiguration |
Initial state after creation |
AwaitingDeposit |
Waiting for user to fund the agent |
AwaitingSubscription |
Waiting for price feed subscription |
Ready |
π’ Active and monitoring for trade conditions |
Swapping |
π Currently executing a swap |
Complete |
β Strategy successfully completed |
Expired |
β° Order expired before completion |
Canceled |
β User cancelled the order |
EmergencyExited |
π¨ Emergency withdrawal executed |
- Lua 5.4.6
- LuaRocks (package manager)
- Teal 0.15.3 (typed Lua)
- Cyan 0.3.1 (Teal build tool)
- amalg (Lua bundler)
- Node.js 18+ (for tooling)
# Clone the repository
git clone https://github.com/Autonomous-Finance/limit-order-agent.git
cd limit-order-agent
# Install Node dependencies
npm install
# Build the project
npm run build
# Run tests
npm testThe build process produces:
build/agent.lua- Bundled agent process codebuild/factory.lua- Bundled factory process code (includes agent source)
limit-order-agent/
βββ π src/
β βββ π agent/ # Agent process implementation
β β βββ agent.tl # Main agent module
β β βββ swaps.tl # Swap execution logic
β β βββ π strategies/ # Strategy implementations
β β βββ limit-order.tl
β β βββ stop-order.tl
β β βββ dca-order.tl
β β βββ π primitives/ # Composable building blocks
β βββ π factory/ # Factory process implementation
β β βββ factory.tl # Main factory module
β β βββ queries.tl # Database queries
β β βββ sqlschema.tl # SQLite schema
β βββ π utils/ # Shared utilities
β βββ π typedefs/ # Type definitions
βββ π test/ # Unit tests
β βββ π mocked-env/ # Mock AO environment
β βββ unit_test_*.lua # Test suites
βββ π scripts/ # Build & test scripts
βββ π packages/ # External packages
Agents are configured through process tags when spawned:
| Tag | Description | Required |
|---|---|---|
Amm |
AMM process ID for trading | β |
Token-From |
Input token process ID | β |
Token-To |
Output token process ID | β |
Input |
Amount of input token | β |
Expires-At |
Expiration timestamp | β |
Order-Owner |
Owner wallet address | β |
Limit Order
| Tag | Description |
|---|---|
Min-Output |
Minimum acceptable output amount |
Stop-Price |
(Optional) Stop-loss trigger price |
Stop Order
| Tag | Description |
|---|---|
Stop-Price |
Price threshold to trigger execution |
Is-Stop-Limit |
true for limit execution, false for market |
Is-Trailing |
true for trailing stop functionality |
Trailing-Difference |
Basis points for trailing distance |
DCA Order
| Tag | Description |
|---|---|
Run-Time |
Total duration for DCA execution |
Tick-Interval |
(Optional) Custom interval between swaps |
| Technology | Purpose |
|---|---|
| Teal | Typed Lua for safer code |
| AO | Decentralized compute on Arweave |
| Cyan | Teal project build tool |
| Busted | Lua testing framework |
| SQLite | Embedded database for factory |
This software is provided "as is" without warranty of any kind. Use at your own risk. The authors are not responsible for any financial losses incurred through the use of this software.
This is experimental DeFi software. Always:
- Test with small amounts first
- Understand the risks of AMM trading
- Review the code before deploying with real assets
This project is licensed under the MIT License - see the LICENSE.md file for details.
Originally developed with β€οΈ by Autonomous Finance
Building the future of autonomous finance on Arweave