Skip to content

Commit

Permalink
Update vest schedule to ensure total amt = set amt
Browse files Browse the repository at this point in the history
  • Loading branch information
tensojka committed Dec 1, 2023
1 parent 988ea31 commit d7ab3ae
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/vesting.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,24 @@ mod vesting {
assert(increments_count > 1, 'schedule must have more than one milestone');
assert(get_block_timestamp() < first_vest, 'first vest cannot be in the past');
assert()
let per_vest_amount = total_amount
/ increments_count; // check behavior for low/high increments_count, check rounding, increase last vest so total_amount holds.
let per_vest_amount = total_amount / increments_count;
let mut total_scheduled = 0;
loop {
if i == increments_count {
break;
}
self.add_vesting_milestone(curr_timestamp, grantee, per_vest_amount);
total_scheduled += per_vest_amount;
if i + 1 == increments_count {
let left_to_get_to_total = total_amount - total_scheduled;
self
.add_vesting_milestone(
curr_timestamp, grantee, per_vest_amount + left_to_get_to_total
);
} else {
self.add_vesting_milestone(curr_timestamp, grantee, per_vest_amount);
}
curr_timestamp = curr_timestamp + period;
i += 1;
}
}
}
Expand Down

0 comments on commit d7ab3ae

Please sign in to comment.