{"id":26162484,"url":"https://github.com/balancer/balancer-v3-monorepo","last_synced_at":"2025-04-06T06:06:48.009Z","repository":{"id":246899336,"uuid":"630655612","full_name":"balancer/balancer-v3-monorepo","owner":"balancer","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-28T15:27:03.000Z","size":14178,"stargazers_count":83,"open_issues_count":31,"forks_count":52,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T05:06:26.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/balancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/README.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-20T21:21:10.000Z","updated_at":"2025-03-29T17:43:14.000Z","dependencies_parsed_at":"2024-08-27T17:59:40.885Z","dependency_job_id":"4aedc0bd-5fb9-4cf4-9603-1c0dc554f157","html_url":"https://github.com/balancer/balancer-v3-monorepo","commit_stats":null,"previous_names":["balancer/balancer-v3-monorepo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-v3-monorepo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-v3-monorepo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-v3-monorepo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-v3-monorepo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balancer","download_url":"https://codeload.github.com/balancer/balancer-v3-monorepo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441042,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T13:54:39.218Z","updated_at":"2025-04-06T06:06:47.983Z","avatar_url":"https://github.com/balancer.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"logo.svg\" alt=\"Balancer\" height=\"128px\"\u003e\n\n# Balancer V3 Monorepo\n\n[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.balancer.fi/)\n[![CI Status](https://github.com/balancer/balancer-v3-monorepo/workflows/CI/badge.svg)](https://github.com/balancer/balancer-v3-monorepo/actions)\n[![License](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\nThis repository contains the Balancer Protocol V3 core smart contracts, including the `Vault` and standard Pools, along with their tests.\n\n## Structure\n\nThis is a Yarn monorepo, with the packages meant to be published in the [`pkg`](./pkg) directory. Newly developed packages may not be published yet.\n\nActive development occurs in this repository, which means some contracts in it might not be production-ready. Proceed with caution.\n\n### Packages\n\n- [`v3-interfaces`](./pkg/interfaces): Solidity interfaces for all contracts.\n- [`v3-solidity-utils`](./pkg/solidity-utils): miscellaneous Solidity helpers and utilities used in many different contracts.\n- [`v3-pool-hooks`](./pkg/pool-hooks/): hook examples to illustrate potential capabilities and how to build one.\n- [`v3-pool-utils`](./pkg/pool-utils/): Solidity utilities used to develop Pool contracts.\n- [`v3-pool-stable`](./pkg/pool-stable/): contains [`StablePool`](./pkg/pool-stable/contracts/StablePool.sol), along with its associated factory.\n- [`v3-pool-weighted`](./pkg/pool-weighted): contains [`WeightedPool`](./pkg/pool-weighted/contracts/WeightedPool.sol), along with its associated factory.\n- [`v3-vault`](./pkg/vault): contains the main [`Vault`](./pkg/vault/contracts/Vault.sol) contract, which is the cornerstone of Balancer V3, and its extensions. Also includes the standard [`Router`](./pkg/vault/contracts/Router.sol) and [`BatchRouter`](./pkg/vault/contracts/BatchRouter.sol), which supports end-user interactions with the Vault.\n\n## Pre-requisites\n\nThe build \u0026 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](https://github.com/NomicFoundation/hardhat/issues/3877) that makes the build flaky.\n\nMultiple Node versions can be installed in the same system, either manually or with a version manager.\nOne option to quickly select the suggested Node version is using `nvm`, and running:\n\n```bash\n$ nvm use\n```\n\nSolidity 0.8.24 or higher is required to support the upcoming Cancun hard fork with transient storage. We strongly recommend using the latest released version of the Solidity compiler (at least 0.8.24), to incorporate all the latest bug fixes.\n\n## Build and Test\n\nBefore any tests can be run, the repository needs to be prepared:\n\n### First time build\n\n```bash\n$ yarn # install all dependencies\n```\n\nYou will also need to configure your environment variables to point to RPC endpoints in order to run fork tests.\nWrite your preferred RPC URL to `.env`, and source it. For example:\n\n```bash\n$ sed 's,YOUR_MAINNET_RPC_URL,\u003cYOUR_RPC_URL\u003e,g' .env.example \u003e .env\n$ source .env\n```\n\n### Regular build \u0026 test\n\n```bash\n$ yarn build # compile all contracts\n```\n\nMost tests are standalone and simply require installation of dependencies and compilation.\n\nIn order to run all tests (including those with extra dependencies), configure your RPC endpoints by sourcing your `.env` file and run:\n\n```bash\n$ yarn test # run all tests\n```\n\nTo instead run a single package's tests, run:\n\n```bash\n$ cd pkg/\u003cpackage\u003e # e.g. cd pkg/vault\n$ yarn test\n```\n\nYou can see a sample report of a test run [here](./audits/test-report.md).\n\n#### Foundry (Forge) tests\n\nTo instead run a single package's forge tests, run:\n\n```bash\n$ cd pkg/\u003cpackage\u003e # e.g. cd pkg/vault\n$ yarn test:forge\n```\n\n#### Hardhat tests\n\nTo instead run a single package's hardhat tests, run:\n\n```bash\n$ cd pkg/\u003cpackage\u003e # e.g. cd pkg/vault\n$ yarn test:hardhat\n```\n\nHardhat tests will also update snapshots for bytecode size and gas usage if applicable for a given package.\n\n### Medusa tests\n\nMedusa is a tool, developed by Trail of Bits, that allow us to execute stateful fuzz tests in contracts, in a way\nsmarter than Forge. That's because Medusa has an optimizer to create a path of transactions which is not completely\nrandom.\n\nTo run Medusa tests, we first need to install Echidna. To do so, install `echidna` using the \n[release page](https://github.com/crytic/echidna/releases) or `brew install echidna` on a Mac. Notice that the Mac\ninstallation will also install Crytic-compiler, so this step can be skipped when installing Medusa.\n\nThen, install Medusa using this [installation guide](https://github.com/crytic/medusa/blob/master/docs/src/getting_started/installation.md#building-from-source), `brew install medusa` on a Mac. Alternatively, just copy the adequate precompiled binary to a directory within your `PATH`.\n\nFinally, run `yarn test:medusa`. This command is available inside the packages `vault`, `pool-weighted` and \n`pool-stable`.\n\n## Static analysis\n\nTo run [Slither](https://github.com/crytic/slither) static analyzer, Python 3.8+ is a requirement.\n\n### Installation in virtual environment\n\nThis step will create a Python virtual environment with Slither installed. It only needs to be executed once:\n\n```bash\n$ yarn slither-install\n```\n\n### Run analyzer\n\n```bash\n$ yarn slither\n```\n\nThe analyzer's global settings can be found in `.slither.config.json`.\n\nSome of the analyzer's known findings are already filtered out using [--triage-mode option](https://github.com/crytic/slither/wiki/Usage#triage-mode); the results of the triage can be found in `slither.db.json` files inside each individual workspace.\n\nTo run Slither in triage mode:\n\n```bash\n$ yarn slither:triage\n```\n\n### Coverage\n\n```bash\n$ yarn coverage\n```\n\nThe `coverage` command generates a coverage report for each package found in the `./package/coverage/index.html` directory. The `coverage.sh` script can generate Forge and Hardhat reports and/or merge them. The Yarn command uses Forge by default as most of the tests are written with it, and it's the most reliable option.\n\n**Note: We suggest adopting [lcov 1.16](https://github.com/linux-test-project/lcov/releases/tag/v1.16) since `forge coverage --report lcov` command works better in this version.**\n\n## Security\n\n\u003e Upgradeability | Not Applicable. The system cannot be upgraded.\n\n## Licensing\n\nMost of the Solidity source code is licensed under the GNU General Public License Version 3 (GPL v3): see [`LICENSE`](./LICENSE).\n\n### Exceptions\n\n- All other files, including tests and the [`pvt`](./pvt) directory are unlicensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalancer%2Fbalancer-v3-monorepo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalancer%2Fbalancer-v3-monorepo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalancer%2Fbalancer-v3-monorepo/lists"}