Strategies
Overview
Strategies in the Almanak Platform are Python applications that define the automated decision-making and execution logic for your DeFi operations. Implemented as state machines, these strategies are designed to run on Almanak's high-reliability infrastructure while maintaining privacy and security.
Key Characteristics
- Python-based: Written in Python, allowing for flexible and powerful programming capabilities
- State Machine Architecture: Enables complex decision trees and branching logic based on market conditions
- High Reliability: Runs on Almanak's dedicated infrastructure with robust monitoring and failover mechanisms
- Private by Default: All strategy code is encrypted to protect your proprietary trading logic
- Abstracted Transaction Logic: No need to handle low-level blockchain interactions, wallet management, or transaction signing
How Strategies Work
Strategies operate as the "brain" of your Agents, determining what actions to take based on:
- Market Conditions: Current prices, liquidity, volatility, etc.
- Wallet State: Available balances, existing positions, etc.
- Custom Parameters: User-defined thresholds, targets, and other configuration options
When a strategy is executed by an Agent, it:
- Evaluates current conditions using Sensors that fetch data from data feeds and on-chain sources
- Determines which actions to take based on its programmed logic
- Creates and submits Action Bundles for execution
- Transitions to appropriate states based on execution results
Strategy Framework
The Almanak Strategy Framework provides a structured way to develop strategies without worrying about the complexities of blockchain transactions. This framework consists of several key components:
Actions & Action Bundles
Actions represent atomic operations that can be performed on the blockchain, such as:
- Token swaps
- Liquidity provision
- Lending/borrowing
- Position management
Action Bundles group multiple Actions to be executed together, ensuring atomicity and reducing gas costs. For more details, see the Actions & Action Bundles documentation.
Core Classes
The Strategy Framework includes essential base classes and utilities for strategy development:
- Strategy base classes
- State management
- Event handling
- Data access layers
These components streamline the development process and ensure consistent behavior across strategies. For more information, see the Core Classes documentation.
Protocols
Protocols are pre-built collections of Actions that interface with specific DeFi protocols on particular blockchains. They provide ready-to-use implementations for common operations like:
- Trading on decentralized exchanges (Uniswap, SushiSwap, etc.)
- Lending and borrowing (Aave, Compound, etc.)
- Yield farming on various platforms
Using Protocol implementations saves development time and ensures best practices for interacting with these services. Learn more in the Protocols documentation.
Creating Strategies
There are two ways to create Strategies in the Almanak Platform:
SDK-based Development
Create strategies by writing Python code using the Almanak SDK. This approach offers maximum flexibility and control, allowing you to:
- Define complex logic and conditions
- Integrate with custom data sources
- Fine-tune parameters and execution flows
- Create highly optimized strategies for specific use cases
Natural Language Strategy Creation (Coming Soon)
Almanak is developing a UI-based flow that allows users to create strategies using natural language descriptions:
- Describe your strategy goals and parameters in plain English
- A Multi-agent system processes your input and generates the appropriate strategy code
- Review, modify, and deploy the generated strategy through the Almanak interface
- No coding experience required
This feature is currently under development and will be released in the coming weeks.
Strategy Execution
Strategies are executed by Agents according to your specified schedule or trigger conditions. The execution environment provides:
- Access to real-time market data
- Secure access to wallet permissions through the Zodiac Roles Modifier
- Comprehensive logging and monitoring
- Exception handling and automatic retries
Security Considerations
- All strategy code is encrypted at rest and in transit
- Execution occurs in isolated environments with strict resource limitations
- Permission scopes are strictly enforced through the Zodiac Roles Modifier
- No direct access to private keys at any point
Getting Started
To begin developing your own strategies, see our Quickstart Guide or explore the specific Strategy Tutorials for common use cases like trading, lending, and market making.