Balancer: the Python edition

The same Balancer, but coded in Python

The model has been built emulating the operations of Balancer's BPool smart contracts. We made an initial 1:1 port to python to test and match we could get similar results than Solidity, and the split the logic (into policies) and state (state variables and state update functions) in order to create a cadCAD compatible model.

This is an initial iteration built to reproduce and test the model's behaviour following existing pools, so there is no agents or behaviours (yet!), but it's modular enough so they could be added later.

The Python edition of Balancer contains several modules:

Basic state update functions are omitted in the docs. If you need more info, check the repo

The initial BPool port is kept as a reference:

  • balancer_pool.py - the core of Balancer Pool, in a python class.

Some simplifications and omissions were made, like no token binding logic, no need for security limits in the trade (max price, min token amount in...) since in cadCAD we don't have delayed transactions or reordering. To know more about this, check verification & limitations page.

Last updated