Recently, Uniswap released its fourth version, whose code is again locked under a 2.5-year license. As I mentioned earlier, all versions of Uniswap are protected against copying by licenses. In the case of the first version, the Algebra team simply waited for its expiration.
This time, to avoid waiting for the license to expire, Algebra took a smarter approach — the new protocol version, Algebra Integral (v2), will still be based on Uniswap v3 but with added hooks, like in Uniswap v4. This will allow moving to a modular architecture and implementing plugin support.
With this approach, it’s unlikely to create a DEX that surpasses Uni v4, but implementing similar features without violating the license is quite possible.
Modular DEX Instead of Monolith
One of the key features of Uniswap v4 is its modular architecture. The idea of a modular DEX is to create a simple, reliable, and secure core that can be extended with external modules (plugins). Not every pool needs, say, dynamic fees or a TWAP oracle, and having such functionality can significantly increase gas costs.
The previous approach to building a DEX always assumed a monolithic structure, which didn’t allow dropping unnecessary features. But by moving these functions "outside," the pool creator gains the ability to add extra "features" as needed.
Algebra managed to implement modularity through plugins. This approach, in theory, also allows adding new functionality to the DEX without the need to migrate liquidity.
Plugins
Plugins in Algebra Integral are smart contracts that can be attached to a liquidity pool to extend its functionality. Currently, only one plugin can be connected to a pool at a time. It can be disabled or replaced with another.
In theory, the new protocol architecture allows implementing a proxy plugin that enables connecting multiple plugins simultaneously (the protocol plans to develop such a plugin in the future).
Plugins can:
- perform arbitrary actions on the blockchain (including calling other contracts),
- change fees in the pool,
- perform additional checks or execute other external logic.
Plugins cannot:
- directly work with liquidity,
- modify the core mathematical formulas of the pool’s operation.
Hooks
Each plugin interacts with the pool through hooks — special callback functions that are called before and after key pool operations: initialization, position changes, swaps, flash loans, etc. This allows plugins to "hook into" the pool’s workflow and execute necessary external logic.