Dissecting the Balancer V2 protocol (Part 1)

Trade with gas efficiency!

Andrew Hong
Coinmonks
Published in
13 min readMay 17, 2021

--

This was first published on substack, make sure to follow 0xkowloon for more protocol deep dives.

Balancer protocol is an automated portfolio manager, liquidity provider and price sensor. Liquidity providers who want to earn trading fees and rebalance their portfolios can deposit their assets into a balancer pool. Arbitrageurs help liquidity providers to rebalance their portfolios by trading against the pools’ assets.

Contrary to Uniswap, which only holds two tokens in each pool, a balancer pool can hold up to eight tokens. A pool’s underlying token weights and trading fees are set when it is initialized. The pool’s weights are rebalanced when a trade happens to ensure each token maintains a proportional value to the rest of the pool. The protocol executes each trade by finding the most profitable route (Smart Order Routing), taking into account the amount, fees and gas costs.

Balancer V2 can be a cheaper protocol for traders because it is designed in a way that makes each trade consume less gas. Even if a trader’s input and output tokens belong to different pools, which in a typical decentralized exchange requires ERC-20 transfers to hop along the token path, Balancer V2 does not require the ERC-20 hops in the middle. Its vault keeps track of each…

--

--

Andrew Hong
Coinmonks

Follow me on @andrewhong5297 on twitter for more data insights