While a V3 DEX gives each pool its own contract, in Henjin V4 DEX all DeFi pools go into a single contract. This should make the creation of a new pool 99% cheaper. Crucial is the role of the Pool Manager, a piece of software that maintains and maps all different pools. Pool Manager then also performs the swaps, and updates the pools. All operations will go through the Pool Manager.
The Pool Manager is also referred to as the Singleton Contract. Instead of moving assets in and out of different pools to perform a swap, this contract only moves net balances. This makes the entire system highly efficient, saving users a lot more gas fees in Henjin V4.
Another innovative V4 feature feature has been dubbed Flash Accounting. This system allows users to efficiently chain together multiple actions, for example swapping and adding liquidity. The system tracks the net balances of inbound and outbound tokens, and in the end the contract verifies that all debts have been settled by the user. The entire string of actions can only happen when the user has the gas fees and the necessary tokens. If not, the system will revert the transaction. Henjin v4 hopes to reduce gas costs and enhance efficiency on the platform.
Henjin V4 introduces hooks, allowing developers to customise liquidity pools by attaching smart contracts to it. These hooks offer a high degree of customization, not seen in previous iterations of Henjin liquidity pools. For example, hooks can enable different types of orders, like limit orders. In addition, hooks can allow for tailored oracles, or custom market maker functionalities.
In the past V3 DEXs only allowed for transactions to happen then and now, but V4 DEXs introduce time-weighted average market maker functionality. This means that users can set a command to for example purchase $100 worth of ETH every 2 hours for a total of 24 hours.
Time-weighted average market maker, or TWAMM, is an example of a hook. TWAMM gets traders better prices by splitting a large order into smaller swaps that steadily execute over time. These types of swaps are less likely to impact the token price. Henjin V4 will always process TWAMM orders before any other trades or LP transactions. This protects users from frontrunning bots, or simply MEVs.
Through hooks, users and developers can expect a lot more interoperability with other Ethereum protocols and standards. This would enable complex interactions between different DeFi protocols, but also actions with SocialFi or games. This will generate more fees, which benefit liquidity providers.
In addition, the dynamic fees introduced in V4 DEXs can give liquidity providers more control, and with that comes a potential for increased earnings. For example, they could implement withdrawal fees to discourage selling tokens or LP positions.
In summary, a V4 DEX or AMM can be summarised by the following features :