From 66d00e417d9009a58842983d1d45c836f8da76fb Mon Sep 17 00:00:00 2001 From: Albert Llimos <53186777+albert-llimos@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:50:33 +0100 Subject: [PATCH] chore: add deployment usdt (#498) * chore: add deployment usdt * chore: rename INIT_USDC_SUPPLY * chore: rename to USD_BALANCE * chore: fix typo --- scripts/deploy_contracts.py | 9 +++++++++ tests/conftest.py | 4 ++-- tests/consts.py | 4 ++-- tests/deploy.py | 25 ++++++++++++++++++++++--- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/scripts/deploy_contracts.py b/scripts/deploy_contracts.py index 9d8efcf6..685dc90c 100644 --- a/scripts/deploy_contracts.py +++ b/scripts/deploy_contracts.py @@ -13,6 +13,7 @@ StateChainGateway, FLIP, MockUSDC, + MockUSDT, DeployerContract, AddressChecker, CFTester, @@ -21,6 +22,7 @@ from deploy import ( deploy_Chainflip_contracts, deploy_usdc_contract, + deploy_usdt_contract, deploy_new_cfReceiver, deploy_contracts_secondary_evm, ) @@ -179,6 +181,11 @@ def deploy_optional_contracts(cf, addressDump): cf.cfTester = deploy_new_cfReceiver(deployer, CFTester, cf.vault.address) addressDump["CF_TESTER"] = cf.cfTester.address + # Keeping the order to not change the final addresses + if chain.id in [arb_localnet, eth_localnet, hardhat]: + cf.mockUSDT = deploy_usdt_contract(deployer, MockUSDT, cf_accs[0:10]) + addressDump["USDT_ADDRESS"] = cf.mockUSDT.address + def display_common_deployment_params(chain_id, deployer, govKey, commKey, aggKey): print(f" Chain: {chain_id}") @@ -218,6 +225,8 @@ def display_deployed_contracts(cf): # Contracts dependant on localnet/testnet/mainnet if hasattr(cf, "mockUSDC"): print(f" USDC: {cf.mockUSDC.address}") + if hasattr(cf, "mockUSDT"): + print(f" USDT: {cf.mockUSDT.address}") if hasattr(cf, "cfTester"): print(f" CFTester: {cf.cfTester.address}") diff --git a/tests/conftest.py b/tests/conftest.py index 6a3c77f2..896d02d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -268,7 +268,7 @@ def cfLoopbackMock(cf, LoopBackMock): @pytest.fixture(scope="module") def mockUsdc(cf, MockUSDC): - return cf.SAFEKEEPER.deploy(MockUSDC, "USD Coin", "USDC", INIT_USDC_SUPPLY) + return cf.SAFEKEEPER.deploy(MockUSDC, "USD Coin", "USDC", INIT_USD_SUPPLY) @pytest.fixture(scope="module") @@ -278,7 +278,7 @@ def utils(cf, Utils): @pytest.fixture(scope="module") def mockUSDT(cf, MockUSDT): - return cf.SAFEKEEPER.deploy(MockUSDT, "Tether USD", "USDT", INIT_USDC_SUPPLY) + return cf.SAFEKEEPER.deploy(MockUSDT, "Tether USD", "USDT", INIT_USD_SUPPLY) @pytest.fixture(scope="module") diff --git a/tests/consts.py b/tests/consts.py index a4392210..8b7baebe 100644 --- a/tests/consts.py +++ b/tests/consts.py @@ -29,8 +29,8 @@ INIT_NATIVE_BAL = int(10000 * E_18) SECS_PER_BLOCK = 13 # USDC and USDT use 6 decimals -INIT_USDC_SUPPLY = int(20 * 10**6 * 10**6) -INIT_USDC_ACCOUNT = int(10**6 * 10**6) +INIT_USD_SUPPLY = int(20 * 10**6 * 10**6) +INIT_USD_BALANCE = int(10**6 * 10**6) TEST_AMNT_USDC = int(10**6) # Time in seconds diff --git a/tests/deploy.py b/tests/deploy.py index 9517d959..c18cb586 100644 --- a/tests/deploy.py +++ b/tests/deploy.py @@ -226,17 +226,36 @@ def deploy_usdc_contract(deployer, MockUSDC, accounts): mockUsdc = MockUSDC.deploy( "USD Coin", "USDC", - INIT_USDC_SUPPLY, + INIT_USD_SUPPLY, {"from": deployer, "required_confs": required_confs}, ) # Distribute tokens to other accounts for account in accounts: - if account != deployer and mockUsdc.balanceOf(deployer) >= INIT_USDC_ACCOUNT: - mockUsdc.transfer(account, INIT_USDC_ACCOUNT, {"from": deployer}) + if account != deployer and mockUsdc.balanceOf(deployer) >= INIT_USD_BALANCE: + mockUsdc.transfer(account, INIT_USD_BALANCE, {"from": deployer}) return mockUsdc +# Deploy USDCT mock token +def deploy_usdt_contract(deployer, MockUSDT, accounts): + # Set the priority fee for all transactions and the required number of confirmations. + required_confs = transaction_params() + + mockUsdt = MockUSDT.deploy( + "Tether USD", + "USDT", + INIT_USD_SUPPLY, + {"from": deployer, "required_confs": required_confs}, + ) + # Distribute tokens to other accounts + for account in accounts: + if account != deployer and mockUsdt.balanceOf(deployer) >= INIT_USD_BALANCE: + mockUsdt.transfer(account, INIT_USD_BALANCE, {"from": deployer}) + + return mockUsdt + + def deploy_addressHolder( deployer, AddressHolder,