Core Classes
These classes are not meant to be used by the user and this explanaition is necessary to better contextualize the user.
This page provides an overview of three core classes within the Almanak SDK: TransactionManager, AccountManager, and ExecutionManager. These classes are crucial for managing, signing, and executing actions for agents deployed on the Almanak platform and are not under the user's control. Instead they are ready to be used but instead of being extended by the user, the Almanak team works on extending it.
TransactionManager
The TransactionManager
class is responsible for converting an ActionBundle
into executable transactions. It builds and validates transactions for each supported action, such as transfers, swaps, and wrapping/unwrapping tokens.
Key Responsibilities
- Action Conversion: Converts actions (e.g., transfer, swap, open/close positions) from an
ActionBundle
into actual blockchain transactions. - Protocol and Chain Support: Defines supported chains (Ethereum, Arbitrum, Optimism, Base) and protocols (e.g., Uniswap V3).
- Gas Management: Estimates and overrides gas limits as necessary, with specific adjustments for Arbitrum.
- Simulation for Execution: Uses Alchemy's API to simulate transaction bundles, checking for success and gas requirements.
Supported Actions and Protocols
The following actions are currently supported:
- TRANSFER: Token transfers between addresses.
- WRAP: Converts ETH to WETH.
- UNWRAP: Converts WETH to ETH.
- APPROVE: Grants token spending permission.
- SWAP: Token swaps using Uniswap SDK.
- OPEN_LP_POSITION: Opens a liquidity pool position.
- CLOSE_LP_POSITION: Closes a liquidity pool position.
Account Manager
The AccountManager
class handles the signing of transactions in an ActionBundle
. Once an action bundle is built by the TransactionManager
, the AccountManager
signs the transactions, preparing them for execution on the blockchain.
Key Responsibilities
- Transaction Signing: Signs each transaction in the action bundle using the appropriate signing mechanism.
Execution Manager
The ExecutionManager
class is responsible for broadcasting signed transactions to the blockchain. It manages execution, monitors transaction statuses, and handles any network-specific constraints or failure cases.
Key Responsibilities
- Broadcast Transactions: Sends signed transactions from an action bundle to the blockchain.
- Monitor Transaction Status: Tracks the status of each transaction (e.g., pending, success, failure).
- Retry Mechanism: Implements retry mechanisms to handle network issues and increase transaction reliability.
- Network-Specific Execution: Supports only specific networks (e.g., Ethereum Mainnet) and handles limitations per chain/network combination.