Skip to content

Commit

Permalink
Fix vesting contract
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed committed Jan 25, 2024
1 parent 8d4dd69 commit f563310
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions vesting/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ mod vesting_contract {
return Err(Error::ZeroReleasableBalance)
}

self.released_balance += releasable;
self.released_balance =
self.released_balance.checked_add(releasable).unwrap();
self.env()
.transfer(self.beneficiary, releasable)
.expect("Transfer failed during release");
Expand Down Expand Up @@ -198,10 +199,12 @@ mod vesting_contract {
} else if current_time >= self.end_time() {
return total_allocation
} else {
return (total_allocation
* (current_time.checked_sub(self.start_time()).unwrap()) as Balance)
.checked_div(self.duration_time() as Balance)
.unwrap()
return (total_allocation.checked_mul(
(current_time.checked_sub(self.start_time()).unwrap()) as Balance,
))
.unwrap()
.checked_div(self.duration_time() as Balance)
.unwrap()
}
}
}
Expand Down

0 comments on commit f563310

Please sign in to comment.