Last active
August 26, 2021 13:43
-
-
Save ramyhardan/0c01f0bb9d71d43e6b3fc41f1bb133f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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