Balancer Integration

Details on how pool uses Balancer protocol

Integration with the Balancer

Twamm pool is built as custom pool over Balancer protocol. Specifically, we are overriding BaseWeightedPool of the balancer protocol. BaseWeightedPool provides required set of basic functionalities and security required from a liquidity pool, without the overhead of extra features as in WeightedPool.

TWAMM pool functionalities with Balancer

To achieve some of the core functionalities of the Twamm protocol, we are overriding following functionalities from the BaseWeightedPool:

  1. Place long term order: This functionality is implemented using JoinPool on the Balancer protocol. The reason being, placing a long term order can be thought of as joining a pool, the tokens internally are part of the pool liquidity and stored with the Vault.

  2. Withdraw/Cancel long term order: This functionality is implemented using ExitPool on the Balancer protocol. Just like place long term order is joining a pool, withdraw liquidity can be thought of as removing liquidity. The converted tokens are part of pool liquidity and are with the Vault.

Storage of long term order tokens

The tokens from placement of long term orders are stored with pool liquidity in the Vault. The advantage with this approach is that it adds up the security of the Vault to the tokens security. The actual value of the non-converted and converted tokens is accounted with the LongTermSwap contract. The contract takes care of manipulating the token values before any pool liquidity based operation. This way joinPool, exitPool or swap operation on the pool behaves normally as if there aren't any additional liquidity from long term orders.

Last updated