Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge dev into fuzz #185

Merged
merged 34 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bbc79ca
fix: replace bLabs for bDao (#147)
wei3erHase Jul 9, 2024
c11c311
fix: run all unit tests for coverage report (#152)
0xteddybear Jul 11, 2024
b795bfb
test: btt bpool exitPool (#148)
0xteddybear Jul 11, 2024
06efb54
test: btt tests for swap exact amount in (#149)
0xteddybear Jul 12, 2024
d00b1eb
feat: adding bCoW deployment snapshots and updating snaps (#151)
wei3erHase Jul 12, 2024
4a4f8d3
fix: return variable names consistency (#156)
wei3erHase Jul 15, 2024
28fbf44
test: btt bpool swap exact amount out (#153)
0xteddybear Jul 16, 2024
598b6ee
feat: increasing max swap fee to 99.9999% (#158)
wei3erHase Jul 16, 2024
dfbed26
feat: adding btt test for joinswap extern amount in (#164)
0xteddybear Jul 22, 2024
cb92f9d
feat: add btt tests for exitswap pool amount in (#169)
0xteddybear Jul 22, 2024
6c13de8
feat: adding bcowpool verify btt tests (#155)
0xteddybear Jul 22, 2024
2a0b429
feat: add btt tests for finalize methods (#159)
0xteddybear Jul 22, 2024
49aba91
test: btt tests for joinswapPoolAmountOut (#170)
0xteddybear Jul 22, 2024
76ea1ef
feat: add btt tests for BCoWPool commit (#162)
0xteddybear Jul 22, 2024
0e30c85
feat: adding BTT tests for BPool getters and setters (#165)
wei3erHase Jul 22, 2024
c9a3849
feat: adding CoW helper MVP (#121)
wei3erHase Jul 23, 2024
eef9f2a
feat: adding btt tests for bToken (#167)
wei3erHase Jul 23, 2024
4b5fab7
feat: add btt for isValidSignature (#161)
0xteddybear Jul 23, 2024
dad92aa
test: btt tests for bcowpool constructor (#163)
0xteddybear Jul 23, 2024
585d3d2
chore: cleaning up remanent test code (#171)
wei3erHase Jul 23, 2024
85dd939
feat: btt tests for push/pull underlying (#173)
0xteddybear Jul 23, 2024
e7099e3
feat: btt tests for exitswapExternAmountOut (#172)
0xteddybear Jul 23, 2024
5920cd1
chore: preparing package for release (#157)
wei3erHase Jul 24, 2024
c250754
feat: adding deployment script with faucet erc20s (#114)
wei3erHase Jul 24, 2024
318eab9
Chore: post btt cleanup (#174)
0xteddybear Jul 25, 2024
521b10c
fix: test small fixes (#176)
0xteddybear Jul 25, 2024
0fe7750
chore: v1.0.0 deployment addresses (#175)
wei3erHase Jul 25, 2024
d140170
feat: deprecate single-token joins and exits (#177)
wei3erHase Jul 29, 2024
72a27c5
chore: redeploying testnet (#180)
wei3erHase Jul 29, 2024
302463c
chore: merge dev
wei3erHase Jul 29, 2024
23a8264
chore: update forge snapshots
wei3erHase Jul 29, 2024
b3f2cf6
chore: merge
wei3erHase Jul 29, 2024
5abef51
chore: update gas snapshots
wei3erHase Jul 29, 2024
a793e9d
chore: updating Properties document after merge
wei3erHase Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .forge-snapshots/exitPool.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174743
174820
2 changes: 1 addition & 1 deletion .forge-snapshots/joinPool.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
138985
138974
1 change: 1 addition & 0 deletions .forge-snapshots/newBCoWFactory.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4200675
1 change: 1 addition & 0 deletions .forge-snapshots/newBCoWPool.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3397437
2 changes: 1 addition & 1 deletion .forge-snapshots/newBFactory.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4130621
3442127
2 changes: 1 addition & 1 deletion .forge-snapshots/newBPool.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3477592
2841995
2 changes: 1 addition & 1 deletion .forge-snapshots/settlementCoWSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
215793
215771
2 changes: 1 addition & 1 deletion .forge-snapshots/settlementCoWSwapInverse.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
225641
225619
2 changes: 1 addition & 1 deletion .forge-snapshots/swapExactAmountIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
104914
104964
2 changes: 1 addition & 1 deletion .forge-snapshots/swapExactAmountInInverse.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
114583
114787
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ yarn test # run the tests
- Deprecated `Migrations` contract (not needed)
- Added an `_afterFinalize` hook (to be called at the end of the finalize routine)
- Implemented reentrancy locks using transient storage.
- Deprecated `joinswap` and `exitswap` methods (avoid single-token math precision issues)

## Features on BCoWPool (added via inheritance to BPool)
- Immutably stores CoW Protocol's `SolutionSettler` and `VaultRelayer` addresses at deployment
Expand All @@ -57,3 +58,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: [0x23fcC2166F991B8946D195de53745E1b804C91B7](https://etherscan.io/address/0x23fcC2166F991B8946D195de53745E1b804C91B7)
- BCoWHelper: [0x5F6e7D3ef6e9aedD21C107BF8faA610f1215C730 ](https://etherscan.io/address/0x5F6e7D3ef6e9aedD21C107BF8faA610f1215C730 )

Ethereum Sepolia:
- BCoWFactory: [0xF3F089AF5FaAF8784B445593B3bd8A514EaA3433 ](https://sepolia.etherscan.io/address/0xF3F089AF5FaAF8784B445593B3bd8A514EaA3433 )
- BCoWHelper: [0x07E7E9e3f4E715Ef1434b7f865fedBCE82Dd41Ba](https://sepolia.etherscan.io/address/0x07E7E9e3f4E715Ef1434b7f865fedBCE82Dd41Ba)
- BCoWPool: [0x4Cc911897fFCC5553627d454533D944F1D78CBdE](https://sepolia.etherscan.io/address/0x4Cc911897fFCC5553627d454533D944F1D78CBdE)

Gnosis Mainnet:
- BCoWFactory: [0x7573B99BC09c11Dc0427fb9c6662bc603E008304](https://gnosisscan.io/address/0x7573B99BC09c11Dc0427fb9c6662bc603E008304)
- BCoWHelper: [0x85315994492E88D6faCd3B0E3585c68A4720627e](https://gnosisscan.io/address/0x85315994492E88D6faCd3B0E3585c68A4720627e)
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" }
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
{
"name": "balancer-core",
"version": "0.0.7",
"name": "balancer-cow-amm",
"version": "1.4.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:gnosis": "forge script DeployBCoWFactory -vvvvv --rpc-url $GNOSIS_RPC --broadcast --chain gnosis --private-key $GNOSIS_DEPLOYER_PK --verify",
"deploy:mainnet": "forge script DeployBCoWFactory -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify",
"deploy:testnet": "forge script DeployBCoWFactory -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:echidna": "find test/invariants/fuzz -regex '.*\\.t\\.sol$' |cut -d '/' -f 4 | cut -d . -f 1 |xargs -I{} echidna test/invariants/fuzz/{}.t.sol --contract Fuzz{} --config test/invariants/fuzz/{}.yaml",
Expand All @@ -44,6 +46,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 @@ -5,8 +5,11 @@ solmate/=node_modules/solmate/src
@cowprotocol/=node_modules/@cowprotocol/contracts/src/contracts
cowprotocol/=node_modules/@cowprotocol/contracts/src/
@composable-cow/=node_modules/composable-cow/
@cow-amm/=node_modules/cow-amm/src
lib/openzeppelin/=node_modules/@openzeppelin
halmos-cheatcodes=node_modules/halmos-cheatcodes
@crytic/=node_modules/@crytic/

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');
}
}
}
Loading
Loading