SDK
overview
Intro

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 version (opens in a new tab)

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

Setup

Install the package with

::: code-tabs#shell

@tab yarn

yarn install @balancer-labs/sdk

@tab npm

npm install @balancer-labs/sdk

:::

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);

© 2023 Balancer Labs