BalancerV2: The Python Edition

Originally written in Solidity, our team has translated the files attempting to achieve the exact same results in python. In order to achieve accurate results, the python Decimal library was used in all of the following.

The Python edition of BalancerV2 contains these modules:

The Python edition of BalancerV2 contains these modules:

  • StableMath.py - this file contains the calculations for a stable pool.

  • StablePool.py - this file contains all the functions that enable a stable pool to take actions such as swapping or joining a pool.

  • WeightedMath.py - this file contains the calculations for a weighted pool.

  • WeightedPool.py - this file contains all the functions that enable a weighted pool to take actions such as swapping or joining a pool.

  • BalancerConstants.py - this file contains all of the constant values that are needed to make precise calculations.

  • util.py - this file handles all of the basic mathematical functions such as adding, subtracting, multiplying and dividing however each one having a version that either rounds up or down ex. mulUp and mulDown.

Last updated