Skip to content

Commit

Permalink
chore: adapt script to the csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-llimos committed Oct 5, 2023
1 parent d47d25f commit 57a3234
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
6 changes: 4 additions & 2 deletions contracts/mocks/MultiSend.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
79 changes: 54 additions & 25 deletions scripts/deploy_tokenVestings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 57a3234

Please sign in to comment.