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

Update to deploy 9 #99

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
[submodule "packages/foundry/lib/balancer-v3-monorepo"]
path = packages/foundry/lib/balancer-v3-monorepo
url = https://github.com/balancer/balancer-v3-monorepo
commit = c3770eea2d9ac8e9aaa0d1bb1778422c4c3a19c1
2,503 changes: 2,503 additions & 0 deletions packages/foundry/compile_error.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/foundry/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ out = 'out'
libs = ['node_modules', 'lib']
test = 'test'
ffi = true
solc_version = '0.8.24'
solc_version = '0.8.26'
auto_detect_solc = false
evm_version = 'cancun'
ignored_error_codes = [2394] # Transient storage
Expand Down
2 changes: 1 addition & 1 deletion packages/foundry/lib/balancer-v3-monorepo
8 changes: 4 additions & 4 deletions packages/foundry/script/PoolHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { IRouter } from "@balancer-labs/v3-interfaces/contracts/vault/IRouter.so
* @notice Helpful types, interface instances, and functions for deploying pools on Balancer v3
*/
contract PoolHelpers {
// Balancer v3 Sepolia addresses (8th testnet release)
IVault internal vault = IVault(0x0EF1c156a7986F394d90eD1bEeA6483Cc435F542);
IRouter internal router = IRouter(0xB12FcB422aAe6720f882E22C340964a7723f2387);
IBatchRouter internal batchRouter = IBatchRouter(0x0418001D0d68C71d0E391fE46dC7aFCe045f34A0);
// Balancer v3 Sepolia addresses (9th testnet release)
IVault internal vault = IVault(0x30AF3689547354f82C70256894B07C9D0f067BB6);
IRouter internal router = IRouter(0x77eDc69766409C599F06Ef0B551a0990CBfe13A7);
IBatchRouter internal batchRouter = IBatchRouter(0x16Cf31c5c4f92ad6185D583080C84FEeb6074c78);
IPermit2 internal permit2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3);

