Frontrunning Considerations and Parameter Confidentiality
TWAP strategies, especially when executed on fixed, predictable intervals (e.g. every 1 minute), can be vulnerable to frontrunning or anticipatory trading—particularly in illiquid markets. An external observer monitoring the chain might attempt to front-run a known pattern by entering positions shortly before the TWAP executes and exiting afterward.
What Can Be Seen On-Chain
When a TWAP executes, each transaction is broadcast and mined like any other on-chain action. This means:
Observers can see the transaction payload (e.g. token pair, amount, swap route, and timestamp)
Observers cannot see the full scope of the automation (e.g. how long it will run or how many intervals are left)
What Remains Private
Critical parameters such as:
Total duration
Number of total orders
Interval between trades
Randomization logic (if enabled) are not stored on-chain, nor embedded in any public contract.
Instead, these parameters are kept off-chain in Brahma’s backend database, and are linked to each user’s TWAP via a Policy Hash, which is used to match and execute the automation. This policy hash is not the transaction hash—it is a backend identifier tied to the user's specific automation settings.
Because these settings aren’t on-chain, an external observer cannot know whether a trade is the first, last, or one of many in a series—unless the user shares this information publicly.
Randomization as a Future Mitigation (v1.1)
Randomization of execution—such as:
Varying the time interval between trades slightly
Varying the size of each order
Introducing controlled jitter to execution timing
...is the most effective defense against predictable execution patterns and frontrunning. These features are currently in development for v1.1 and would obscure predictable trade behavior even further, making it materially harder for adversaries to anticipate execution schedules.
Note: This level of protection is not present in many on-chain TWAP systems, including those used by major providers like Jupiter.
Practical Takeaway
While the current system ensures that key parameters remain private, users should still understand that predictability of execution timing can be a vector for frontrunning—especially in thin markets. Until randomization is deployed, users are advised to:
Avoid using TWAP for extremely large orders on low-liquidity assets with exact intervals
Break up orders across broader timeframes
Monitor impact manually or combine with other execution strategies where necessary
Last updated