Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

jkirkpatrick/balancer-v2-monorepo

 
 

Repository files navigation

Balancer

Balancer V2 Minirepo

THIS IS A PARTIAL CLONE (sparse-checkout) of Balancer V2 Monorepo

Docs

License

This repository contains the Balancer Protocol V2 core smart contracts, including the Vault and standard Pools, along with their tests, configuration, and deployment information.

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

Structure

This is a monorepo supporting npm workspaces, 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

  • v2-pool-stable: contracts for the Balancer V2 Stable Pool, Composable Stable Pool, and Stable Math libraries.
  • v2-balancer-js: a JavaScript SDK which provides commonly used utilities for interacting with the V2 Balancer Protocol

Pre-requisites

NOTE: This minirepo is going to be updated to ensure compatiblity with: node v18 (LTS), npm v9, solc v0.8.19

NOTE: remove hardhat-waffle, ethereum-waffle

NOTE: balancer-js uses rollup for builds

// DONE!
dependencies: {
  // yarn-only (incorrect)
  "@balancer-labs/foo": "workspace:*",

  // general / npm-compatible (correct)
  "@balancer-labs/foo": "file:../foo",
},

// TODO
scripts: {
  // yarn-only (incorrect) ... linting is inconsistent, often eslint is used
  "lint": "yarn lint:typescript",

  // general / npm-compatible (correct)
  "lint": "npx lint:typescript" // or "npm run lint:typescript"
}

Clone

This repository is a fork the original repository:

cd balancer/
git submodule init
git submodule update

# pull in patches from upstream balancer-v2-monorepo into this repository:
git pull upstream master && git push origin main

# fix submodules
git submodule update --init

Build and Test

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

$ npm install # install all dependencies
$ npm build # compile all contracts

Most tests are standalone and simply require installation of dependencies and compilation. Some packages however have extra requirements. Notably, the v2-deployments package must have access to mainnet archive nodes in order to perform fork tests. For more details, head to its readme file.

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

$ npm test # run all tests

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

$ cd pkg/<package> 
$ npm test

The minirepo is adding support for eth-gas-reporter

$ npm run gas # entire repo
$ cd pkg/<package> && npm run gas # e.g. cd pkg/v2-vault and view gas report for v2-vault

Foundry (Forge) tests

NOTE: FIX testing

  • MISSING: pvt/forge-std (submodule install location)
  • MISSING: foundry.toml (lots of symlinks in repo)

Security

All core smart contracts are immutable, and cannot be upgraded.

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.

About

Balancer V2 Monorepo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 57.4%
  • Solidity 38.9%
  • Vyper 3.6%
  • JavaScript 0.1%