Balancer SDK

The Balancer SDK is a Typescript/Javascript library for interfacing with the Balancer protocol. This includes common contract interactions, calculations, the Smart Order Router, and more.

npm versionopen in new window

Some functionality of the SDK, including the SOR can also be accessed via the Balancer API for developers not using ts. Find details in the API Section


Install the package with

The SDK uses the below environment variables as part of the configuration. Set these in an .env file or your preferred way of loading ENV variables

# .env

Initialize the SDK in your code using

import { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';

const config: BalancerSdkConfig = {
  network: Network.MAINNET,
  rpcUrl: `${process.env.INFURA}`,
const balancer = new BalancerSDK(config);