Skip to content

Instantly share code, notes, and snippets.

@ramyhardan
Last active August 26, 2021 13:43
Show Gist options
  • Save ramyhardan/0c01f0bb9d71d43e6b3fc41f1bb133f8 to your computer and use it in GitHub Desktop.
Save ramyhardan/0c01f0bb9d71d43e6b3fc41f1bb133f8 to your computer and use it in GitHub Desktop.
function _amountAvailable(address from) internal view returns (uint256) {
vesting memory vested = _vesting[from];
uint256 totalBalance = _totalBalanceOf(from);
if (vested.amount > 0) {
// vesting applies
uint256 vestingIndex =
_vestingDays.findUpperBound(today() - vested.startDate);
if (vestingIndex < _vestingDays.length) {
// still in vesting phase
uint256 vestingBasisPoints = _vestingBasisPoints[vestingIndex];
uint256 maxAmountAvailable =
vested.amount.mul(vestingBasisPoints).div(
BASIS_POINT_DIVISOR
);
uint256 remainingVestedAmount =
vested.amount.sub(maxAmountAvailable);
return totalBalance.sub(remainingVestedAmount);
} else {
return totalBalance;
}
} else {
return totalBalance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment