Skip to content

Commit

Permalink
chore: merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Jul 25, 2024
2 parents c717bd2 + 0fe7750 commit 1eedf2f
Show file tree
Hide file tree
Showing 81 changed files with 3,519 additions and 3,574 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
MAINNET_RPC=
MAINNET_DEPLOYER_PK=

GNOSIS_RPC=
GNOSIS_DEPLOYER_PK=

SEPOLIA_RPC=
SEPOLIA_DEPLOYER_PK=

Expand Down
1 change: 1 addition & 0 deletions .forge-snapshots/newBCoWFactory.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4899289
1 change: 1 addition & 0 deletions .forge-snapshots/newBCoWPool.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4042925
2 changes: 1 addition & 1 deletion .forge-snapshots/newBFactory.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4130633
4140477
2 changes: 1 addition & 1 deletion .forge-snapshots/newBPool.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3477592
3486610
2 changes: 1 addition & 1 deletion .forge-snapshots/swapExactAmountIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
104914
104920
2 changes: 1 addition & 1 deletion .forge-snapshots/swapExactAmountInInverse.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
114583
114589
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ jobs:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1.2.0
with:
version: nightly

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile using 0.8.14 and via-ir=false
- name: Precompile contracts
run: yarn build

- name: Run tests
Expand All @@ -45,20 +45,20 @@ jobs:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1.2.0
with:
version: nightly

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile using 0.8.14 and via-ir=false
- name: Precompile contracts
run: yarn build

- name: Run tests
Expand All @@ -77,14 +77,14 @@ jobs:
- uses: wagoid/commitlint-github-action@v5

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1.2.0
with:
version: nightly

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'

- name: Install bulloak
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,17 @@ yarn test # run the tests
- The weight represents the intended distribution of value between the tokens in the pool
- Modify the pool's swap fee by calling `IBPool.setSwapFee(fee)`
- Finalize the pool by calling `IBPool.finalize()`

