Skip to content

Commit

Permalink
fighting compile version error
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Oct 16, 2024
1 parent 370f928 commit 1f59bab
Show file tree
Hide file tree
Showing 6 changed files with 2,602 additions and 121 deletions.
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.

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");
// }
}
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

0 comments on commit 1f59bab

Please sign in to comment.