• Stars
    star
    309
  • Rank 134,985 (Top 3 %)
  • Language
    TypeScript
  • License
    GNU General Publi...
  • Created about 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Balancer V2 Monorepo

Balancer

Balancer V2 Monorepo

Docs CI Status License

This repository contains the Balancer Protocol V2 core smart contracts, including the Vault and standard Pools, along with their tests. Deployment configuration and information can be found at the balancer-deployments repository.

For a high-level introduction to Balancer V2, see Introducing Balancer V2: Generalized AMMs.

Structure

This is a Yarn monorepo, with the packages meant to be published in the pkg directory. Newly developed packages may not be published yet.

Active development occurs in this repository, which means some contracts in it might not be production-ready. Proceed with caution.

Packages

Pre-requisites

The build & test instructions below should work out of the box with Node 18. More specifically, it is recommended to use the LTS version 18.15.0; Node 19 and higher are not supported. Node 18.16.0 has a known issue that makes the build flaky.

Multiple Node versions can be installed in the same system, either manually or with a version manager. One option to quickly select the suggested Node version is using nvm, and running:

$ nvm use

Clone

This repository uses git submodules; use --recurse-submodules option when cloning. For example, using https:

$ git clone --recurse-submodules https://github.com/balancer-labs/balancer-v2-monorepo.git

Build and Test

Before any tests can be run, the repository needs to be prepared:

First time build

$ yarn # install all dependencies
$ yarn workspace @balancer-labs/balancer-js build # build balancer-js first

Regular build

$ yarn build # compile all contracts

Most tests are standalone and simply require installation of dependencies and compilation.

In order to run all tests (including those with extra dependencies), run:

$ yarn test # run all tests

To instead run a single package's tests, run:

$ cd pkg/<package> # e.g. cd pkg/v2-vault
$ yarn test

You can see a sample report of a test run here.

Foundry (Forge) tests

To run Forge tests, first install Foundry. The installation steps below apply to Linux or MacOS. Follow the link for additional options.

$ curl -L https://foundry.paradigm.xyz | bash
$ source ~/.bashrc # or open a new terminal
$ foundryup

Then, to run tests in a single package, run:

$ cd pkg/<package> # e.g. cd pkg/v2-vault
$ yarn test-fuzz

Security

Multiple independent reviews and audits were performed by Certora, OpenZeppelin and Trail of Bits. The latest reports from these engagements are located in the audits directory.

Bug bounties apply to most of the smart contracts hosted in this repository: head to Balancer V2 Bug Bounties to learn more.

All core smart contracts are immutable, and cannot be upgraded. See page 6 of the Trail of Bits audit:

Upgradeability | Not Applicable. The system cannot be upgraded.

Licensing

Most of the Solidity source code is licensed under the GNU General Public License Version 3 (GPL v3): see LICENSE.

Exceptions

  • All files in the openzeppelin directory of the v2-solidity-utils package are based on the OpenZeppelin Contracts library, and as such are licensed under the MIT License: see LICENSE.
  • The LogExpMath contract from the v2-solidity-utils package is licensed under the MIT License.
  • All other files, including tests and the pvt directory are unlicensed.

More Repositories

1

balancer-core

Balancer on the EVM
Solidity
333
star
2

balancer-sor

Smart order router: off-chain linear optimization of routing orders across pools for best price execution
TypeScript
218
star
3

frontend-v2

Frontend app for the Balancer protocol
TypeScript
187
star
4

balancer-subgraph-v2

Subgraph (Graph Protocol) data layer for Balancer v2 vault, swaps, txs, users
TypeScript
118
star
5

balancer-exchange

Exchange dapp for token swaps
TypeScript
95
star
6

bal-mining-scripts

TypeScript
88
star
7

erc20-redeemable

Vue
79
star
8

balancer-sdk

TypeScript
77
star
9

frontend-v1

V1 Pool Management
Vue
75
star
10

balancer-subgraph

Subgraph (Graph Protocol) data layer for Balancer pools, swaps, txs, users
TypeScript
67
star
11

balpy

Tools for interacting with Balancer Protocol V2 in Python.
Python
64
star
12

docs

Documentation for Balancer
Vue
44
star
13

balancer-deployments

TypeScript
41
star
14

balancer-v3-monorepo

Solidity
38
star
15

configurable-rights-pool

JavaScript
34
star
16

tokenlists

TypeScript
30
star
17

assets

JavaScript
27
star
18

scaffold-balancer-v3

Starter kit for creating custom pools and hooks contracts on Balancer v3
TypeScript
24
star
19

pool-management

Pool management dapp
TypeScript
22
star
20

swap-frontend-v1

Balancer Protocol Frontend
Vue
21
star
21

exchange-proxy

Solidity
21
star
22

b-sdk

TypeScript
20
star
23

balancer-api

Deprecated
TypeScript
18
star
24

backend

TypeScript
16
star
25

docs-developers

15
star
26

balancer-registry

Solidity
14
star
27

docs-v1

13
star
28

bactions-proxy

Solidity
11
star
29

code-review

JavaScript
10
star
30

balancer-examples

Template repository to begin building on Balancer V2
TypeScript
9
star
31

frontend-v3

Official web application for the Balancer protocol.
TypeScript
9
star
32

docs-v2-archive

7
star
33

linear-pools

TypeScript
6
star
34

scaffold-balancer

TypeScript
5
star
35

brand-assets

4
star
36

balancer-sor-v1

Legacy SOR for V1
TypeScript
3
star
37

ipfs-push

TypeScript
3
star
38

balancer-cred

Shell
3
star
39

pebbles

grug stack rock
HTML
3
star
40

docs-v3

Vue
3
star
41

gauges-subgraph

Subgraph for Liquidity Gauges of the Balancer Protocol
TypeScript
3
star
42

cow-amm

Solidity
3
star
43

dune_queries

PLpgSQL
2
star
44

balancer-bounties

https://bounties.balancer.finance
Vue
2
star
45

helpers

Collection of contracts and JS code for common data dependencies
Solidity
2
star
46

frontend-monorepo

Balancer frontend apps and packages. Includes the official Balancer UI application.
TypeScript
2
star
47

metastable-rate-providers

Rate provider adaptors used by MetaStable pools
Solidity
1
star
48

marketing-site

Marketing site
Vue
1
star
49

frontend-e2e

TypeScript
1
star
50

sor-benchmark

TypeScript
1
star
51

metadata

1
star
52

pool-creator

A user friendly interface for creating and initializing pools
TypeScript
1
star