From 57a32340a8ba890c8badb4e2c64b8a6b64b9b0d5 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 5 Oct 2023 15:05:40 +0200 Subject: [PATCH 1/4] chore: adapt script to the csv file --- contracts/mocks/MultiSend.sol | 6 ++- scripts/deploy_tokenVestings.py | 79 ++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/contracts/mocks/MultiSend.sol b/contracts/mocks/MultiSend.sol index f920d9b9..647b8fe7 100644 --- a/contracts/mocks/MultiSend.sol +++ b/contracts/mocks/MultiSend.sol @@ -17,6 +17,8 @@ contract MultiSend { function multiSendToken(IERC20 token, TransferParams[] calldata transferParamsArray, uint256 totalAmount) external { require(msg.sender == owner, "Not owner"); + uint256 initialBalance = token.balanceOf(address(this)); + require(token.transferFrom(msg.sender, address(this), totalAmount)); uint256 length = transferParamsArray.length; @@ -27,8 +29,8 @@ contract MultiSend { } } - // Return remainding tokens to msg.sender. If totalAmount < actualAmount, it will revert before - require(token.balanceOf(address(this)) == 0, "MultiSend: TotalAmount != amountSent"); + // Assumed that this contract won't be in the recipientAddress + require(token.balanceOf(address(this)) == initialBalance, "MultiSend: TotalAmount != amountSent"); } function recoverTokens(IERC20 token) external { diff --git a/scripts/deploy_tokenVestings.py b/scripts/deploy_tokenVestings.py index 9839f3b4..bd6b8dda 100644 --- a/scripts/deploy_tokenVestings.py +++ b/scripts/deploy_tokenVestings.py @@ -18,15 +18,26 @@ TokenVestingStaking, TokenVestingNoStaking, network, + web3, ) # File should be formatted as a list of parameters. First line should be the headers with names of the # parameters. The rest of the lines should be the values for each parameter. It should contain the # parameters described in the order dictionary below but it can have others, which will be ignored. VESTING_INFO_FILE = os.environ["VESTING_INFO_FILE"] -order = {"eth_address": 0, "amount": 1, "lockup_type": 2, "transferable_beneficiary": 3} -options_lockup_type = ["A", "B"] -options_transferable_beneficiary = ["Y", "N"] +columns = [ + "Full name/Company Name", + "Email Address", + "Final Choice Lock up Schedule", + "Investor Label", + "# tokens", + "Beneficiary Wallet Address", + "Address transfer enabled in smart contract?", + "Sanity checked?", +] +# order = {"eth_address": 0, "amount": 1, "lockup_type": 2, "transferable_beneficiary": 3} +options_lockup_type = ["Option A", "Option B", "Airdrop"] +# options_transferable_beneficiary = ["Y", "N"] # NOTE: Ensure vesting schedule is correct vesting_time_cliff = QUARTER_YEAR @@ -63,34 +74,52 @@ def main(): # Check the first row - parameter names first_row = next(reader) - for parameter_name, position in order.items(): - assert first_row[position] == parameter_name, "Incorrect parameter name" + for position, parameter_name in enumerate(columns): + assert ( + first_row[position] == parameter_name + ), f"Incorrect parameter name: expected {parameter_name}, but got {first_row[position]}" # Read the rest of the rows for row in reader: - assert len(row) == 4, "Incorrect number of parameters" - - beneficiary = row[order["eth_address"]] - amount = int(row[order["amount"]]) - lockup_type = row[order["lockup_type"]] - transferable = row[order["transferable_beneficiary"]] - - # Check that the row are valid - assert ( - transferable in options_transferable_beneficiary - ), "Incorrect transferability parameter" - assert lockup_type in options_lockup_type, "Incorrect lockup type parameter" - - transferable = ( - True if row[order["transferable_beneficiary"]] == "Y" else False - ) + assert len(row) == len( + columns + ), f"Incorrect number of parameters: expected {len(columns)}, but got {len(row)}" - vesting_list.append([beneficiary, amount, lockup_type, transferable]) + # Check that all rows are valid + lockup_type = row[columns.index("Final Choice Lock up Schedule")] - if lockup_type == "A": + if lockup_type == options_lockup_type[0]: number_staking += 1 - else: + elif lockup_type == options_lockup_type[1]: number_noStaking += 1 + elif lockup_type == options_lockup_type[2]: + continue + else: + continue + # raise Exception(f"Incorrect lockup type parameter {lockup_type}") + + beneficiary = row[columns.index("Beneficiary Wallet Address")] + amount = int(row[columns.index("# tokens")].replace(",", "")) + transferable = row[ + columns.index("Address transfer enabled in smart contract?") + ] + + # assert web3.isAddress(beneficiary), f"Incorrect beneficiary address {beneficiary}" + + # To remove + validAddress = web3.isAddress(beneficiary) + if not validAddress: + continue + + if transferable in ["yes", "Yes"]: + transferable = True + elif transferable in ["no", "No"]: + transferable = False + else: + continue + # raise Exception(f"Incorrect transferability parameter {transferable}") + + vesting_list.append([beneficiary, amount, lockup_type, transferable]) flip_total += amount @@ -149,7 +178,7 @@ def main(): beneficiary, amount, lockup_type, transferable_beneficiary = vesting amount_E18 = amount * E_18 - if lockup_type == "A": + if lockup_type == options_lockup_type[0]: tv = deploy_tokenVestingStaking( DEPLOYER, From 4c7c4be6aaff1d1df6fb11efee437236cf1d4c40 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 5 Oct 2023 15:07:36 +0200 Subject: [PATCH 2/4] chore: add strict checks --- scripts/deploy_tokenVestings.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/deploy_tokenVestings.py b/scripts/deploy_tokenVestings.py index bd6b8dda..51553474 100644 --- a/scripts/deploy_tokenVestings.py +++ b/scripts/deploy_tokenVestings.py @@ -58,9 +58,9 @@ def main(): governor = os.environ["GOV_KEY"] sc_gateway_address = os.environ["SC_GATEWAY_ADDRESS"] flip_address = os.environ["FLIP_ADDRESS"] - stMinter_address = os.environ.get("ST_MINTER_ADDRESS") - stBurner_address = os.environ.get("ST_BURNER_ADDRESS") - stFlip_address = os.environ.get("ST_FLIP_ADDRESS") + stMinter_address = os.environ["ST_MINTER_ADDRESS"] + stBurner_address = os.environ["ST_BURNER_ADDRESS"] + stFlip_address = os.environ["ST_FLIP_ADDRESS"] flip = FLIP.at(f"0x{cleanHexStr(flip_address)}") @@ -95,8 +95,7 @@ def main(): elif lockup_type == options_lockup_type[2]: continue else: - continue - # raise Exception(f"Incorrect lockup type parameter {lockup_type}") + raise Exception(f"Incorrect lockup type parameter {lockup_type}") beneficiary = row[columns.index("Beneficiary Wallet Address")] amount = int(row[columns.index("# tokens")].replace(",", "")) @@ -104,20 +103,14 @@ def main(): columns.index("Address transfer enabled in smart contract?") ] - # assert web3.isAddress(beneficiary), f"Incorrect beneficiary address {beneficiary}" - - # To remove - validAddress = web3.isAddress(beneficiary) - if not validAddress: - continue + assert web3.isAddress(beneficiary), f"Incorrect beneficiary address {beneficiary}" if transferable in ["yes", "Yes"]: transferable = True elif transferable in ["no", "No"]: transferable = False else: - continue - # raise Exception(f"Incorrect transferability parameter {transferable}") + raise Exception(f"Incorrect transferability parameter {transferable}") vesting_list.append([beneficiary, amount, lockup_type, transferable]) From cbf71b48282b5418f6e496d6ca6157ab823d04ee Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 5 Oct 2023 15:08:52 +0200 Subject: [PATCH 3/4] chore: remove comments --- scripts/deploy_tokenVestings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/deploy_tokenVestings.py b/scripts/deploy_tokenVestings.py index 51553474..ff3fcc04 100644 --- a/scripts/deploy_tokenVestings.py +++ b/scripts/deploy_tokenVestings.py @@ -35,11 +35,9 @@ "Address transfer enabled in smart contract?", "Sanity checked?", ] -# order = {"eth_address": 0, "amount": 1, "lockup_type": 2, "transferable_beneficiary": 3} options_lockup_type = ["Option A", "Option B", "Airdrop"] -# options_transferable_beneficiary = ["Y", "N"] -# NOTE: Ensure vesting schedule is correct +# TODO: Ensure vesting schedule is correct vesting_time_cliff = QUARTER_YEAR vesting_time_end = vesting_time_cliff + YEAR From 09d8b368ac1c37246d998943928345e27c2773e0 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 5 Oct 2023 15:16:03 +0200 Subject: [PATCH 4/4] chore: lint --- scripts/deploy_tokenVestings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/deploy_tokenVestings.py b/scripts/deploy_tokenVestings.py index ff3fcc04..2bbe0f79 100644 --- a/scripts/deploy_tokenVestings.py +++ b/scripts/deploy_tokenVestings.py @@ -101,7 +101,9 @@ def main(): columns.index("Address transfer enabled in smart contract?") ] - assert web3.isAddress(beneficiary), f"Incorrect beneficiary address {beneficiary}" + assert web3.isAddress( + beneficiary + ), f"Incorrect beneficiary address {beneficiary}" if transferable in ["yes", "Yes"]: transferable = True