Skip to main content

Balancer Analytics with Python

Project description

balancerpy

Python package for Balancer V2 modelling

  • Currently in Beta (version 0.0.10) until fully tested and analyzed

Install

To install package:

> git clone https://github.com/defipy-devs/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
  • 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()

Project details


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.10.tar.gz (13.4 kB view details)

Uploaded Source

File details

Details for the file balancerpy-0.0.10.tar.gz.

File metadata

  • Download URL: balancerpy-0.0.10.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.0rc2

File hashes

Hashes for balancerpy-0.0.10.tar.gz
Algorithm Hash digest
SHA256 a4061e37aae93f6251caa13de399194d11b8d244911b036fd50f5d874147a9b4
MD5 d8d09c48a6dc0eacc1630aa16db99c82
BLAKE2b-256 97a94e16650dad8176fb304d9f4b1c302562b5a4f30b19068c51592feb2f1b15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page