From c2131fbf2472565470948cf57047d7ef51b96aac Mon Sep 17 00:00:00 2001 From: Matthew Pereira Date: Wed, 15 May 2024 17:08:10 -0700 Subject: [PATCH] remove broadcast that deploys mock tokens for run of DeployPool script --- .../foundry/script/DeployFactoryAndPool.s.sol | 7 ++--- packages/foundry/script/DeployPool.s.sol | 26 +++++++---------- packages/foundry/utils/HelperConfig.sol | 29 +++++++++---------- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/packages/foundry/script/DeployFactoryAndPool.s.sol b/packages/foundry/script/DeployFactoryAndPool.s.sol index 2a1d0df7..2ea37925 100644 --- a/packages/foundry/script/DeployFactoryAndPool.s.sol +++ b/packages/foundry/script/DeployFactoryAndPool.s.sol @@ -8,7 +8,7 @@ import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {TokenConfig} from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol"; import {HelperConfig} from "../utils/HelperConfig.sol"; import {ArrayHelpers} from "@balancer-labs/v3-solidity-utils/contracts/helpers/ArrayHelpers.sol"; -import { InputHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/InputHelpers.sol"; +import {InputHelpers} from "@balancer-labs/v3-solidity-utils/contracts/helpers/InputHelpers.sol"; /** * @title DeployFactoryAndPool @@ -30,7 +30,7 @@ contract DeployFactoryAndPool is ScaffoldETHDeploy, DeployPool { // Deploy mock tokens. Remove this if using already deployed tokens and instead set the tokens above vm.startBroadcast(deployerPrivateKey); - (IERC20 token1, IERC20 token2) = deployMockTokens(); + (address mockToken1, address mockToken2) = deployMockTokens(); vm.stopBroadcast(); // Look up configuration options from `HelperConfig.sol` @@ -40,7 +40,7 @@ contract DeployFactoryAndPool is ScaffoldETHDeploy, DeployPool { string memory name, string memory symbol, TokenConfig[] memory tokenConfig - ) = helperConfig.getPoolConfig(token1, token2); + ) = helperConfig.getPoolConfig(mockToken1, mockToken2); ( IERC20[] memory tokens, uint256[] memory exactAmountsIn, @@ -81,5 +81,4 @@ contract DeployFactoryAndPool is ScaffoldETHDeploy, DeployPool { */ exportDeployments(); } - } diff --git a/packages/foundry/script/DeployPool.s.sol b/packages/foundry/script/DeployPool.s.sol index c42b9852..09e0be29 100644 --- a/packages/foundry/script/DeployPool.s.sol +++ b/packages/foundry/script/DeployPool.s.sol @@ -9,7 +9,7 @@ import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {TokenConfig} from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol"; import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol"; import {Script, console} from "forge-std/Script.sol"; -import { InputHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/InputHelpers.sol"; +import {InputHelpers} from "@balancer-labs/v3-solidity-utils/contracts/helpers/InputHelpers.sol"; import {HelperConfig} from "../utils/HelperConfig.sol"; /** @@ -35,25 +35,21 @@ contract DeployPool is HelperFunctions, HelperConfig, Script { ); } - // Deploy mock tokens to use in the pool - vm.startBroadcast(deployerPrivateKey); - (IERC20 token1, IERC20 token2) = (IERC20(DevOpsTools.get_most_recent_deployment( - "MockToken1", // Must match the pool factory contract name + address mockToken1 = DevOpsTools.get_most_recent_deployment( + "MockToken1", // Must match the mock token contract name block.chainid - )),IERC20(DevOpsTools.get_most_recent_deployment( - "MockToken2", // Must match the pool factory contract name + ); + address mockToken2 = DevOpsTools.get_most_recent_deployment( + "MockToken2", // Must match the mock token contract name block.chainid - ))); // Get the most recently deployed address of the pool factory) - - vm.stopBroadcast(); + ); // Look up configurations from `HelperConfig.sol` HelperConfig helperConfig = new HelperConfig(); - ( - , - , - TokenConfig[] memory tokenConfig - ) = helperConfig.getPoolConfig(token1, token2); + (, , TokenConfig[] memory tokenConfig) = helperConfig.getPoolConfig( + mockToken1, + mockToken2 + ); ( IERC20[] memory tokens, uint256[] memory exactAmountsIn, diff --git a/packages/foundry/utils/HelperConfig.sol b/packages/foundry/utils/HelperConfig.sol index 2ccea3d5..6cddb711 100644 --- a/packages/foundry/utils/HelperConfig.sol +++ b/packages/foundry/utils/HelperConfig.sol @@ -20,22 +20,14 @@ contract HelperConfig { IVault public vault = IVault(0x1FC7F1F84CFE61a04224AC8D3F87f56214FeC08c); IRouter public router = IRouter(0xA0De078cd5cFa7088821B83e0bD7545ccfb7c883); - /** - * @dev Tokens for pool (also requires configuration of `TokenConfig` in the `getPoolConfig` function) - * @dev If using already deployed tokens, set the addresses here and remove the args for `getPoolConfig` function - * @notice the args for `getPoolConfig` enable the use of mock tokens that are not yet deployed - */ - IERC20 mockToken1; // Make sure to have proper token order (alphanumeric) - IERC20 mockToken2; // Make sure to have proper token order (alphanumeric) - /** * @notice Creates mock tokens for the pool and mints 1000 of each to the deployer wallet */ - function deployMockTokens() internal returns (IERC20, IERC20) { + function deployMockTokens() internal returns (address, address) { MockToken1 scUSD = new MockToken1("Scaffold USD", "scUSD"); MockToken2 scDAI = new MockToken2("Scaffold DAI", "scDAI"); - return (scDAI, scUSD); + return (address(scDAI), address(scUSD)); } /** @@ -53,8 +45,8 @@ contract HelperConfig { * @dev Set the name, symbol, and token configuration for the pool here */ function getPoolConfig( - IERC20 token1, - IERC20 token2 + address token1, + address token2 ) public pure @@ -69,13 +61,13 @@ contract HelperConfig { tokenConfig = new TokenConfig[](2); // An array of descriptors for the tokens the pool will manage. tokenConfig[0] = TokenConfig({ // Make sure to have proper token order (alphanumeric) - token: token1, + token: IERC20(token1), tokenType: TokenType.STANDARD, // STANDARD, WITH_RATE, or ERC4626 rateProvider: IRateProvider(address(0)), // The rate provider for a token yieldFeeExempt: false // Flag indicating whether yield fees should be charged on this token }); tokenConfig[1] = TokenConfig({ // Make sure to have proper token order (alphanumeric) - token: token2, + token: IERC20(token2), tokenType: TokenType.STANDARD, // STANDARD, WITH_RATE, or ERC4626 rateProvider: IRateProvider(address(0)), // The rate provider for a token yieldFeeExempt: false // Flag indicating whether yield fees should be charged on this token @@ -109,12 +101,17 @@ contract HelperConfig { userData = bytes(""); // Additional (optional) data required for adding initial liquidity } - function sortTokenConfig(TokenConfig[] memory tokenConfig) public pure returns (TokenConfig[] memory) { + function sortTokenConfig( + TokenConfig[] memory tokenConfig + ) public pure returns (TokenConfig[] memory) { for (uint256 i = 0; i < tokenConfig.length - 1; i++) { for (uint256 j = 0; j < tokenConfig.length - i - 1; j++) { if (tokenConfig[j].token > tokenConfig[j + 1].token) { // Swap if they're out of order. - (tokenConfig[j], tokenConfig[j + 1]) = (tokenConfig[j + 1], tokenConfig[j]); + (tokenConfig[j], tokenConfig[j + 1]) = ( + tokenConfig[j + 1], + tokenConfig[j] + ); } } }