Skip to content

Commit

Permalink
Merge branch 'master' into feat/claim_st_rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-llimos authored Oct 11, 2023
2 parents 2d9e4cb + 45b297d commit d5e6337
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 32 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
82 changes: 52 additions & 30 deletions scripts/deploy_tokenVestings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +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"]

# NOTE: Ensure vesting schedule is correct
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?",
]
options_lockup_type = ["Option A", "Option B", "Airdrop"]

# TODO: Ensure vesting schedule is correct
vesting_time_cliff = QUARTER_YEAR
vesting_time_end = vesting_time_cliff + YEAR

Expand All @@ -47,9 +56,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)}")

Expand All @@ -63,34 +72,47 @@ 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"
assert len(row) == len(
columns
), f"Incorrect number of parameters: expected {len(columns)}, but got {len(row)}"

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"
# Check that all rows are valid
lockup_type = row[columns.index("Final Choice Lock up Schedule")]

transferable = (
True if row[order["transferable_beneficiary"]] == "Y" else False
)

vesting_list.append([beneficiary, amount, lockup_type, transferable])

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:
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}"

if transferable in ["yes", "Yes"]:
transferable = True
elif transferable in ["no", "No"]:
transferable = False
else:
raise Exception(f"Incorrect transferability parameter {transferable}")

vesting_list.append([beneficiary, amount, lockup_type, transferable])

flip_total += amount

Expand Down Expand Up @@ -149,7 +171,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 d5e6337

Please sign in to comment.