From 54c0b96cdc23d4ced18743e7412fc889534c4c8a Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Fri, 5 Jan 2024 13:16:03 +0100 Subject: [PATCH] chore: deploy script tweak --- contracts/deploy/utils/deployERC20AndFaucet.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/contracts/deploy/utils/deployERC20AndFaucet.ts b/contracts/deploy/utils/deployERC20AndFaucet.ts index d3b9b2e77..ed0ce1a50 100644 --- a/contracts/deploy/utils/deployERC20AndFaucet.ts +++ b/contracts/deploy/utils/deployERC20AndFaucet.ts @@ -9,11 +9,7 @@ export const deployERC20AndFaucet = async ( ticker: string, faucetFundingAmount: BigNumber = hre.ethers.utils.parseUnits("100000") ): Promise => { - let erc20 = await hre.ethers.getContractOrNull(ticker); - if (erc20) { - return erc20; - } - erc20 = await getContractOrDeploy(hre, ticker, { + const erc20 = await getContractOrDeploy(hre, ticker, { from: deployer, contract: "TestERC20", args: [ticker, ticker], @@ -27,7 +23,8 @@ export const deployERC20AndFaucet = async ( }); const faucetBalance = await erc20.balanceOf(faucet.address); const deployerBalance = await erc20.balanceOf(deployer); - if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.isZero()) { + if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.lt(faucetFundingAmount.div(5))) { + // Fund the faucet if deployer has enough tokens and if the faucet has less than 20% of the faucetFundingAmount console.log(`funding ${ticker}Faucet with ${faucetFundingAmount}`); await erc20.transfer(faucet.address, faucetFundingAmount); }