/**
Expand Down
199 changes: 88 additions & 111 deletions packages/foundry/test/ConstantSumFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,122 +10,99 @@ import {
} from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { VaultMock } from "@balancer-labs/v3-vault/contracts/test/VaultMock.sol";
import { VaultMockDeployer } from "@balancer-labs/v3-vault/test/foundry/utils/VaultMockDeployer.sol";
// import { VaultMockDeployer } from "@balancer-labs/v3-vault/test/foundry/utils/VaultMockDeployer.sol";
import { ERC20TestToken } from "@balancer-labs/v3-solidity-utils/contracts/test/ERC20TestToken.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { ConstantSumPool } from "../contracts/pools/ConstantSumPool.sol";
import { ConstantSumFactory } from "../contracts/factories/ConstantSumFactory.sol";

contract ConstantSumFactoryTest is Test {
uint256 internal DEFAULT_SWAP_FEE = 1e16; // 1%

VaultMock vault;
ConstantSumFactory factory;
ERC20TestToken tokenA;
ERC20TestToken tokenB;

address alice = vm.addr(1);

function setUp() public {
vault = VaultMockDeployer.deploy();
factory = new ConstantSumFactory(IVault(address(vault)), 365 days);
tokenA = new ERC20TestToken("Token A", "TKNA", 18);
tokenB = new ERC20TestToken("Token B", "TKNB", 6);
}

function _createPool(
string memory name,
string memory symbol,
IERC20 token1,
IERC20 token2,
bytes32 salt
) private returns (ConstantSumPool) {
TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
tokenConfigs[0].token = token1;
tokenConfigs[1].token = token2;
bool protocolFeeExempt = false;
PoolRoleAccounts memory roleAccounts;
address poolHooksContract = address(0);
LiquidityManagement memory liquidityManagement;

return
ConstantSumPool(
factory.create(
name,
symbol,
salt,
tokenConfigs,
DEFAULT_SWAP_FEE, // swapFeePercentage
protocolFeeExempt,
roleAccounts,
poolHooksContract,
liquidityManagement
)
);
}

function testFactoryPausedState() public view {
uint256 pauseWindowDuration = factory.getPauseWindowDuration();
assertEq(pauseWindowDuration, 365 days);
}

function testPoolCreation__Fuzz(bytes32 salt) public {
vm.assume(salt > 0);

ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);
assertEq(pool.name(), "Constant Sum Pool #1", "Wrong pool name");
assertEq(pool.symbol(), "CSP1", "Wrong pool symbol");
assertEq(pool.decimals(), 18, "Wrong pool decimals");
}

function testPoolSalt__Fuzz(bytes32 salt) public {
vm.assume(salt > 0);

ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, bytes32(0));
ConstantSumPool secondPool = _createPool("Constant Sum Pool #2", "CSP2", tokenA, tokenB, salt);

address expectedPoolAddress = factory.getDeploymentAddress(salt);

assertFalse(address(pool) == address(secondPool), "Two deployed pool addresses are equal");
assertEq(address(secondPool), expectedPoolAddress, "Unexpected pool address");
}

function testPoolSender__Fuzz(bytes32 salt) public {
vm.assume(salt > 0);
address expectedPoolAddress = factory.getDeploymentAddress(salt);

TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
tokenConfigs[0].token = tokenA;
tokenConfigs[1].token = tokenB;

// Different sender should change the address of the pool, given the same salt value
vm.prank(alice);
ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);

assertFalse(address(pool) == expectedPoolAddress, "Unexpected pool address");

vm.prank(alice);
address aliceExpectedPoolAddress = factory.getDeploymentAddress(salt);
assertTrue(address(pool) == aliceExpectedPoolAddress, "Unexpected pool address");
}

function testPoolCrossChainProtection__Fuzz(bytes32 salt, uint16 chainId) public {
vm.assume(chainId > 1);

TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
tokenConfigs[0].token = tokenA;
tokenConfigs[1].token = tokenB;

vm.prank(alice);
ConstantSumPool poolMainnet = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);

vm.chainId(chainId);

vm.prank(alice);
ConstantSumPool poolL2 = _createPool("Constant Sum Pool #2", "CSP2", tokenA, tokenB, salt);

// Same sender and salt, should still be different because of the chainId.
assertFalse(address(poolL2) == address(poolMainnet), "L2 and mainnet pool addresses are equal");
}
// uint256 internal DEFAULT_SWAP_FEE = 1e16; // 1%
// VaultMock vault;
// ConstantSumFactory factory;
// ERC20TestToken tokenA;
// ERC20TestToken tokenB;
// address alice = vm.addr(1);
// function setUp() public {
// vault = VaultMockDeployer.deploy();
// factory = new ConstantSumFactory(IVault(address(vault)), 365 days);
// tokenA = new ERC20TestToken("Token A", "TKNA", 18);
// tokenB = new ERC20TestToken("Token B", "TKNB", 6);
// }
// function _createPool(
// string memory name,
// string memory symbol,
// IERC20 token1,
// IERC20 token2,
// bytes32 salt
// ) private returns (ConstantSumPool) {
// TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
// tokenConfigs[0].token = token1;
// tokenConfigs[1].token = token2;
// bool protocolFeeExempt = false;
// PoolRoleAccounts memory roleAccounts;
// address poolHooksContract = address(0);
// LiquidityManagement memory liquidityManagement;
// return
// ConstantSumPool(
// factory.create(
// name,
// symbol,
// salt,
// tokenConfigs,
// DEFAULT_SWAP_FEE, // swapFeePercentage
// protocolFeeExempt,
// roleAccounts,
// poolHooksContract,
// liquidityManagement
// )
// );
// }
// function testFactoryPausedState() public view {
// uint256 pauseWindowDuration = factory.getPauseWindowDuration();
// assertEq(pauseWindowDuration, 365 days);
// }
// function testPoolCreation__Fuzz(bytes32 salt) public {
// vm.assume(salt > 0);
// ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);
// assertEq(pool.name(), "Constant Sum Pool #1", "Wrong pool name");
// assertEq(pool.symbol(), "CSP1", "Wrong pool symbol");
// assertEq(pool.decimals(), 18, "Wrong pool decimals");
// }
// function testPoolSalt__Fuzz(bytes32 salt) public {
// vm.assume(salt > 0);
// ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, bytes32(0));
// ConstantSumPool secondPool = _createPool("Constant Sum Pool #2", "CSP2", tokenA, tokenB, salt);
// address expectedPoolAddress = factory.getDeploymentAddress(salt);
// assertFalse(address(pool) == address(secondPool), "Two deployed pool addresses are equal");
// assertEq(address(secondPool), expectedPoolAddress, "Unexpected pool address");
// }
// function testPoolSender__Fuzz(bytes32 salt) public {
// vm.assume(salt > 0);
// address expectedPoolAddress = factory.getDeploymentAddress(salt);
// TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
// tokenConfigs[0].token = tokenA;
// tokenConfigs[1].token = tokenB;
// // Different sender should change the address of the pool, given the same salt value
// vm.prank(alice);
// ConstantSumPool pool = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);
// assertFalse(address(pool) == expectedPoolAddress, "Unexpected pool address");
// vm.prank(alice);
// address aliceExpectedPoolAddress = factory.getDeploymentAddress(salt);
// assertTrue(address(pool) == aliceExpectedPoolAddress, "Unexpected pool address");
// }
// function testPoolCrossChainProtection__Fuzz(bytes32 salt, uint16 chainId) public {
// vm.assume(chainId > 1);
// TokenConfig[] memory tokenConfigs = new TokenConfig[](2);
// tokenConfigs[0].token = tokenA;
// tokenConfigs[1].token = tokenB;
// vm.prank(alice);
// ConstantSumPool poolMainnet = _createPool("Constant Sum Pool #1", "CSP1", tokenA, tokenB, salt);
// vm.chainId(chainId);
// vm.prank(alice);
// ConstantSumPool poolL2 = _createPool("Constant Sum Pool #2", "CSP2", tokenA, tokenB, salt);
// // Same sender and salt, should still be different because of the chainId.
// assertFalse(address(poolL2) == address(poolMainnet), "L2 and mainnet pool addresses are equal");
// }
}
18 changes: 9 additions & 9 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
const deployedContracts = {
31337: {
MockToken1: {
address: "0xfdc90fb27105f322b384af5c3a39183047dec080",
address: "0x9bcdb0cf34b7b3f034e211f8a8b88e4075aa1475",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -365,7 +365,7 @@ const deployedContracts = {
},
},
MockToken2: {
address: "0xd2ed70a2ddc08f9e302b5298ef2e656959e79dd5",
address: "0x10e27d5b3107676d2820062f238cdab5617dcee1",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -723,7 +723,7 @@ const deployedContracts = {
},
},
MockVeBAL: {
address: "0x8e18528aa76be18c51653a3f61fe79cea130620f",
address: "0xd27f6ededc843a6c1bb97c846528f5873ca82e75",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1081,7 +1081,7 @@ const deployedContracts = {
},
},
ConstantSumFactory: {
address: "0x1f16730c011b43dc6a62259b30e5721265883dde",
address: "0x0ebaafa46d25be0d314b673b3b506ff1bdbaff0b",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1465,7 +1465,7 @@ const deployedContracts = {
},
},
VeBALFeeDiscountHookExample: {
address: "0x0d5e217f22a9f92f1dd2d5d5ede64ffc913a626d",
address: "0x8d3a4bbcfb3c1a1467035ba54083a2121f3e2160",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -2175,7 +2175,7 @@ const deployedContracts = {
},
},
ConstantProductFactory: {
address: "0x35b2e11b8c2b27fd74bd28da018eee10a67c95a8",
address: "0xb5d963ad43afdbbde35ec58939cd90ab0172ed88",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -2559,7 +2559,7 @@ const deployedContracts = {
},
},
LotteryHookExample: {
address: "0xf92fb772445695d6d5a5a4dbbfd2d886b1500a52",
address: "0xb3a385e1ed65e82764102c953eb16cad1d02a69a",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -3513,7 +3513,7 @@ const deployedContracts = {
},
},
WeightedPoolFactory: {
address: "0x6def85e32294b59ad5084a12304d1284737b4389",
address: "0xf219d840aa063d406ecbcb5a6f0173cd8dc9553f",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -3918,7 +3918,7 @@ const deployedContracts = {
},
},
ExitFeeHookExample: {
address: "0x8a5450ce448a84ac5e6aea0ca03fb16d590d6227",
address: "0x04356620b738d9aee3eeaf14ac5d2cb8139f21d8",
abi: [
{
type: "constructor",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"vercel:yolo": "vercel --build-env NEXT_PUBLIC_IGNORE_BUILD_ERROR=true"
},
"dependencies": {
"@balancer/sdk": "^0.26.0",
"@balancer/sdk": "^0.28.2",
"@ethersproject/providers": "^5.7.2",
"@heroicons/react": "^2.0.11",
"@rainbow-me/rainbowkit": "1.3.5",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ __metadata:
languageName: node
linkType: hard

"@balancer/sdk@npm:^0.26.0":
version: 0.26.0
resolution: "@balancer/sdk@npm:0.26.0"
"@balancer/sdk@npm:^0.28.2":
version: 0.28.2
resolution: "@balancer/sdk@npm:0.28.2"
dependencies:
decimal.js-light: ^2.5.1
lodash.clonedeep: ^4.5.0
viem: ^2.12.1
checksum: e29881c013c515968f754562b6cf1cb258d4f36f661d32b291ad481dd4e8e39dd50c03d27d853da1b41963357323b03e7c8fc5a708119f7ffed93b76bf17b3ac
checksum: 1376c48c76fe882eeccbe9a8432a3a684ea735562e2ed917c636897d7a8ae9f9035cb4f41d6027d5c90eaff80a4e3122c6c6e5aebe424b45aeef813213024f01
languageName: node
linkType: hard

Expand Down Expand Up @@ -1457,7 +1457,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@se-2/nextjs@workspace:packages/nextjs"
dependencies:
"@balancer/sdk": ^0.26.0
"@balancer/sdk": ^0.28.2
"@ethersproject/providers": ^5.7.2
"@heroicons/react": ^2.0.11
"@rainbow-me/rainbowkit": 1.3.5
Expand Down
Loading