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

Setup

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
INFURA=

Initialize the SDK in your code using

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

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