This repository contains Balancer Protocol V2's core smart contract, the Vault
, along with auxiliary contracts such as the WeightedPoolFactory
.
For a high-level introduction to Balancer V2, see Introducing Balancer V2: Generalized AMMs.
Active development occurs in this repository, which means some contracts in it may not be production-ready. Proceed with proper care.
contracts
: source code for all smart contracts in the system.vault
stores theVault
contract, which is split across many files for separation of concerns and clarity.pools
keeps the code for the different Pool types and related contracts, such as factories.test
holds contracts that are only used for testing purposes, often with lax access control patterns and other unsafe properties.
test
: unit tests for each smart contract, using ethers and waffle chai matchers. Thehelpers
subdirectory holds utilities used to simplify writing assertions, deploying test contracts, etc., with the overall goal of making tests more ergonomic and less verbose.lib
: miscellaneous files used for deployment, gas benchmarking, testing and so on.
This repository will soon be migrated into a monorepo, making the different contracts, interfaces and libraries easier to use by third parties. Stay tuned!
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.
Most of the source code is licensed under the GNU General Public License Version 3 (GPL v3): see LICENSE
.
- All files under
contracts/lib/openzeppelin
, are based on the OpenZeppelin Contracts library, and as such are licensed under the MIT License: see LICENSE. contracts/lib/math/LogExpMath.sol
is licensed under the MIT License.- All other files under
lib
andtest
are unlicensed.
In your .env file, add these -
DEPLOYER_PRIVATE_KEY=
CONTROLLER_PRIVATE_KEY=
CREATOR_PRIVATE_KEY=
OTHER_PRIVATE_KEY=
The basic deployment: Authorizer, Vault, WETH and Weighted Pools
yarn hardhat deploy --network neonDevnet
# replace deployed addresses in lib/scripts/gas-measurement/contracts.ts
# Run these scripts for gas measurement
$ yarn measure-gas-deployment --network neonDevnet
$ yarn measure-gas-multihop --network neonDevnet
$ yarn measure-gas-join-exit --network neonDevnet
$ yarn measure-gas-single-pair --network neonDevnet