Architecture

To understand how TWAP automation operates, it’s important to first examine how Brahma accounts function under the hood. For a full technical breakdown, refer to the official Brahma documentation: https://docs.brahma.fi

Brahma Accounts are at the core of all automated actions within TWAP. These accounts are unique smart contracts derived from a user’s primary EOA wallet, enabling secure asset management and automated execution.

Execution

TWAP uses Brahma to allow users to define and automate complex execution logic. It enables trades to be split across multiple orders over a chosen time frame, with customizable parameters such as duration, number of splits, and slippage thresholds. Once configured, these actions can be executed autonomously without further user interaction.

This system is fully self-custodial. Assets remain in the user’s Safe Account throughout the entire automation process and no funds are ever deposited into contracts controlled by Brahma.

Safe Smart Accounts

A Safe Smart Account is a programmable smart contract wallet that replaces traditional seed-based EOAs with enhanced security features. These include multi-sig support and transaction guards. For each TWAP automation, a dedicated Safe is created and tied to the specific execution. This Safe manages all trade logic and execution parameters without user intervention.

Users grant permission to a dedicated Automation SubAccount, owned by their Safe, to carry out the trades. This SubAccount handles the input token, executes the predefined swap route, and returns the output token to the primary Safe. Brahma handles these executions under the hood, batching multi-step logic into a single transaction where possible.

Balance Requirements

Users must maintain a sufficient balance of the chosen input token within their Brahma wallet to complete the entire value of the TWAP execution.

Supported Tokens

The native gas asset of BERA is not supported as and input token due to limitations in the multi-call process. Any other ERC20 token is supported, as long as a valid swap route exists. Tokens can be added by name search or contract address.

Automation Initiation

TWAP automation is initiated through a single signed multicall transaction, which handles the following:

  • SubAccount Configuration: For new users, a dedicated Automation SubAccount is created—a Safe owned by the user’s main Brahma Safe, restricted by a custom policy tied to the automation parameters. Existing users reuse their current SubAccount for new automations.

  • Token Approval and Authorization: On-chain approval is granted to the SubAccount, allowing it to manage the input token, perform the swap, and return the output in one atomic transaction.

Routing Through Ooga Booga

All TWAP trades are executed through Ooga Booga.

Last updated