Pool Maths Reference

Explore our GitHub repositoryopen in new window containing reference mathematical implementations, in Javascript and Python, for supported Balancer pool types. Designed to assist developers and integrators in understanding the underlying swap calculations, these implementations can be imported as a packages into your project or serve as a reference for your own implementation.

Supported Pool Types

Weighted Pool

Pools that swap tokens by enforcing a Constant Weighted Product invariant.

See SC code implementation hereopen in new window.

Stable Pool

Pools that swap tokens by enforcing a Stable Math invariant, based on Curve.

See SC code implementation hereopen in new window.

Notes:

  • Amplification factor can be dynamic see:
    • getAmplificationParameter() view function
    • AmpUpdateStarted & AmpUpdateStopped events