# Deployments
Ethereum Mainnet:
- BCoWFactory: [0x5AC134DAC7070eFeE8b1C5e3fD0B353922ceD843](https://etherscan.io/address/0x5AC134DAC7070eFeE8b1C5e3fD0B353922ceD843)
- BCoWHelper: [0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624](https://etherscan.io/address/0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624)

Ethereum Sepolia:
- BCoWFactory: [0xf3916A8567DdC51a60208B35AC542F5226f46773](https://sepolia.etherscan.io/address/0xf3916A8567DdC51a60208B35AC542F5226f46773)
- BCoWHelper: [0x55DDf396886C85e443E0B5A8E42CAA3939E4Cf50](https://sepolia.etherscan.io/address/0x55DDf396886C85e443E0B5A8E42CAA3939E4Cf50)
- BCoWPool: [0x60048091401F27117C3DFb8136c1ec550D949B12](https://sepolia.etherscan.io/address/0x60048091401F27117C3DFb8136c1ec550D949B12)

Gnosis Mainnet:
- BCoWFactory: [0xaD0447be7BDC80cf2e6DA20B13599E5dc859b667](https://gnosisscan.io/address/0xaD0447be7BDC80cf2e6DA20B13599E5dc859b667)
- BCoWHelper: [0x21Ac2E4115429EcE4b5FE79409fCC48EB6315Ccc](https://gnosisscan.io/address/0x21Ac2E4115429EcE4b5FE79409fCC48EB6315Ccc)
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ max_test_rejects = 2_500_000

[rpc_endpoints]
mainnet = "${MAINNET_RPC}"
gnosis = "${GNOSIS_RPC}"
sepolia = "${SEPOLIA_RPC}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", chain = "mainnet" }
gnosis = { key = "${ETHERSCAN_API_KEY}", chain = "gnosis" }
sepolia = { key = "${ETHERSCAN_API_KEY}", chain = "sepolia" }
30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
{
"name": "balancer-core",
"version": "0.0.7",
"name": "balancer-cow-amm",
"version": "1.0.0",
"private": true,
"description": "Balancer Core Contracts and ABI",
"homepage": "https://github.com/balancer-labs/balancer-core#readme",
"description": "Balancer CoW AMM",
"homepage": "https://github.com/balancer/cow-amm#readme",
"bugs": {
"url": "https://github.com/balancer-labs/balancer-core/issues"
"url": "https://github.com/balancer/cow-amm/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/balancer-labs/balancer-core.git"
"url": "git+https://github.com/balancer/cow-amm.git"
},
"license": "GPL-3.0-only",
"license": "GPL-3.0-or-later",
"scripts": {
"build": "forge build",
"build:optimized": "FOUNDRY_PROFILE=optimized forge build",
"coverage": "forge coverage --match-contract Unit",
"deploy:bcowfactory:mainnet": "bash -c 'source .env && forge script DeployBCoWFactory -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"deploy:bcowfactory:testnet": "bash -c 'source .env && forge script DeployBCoWFactory -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"deploy:bfactory:mainnet": "bash -c 'source .env && forge script DeployBFactory -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"deploy:bfactory:testnet": "bash -c 'source .env && forge script DeployBFactory -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"coverage": "forge coverage --match-path 'test/unit/**'",
"deploy:bcowfactory:gnosis": "forge script DeployBCoWFactory -vvvvv --rpc-url $GNOSIS_RPC --broadcast --chain gnosis --private-key $GNOSIS_DEPLOYER_PK --verify",
"deploy:bcowfactory:mainnet": "forge script DeployBCoWFactory -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify",
"deploy:bcowfactory:testnet": "forge script DeployBCoWFactory -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify",
"deploy:bfactory:gnosis": "forge script DeployBFactory -vvvvv --rpc-url $GNOSIS_RPC --broadcast --chain gnosis --private-key $GNOSIS_DEPLOYER_PK --verify",
"deploy:bfactory:mainnet": "forge script DeployBFactory -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify",
"deploy:bfactory:testnet": "forge script DeployBFactory -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify",
"lint:bulloak": "find test/unit -name '*.tree' | xargs bulloak check",
"lint:check": "solhint 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol' && forge fmt --check",
"lint:fix": "solhint --fix 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol' && sort-package-json && forge fmt",
"lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js",
"prepare": "husky install",
"script:gnosis": "forge script MainnetScript -vvvvv --rpc-url $GNOSIS_RPC --broadcast --chain gnosis --private-key $GNOSIS_DEPLOYER_PK --verify",
"script:mainnet": "forge script MainnetScript -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify",
"script:testnet": "forge script TestnetScript -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify",
"smock": "smock-foundry --contracts src/contracts",
"test": "yarn test:integration && yarn test:unit",
"test:integration": "forge test --ffi --match-path 'test/integration/**' -vvv --isolate",
Expand All @@ -43,6 +48,7 @@
"@crytic/properties": "https://github.com/crytic/properties.git",
"@openzeppelin/contracts": "5.0.2",
"composable-cow": "github:cowprotocol/composable-cow.git#24d556b",
"cow-amm": "github:cowprotocol/cow-amm.git#6566128",
"solmate": "github:transmissions11/solmate#c892309"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ cowprotocol/=node_modules/@cowprotocol/contracts/src/
@composable-cow/=node_modules/composable-cow/
halmos-cheatcodes=node_modules/halmos-cheatcodes
@crytic/=node_modules/@crytic/
@cow-amm/=node_modules/cow-amm/src
lib/openzeppelin/=node_modules/@openzeppelin

contracts/=src/contracts
interfaces/=src/interfaces
libraries/=src/libraries
6 changes: 6 additions & 0 deletions script/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"one-contract-per-file": "off",
"custom-errors": "off"
}
}
43 changes: 43 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {BCoWFactory} from 'contracts/BCoWFactory.sol';
import {BCoWHelper} from 'contracts/BCoWHelper.sol';
import {BFactory} from 'contracts/BFactory.sol';
import {IBFactory} from 'interfaces/IBFactory.sol';

import {Script} from 'forge-std/Script.sol';
import {Params} from 'script/Params.s.sol';

/// @notice This base script is shared across `yarn script:{b|bcow}factory:{mainnet|testnet}`
abstract contract DeployBaseFactory is Script, Params {
constructor() Params(block.chainid) {}

function run() public {
vm.startBroadcast();
IBFactory bFactory = _deployFactory();
bFactory.setBDao(_bFactoryDeploymentParams.bDao);
vm.stopBroadcast();
}

function _deployFactory() internal virtual returns (IBFactory);
}

/// @notice This script will be executed by `yarn script:bfactory:{mainnet|testnet}`
contract DeployBFactory is DeployBaseFactory {
function _deployFactory() internal override returns (IBFactory bFactory) {
bFactory = new BFactory();
}
}

/// @notice This script will be executed by `yarn script:bcowfactory:{mainnet|testnet}`
contract DeployBCoWFactory is DeployBaseFactory {
function _deployFactory() internal override returns (IBFactory bFactory) {
bFactory = new BCoWFactory({
solutionSettler: _bCoWFactoryDeploymentParams.settlement,
appData: _bCoWFactoryDeploymentParams.appData
});

new BCoWHelper(address(bFactory));
}
}
17 changes: 0 additions & 17 deletions script/DeployBCoWFactory.s.sol

This file was deleted.

17 changes: 0 additions & 17 deletions script/DeployBFactory.s.sol

This file was deleted.

50 changes: 29 additions & 21 deletions script/Params.s.sol
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

contract Params {
/// @notice Deployment parameters
abstract contract Params {
struct BFactoryDeploymentParams {
address bLabs;
address bDao;
}

struct BCoWFactoryDeploymentParams {
address bLabs;
address settlement;
bytes32 appData;
}

/// @notice Settlement address
address internal constant _GPV2_SETTLEMENT = 0x9008D19f58AAbD9eD0D60971565AA8510560ab41;

/// @notice AppData identifier
bytes32 internal constant _APP_DATA = bytes32('appData');

/// @notice BFactory deployment parameters for each chain
mapping(uint256 _chainId => BFactoryDeploymentParams _params) internal _bFactoryDeploymentParams;

/// @notice BCoWFactory deployment parameters for each chain
mapping(uint256 _chainId => BCoWFactoryDeploymentParams _params) internal _bCoWFactoryDeploymentParams;

constructor() {
// Mainnet
_bFactoryDeploymentParams[1] = BFactoryDeploymentParams(address(this));
_bCoWFactoryDeploymentParams[1] = BCoWFactoryDeploymentParams(address(this), _GPV2_SETTLEMENT, _APP_DATA);

// Sepolia
_bFactoryDeploymentParams[11_155_111] = BFactoryDeploymentParams(address(this));
_bCoWFactoryDeploymentParams[11_155_111] = BCoWFactoryDeploymentParams(address(this), _GPV2_SETTLEMENT, _APP_DATA);
/// @notice Balancer DAO address (has controller permission to collect fees from BFactory pools)
address internal constant _B_DAO = 0xce88686553686DA562CE7Cea497CE749DA109f9F;

/**
* @notice AppData identifier
* @dev Value obtained from https://explorer.cow.fi/appdata?tab=encode
* - appCode: "CoW AMM Balancer"
* - metadata:hooks:version: 0.1.0
* - version: 1.1.0
*/
bytes32 internal constant _APP_DATA = 0x362e5182440b52aa8fffe70a251550fbbcbca424740fe5a14f59bf0c1b06fe1d;

/// @notice BFactory deployment parameters
BFactoryDeploymentParams internal _bFactoryDeploymentParams;

/// @notice BCoWFactory deployment parameters
BCoWFactoryDeploymentParams internal _bCoWFactoryDeploymentParams;

constructor(uint256 chainId) {
if (chainId == 1 || chainId == 100 || chainId == 11_155_111) {
// Ethereum Mainnet & Ethereum Sepolia [Testnet]
_bFactoryDeploymentParams = BFactoryDeploymentParams({bDao: _B_DAO});
_bCoWFactoryDeploymentParams = BCoWFactoryDeploymentParams({settlement: _GPV2_SETTLEMENT, appData: _APP_DATA});
} else {
revert('Params: unknown chain ID');
}
}
}
33 changes: 33 additions & 0 deletions script/Registry.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {BCoWFactory} from 'contracts/BCoWFactory.sol';
import {BCoWHelper} from 'contracts/BCoWHelper.sol';

import {Params} from 'script/Params.s.sol';

/// @notice Registry of deployed contracts
abstract contract Registry is Params {
/// @notice Balancer CoW Pool Factory
BCoWFactory public bCoWFactory;
/// @notice Balancer CoW Helper
BCoWHelper public bCoWHelper;

constructor(uint256 chainId) Params(chainId) {
if (chainId == 1) {
// Ethereum Mainnet
bCoWFactory = BCoWFactory(0x5AC134DAC7070eFeE8b1C5e3fD0B353922ceD843);
bCoWHelper = BCoWHelper(0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624);
} else if (chainId == 100) {
// Gnosis Mainnet
bCoWFactory = BCoWFactory(0xaD0447be7BDC80cf2e6DA20B13599E5dc859b667);
bCoWHelper = BCoWHelper(0x21Ac2E4115429EcE4b5FE79409fCC48EB6315Ccc);
} else if (chainId == 11_155_111) {
// Ethereum Sepolia [Testnet]
bCoWFactory = BCoWFactory(0xf3916A8567DdC51a60208B35AC542F5226f46773);
bCoWHelper = BCoWHelper(0x55DDf396886C85e443E0B5A8E42CAA3939E4Cf50);
} else {
revert('Registry: unknown chain ID');
}
}
}
Loading

0 comments on commit 1eedf2f

Please sign in to comment.