Balancer Analytics with Python
Project description
balancerpy
Python package for Balancer V2 modelling
- Currently in Beta (version 0.0.7) until fully tested and analyzed
Install
To install package:
> git clone https://github.com/icmoore/balancerpy
> pip install .
or
> pip install BalancerPy
Basic Weighted Pool Overview
- See test notebook for example implementation
- Python implementation of Balancer Weighted Pools 'broadly' consists of two main components
- BalancerMath.py: refactor of Balancer V2 Math solidity contract code, and was copied from BalancerPools_Model GH repos
- BalancerExchange.py: refactor of Balancer Pool solidity contract code, created in-house (+ supporting classes)
- The mapping (contract code -> math refactor -> exchange refactor) is as follows:
- Price
- BMath.calcSpotPrice() -> BalancerMath.calc_spot_price() -> BalancerExchange.get_price()
- Swapping
- BMath.calcOutGivenIn() -> BalancerMath.calc_out_given_in() -> BalancerExchange.get_amount_out()
- BMath.calcInGivenOut() -> BalancerMath.calc_in_given_out() -> BalancerExchange.get_amount_in()
- Adding Liquidity
- BMath.calcPoolOutGivenSingleIn() -> BalancerMath.calc_pool_out_given_single_in() -> BalancerExchange.join_swap_extern_amount_in()
- BMath.calcSingleInGivenPoolOut() -> BalancerMath.calc_single_in_given_pool_out() -> BalancerExchange.join_swap_pool_amount_out()
- Removing Liquidity
- BMath.calcPoolInGivenSingleOut() -> BalancerMath.calc_pool_in_given_single_out() -> BalancerExchange.exit_swap_extern_amount_out()
- BMath.calcSingleOutGivenPoolIn() -> BalancerMath.calc_single_out_given_pool_in() -> BalancerExchange.exit_swap_pool_amount_in()
- Price
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
BalancerPy-0.0.7.tar.gz
(12.8 kB
view hashes)