Skip to content

Instantly share code, notes, and snippets.

View ramyhardan's full-sized avatar

Ramy Hardan ramyhardan

View GitHub Profile
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {
// When minting tokens
require(
owner() == _msgSender(),
using Arrays for uint256[];
// Number of seconds for 30, 60, 90, ... days
// [2592000, 5184000, 7776000, ..., 75168000, 77760000]
uint256[] private _vestingDays;
// Basis points (0.01%) made available within month 1,2,3,... after time of purchase.
// [0, 50, 100, ..., 9000, 10000]
uint256[] private _vestingBasisPoints;
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _amountAvailable(account);
}
struct vesting {
uint256 amount;
uint256 startDate;
}
mapping(address => vesting) private _vesting;
function transferVested(
address recipient,
uint256 amount,
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];

Keybase proof

I hereby claim:

  • I am ramyhardan on github.
  • I am ramy_ (https://keybase.io/ramy_) on keybase.
  • I have a public key ASAE1ZoFYJ_miT9uB3pBSkT3vbv0Xq__67LOBNMvMKjEnQo

To claim this, I am signing this object: