Skip to main content

VestedMilestoneManager

The VestedMilestoneManager contract manages milestone-based token vesting schedules where tokens are released upon admin approval of specific milestone steps. This contract provides a structured approach to vesting that requires explicit approval for each milestone step before tokens can be claimed.

Overview

Unlike traditional time-based vesting, milestone-based vesting releases tokens only when predetermined milestones are achieved and approved by administrators. This approach is ideal for:

  • Performance-based compensation: Tokens vest based on achievement of specific goals
  • Project deliverables: Release payments upon completion of project phases
  • Conditional vesting: Tokens only vest when specific conditions are met
  • Flexible scheduling: Each milestone can have different vesting parameters

Key Features

  • Milestone-based releasing: Tokens vest only upon admin approval of milestone steps
  • Flexible funding models: Support for both full upfront funding and partial funding
  • Fee structures: Configurable gas fees or token-based fees
  • Batch operations: Efficient creation and management of multiple milestones
  • Ownership transfers: Secure transfer of milestone ownership between addresses
  • Comprehensive querying: Rich set of view functions for milestone and step information

Contract Interface

Constructor

constructor(
address tokenAddress_,
ITypes.FeeType feeType_,
uint256 fee_,
address feeCollector_,
ITypes.FundingType fundingType_
)

Parameters:

  • tokenAddress_: Address of the ERC20 token to be vested
  • feeType_: Type of fee (Gas or DistributionToken)
  • fee_: Fee amount (wei for gas fees, basis points for token fees)
  • feeCollector_: Address authorized to collect fees
  • fundingType_: Funding model (Full or Partial)

Core Functions

Milestone Creation

createMilestone

Creates a new milestone with multiple steps.

function createMilestone(
address _recipient,
uint256[] calldata _allocations,
string[] calldata _externalRefs
) external onlyAdmin

Parameters:

  • _recipient: Address of the milestone recipient
  • _allocations: Token amounts allocated to each step
  • _externalRefs: External reference strings for each step (e.g., "Phase 1", "MVP Delivery")

Requirements:

  • Only admin can call this function
  • Arrays must have matching lengths
  • Recipient address cannot be zero
  • In full funding mode, requires token transfer for total allocation

createMilestoneBatch

Creates multiple milestones in a single transaction.

function createMilestoneBatch(
address[] calldata recipients,
uint256[][] calldata _allocations,
string[][] calldata _externalRefs
) external onlyAdmin

Use Cases:

  • Setting up vesting for multiple team members
  • Batch creation of project-based milestones
  • Efficient deployment of similar milestone structures

Step Approval

approveMilestoneStep

Approves a milestone step and initializes its vesting schedule.

function approveMilestoneStep(
bytes32 _milestoneId,
uint256 _stepIndex,
uint32 _startTimestamp,
uint32 _endTimestamp,
uint32 _timelock,
uint256 _initialUnlock,
uint32 _cliffReleaseTimestamp,
uint256 _cliffAmount,
uint32 _releaseIntervalSecs,
uint256 _linearVestAmount,
bool _isRevocable
) external onlyAdmin

Parameters:

  • _milestoneId: ID of the milestone
  • _stepIndex: Index of the step to approve
  • _startTimestamp: When vesting begins
  • _endTimestamp: When vesting ends
  • _timelock: Optional timelock period
  • _initialUnlock: Tokens immediately available
  • _cliffReleaseTimestamp: Cliff release time
  • _cliffAmount: Tokens released at cliff
  • _releaseIntervalSecs: Interval between releases
  • _linearVestAmount: Tokens released linearly
  • _isRevocable: Whether the vesting can be revoked

Requirements:

  • Total vesting amounts must equal step allocation
  • Vesting parameters must be valid
  • Step must not already be approved
  • Step must not be revoked

Funding Operations

fundMilestone

Funds a specific milestone step (partial funding mode only).

function fundMilestone(
bytes32 milestoneId,
uint256 stepId,
uint256 fundingAmount
) external onlyAdmin

Example:

// Fund 50% of a milestone step
vestedMilestoneManager.fundMilestone(
milestoneId,
0, // First step
50000 * 10**18 // 50,000 tokens
);

fundMilestoneBatch

Funds multiple milestone steps in a single transaction.

function fundMilestoneBatch(
bytes32 milestoneId,
uint256[] calldata stepIds,
uint256[] calldata fundingAmounts
) external onlyAdmin

Token Claiming

claim

Claims available tokens for a specific milestone step.

function claim(bytes32 milestoneId, uint256 stepIndex) external payable

Requirements:

  • Caller must be the milestone recipient
  • Step must be approved and active
  • Timelock must be expired (if applicable)
  • Start timestamp must be reached
  • Gas fee must be paid (if applicable)

Example:

// Claim tokens from first step of milestone
vestedMilestoneManager.claim{value: gasFee}(milestoneId, 0);

Administrative Functions

revokeMilestone

Revokes an entire milestone, canceling all unapproved steps and revoking approved ones.

function revokeMilestone(bytes32 _milestoneId) external onlyAdmin

revokeMilestoneStep

Revokes a specific milestone step.

function revokeMilestoneStep(
bytes32 _milestoneId,
uint256 _stepIndex
) external onlyAdmin returns (uint256)

withdrawAdmin

Withdraws excess tokens not allocated to milestones.

function withdrawAdmin(uint256 _amountRequested) external onlyAdmin

Ownership Transfer

initiateMilestoneTransfer

Initiates transfer of milestone ownership.

function initiateMilestoneTransfer(
bytes32 _milestoneId,
address _newOwner
) external onlyMilestoneRecipient(_milestoneId)

acceptMilestoneTransfer

Accepts a pending milestone transfer.

function acceptMilestoneTransfer(bytes32 _milestoneId) external

directMilestoneTransfer

Direct transfer without acceptance (for contract compatibility).

function directMilestoneTransfer(
bytes32 _milestoneId,
address _newOwner
) external onlyMilestoneRecipient(_milestoneId)

Fee Management

withdrawTokenFee

Withdraws collected token fees (fee collector only).

function withdrawTokenFee(
address recipient,
uint256 amount
) external onlyFeeCollector

withdrawGasFee

Withdraws collected gas fees (fee collector only).

function withdrawGasFee(
address recipient,
uint256 amount
) external onlyFeeCollector

View Functions

Milestone Information

getMilestoneById

Returns complete milestone information.

function getMilestoneById(bytes32 milestoneId)
external view returns (Milestone memory)

getMilestoneStep

Returns information about a specific milestone step.

function getMilestoneStep(bytes32 milestoneId, uint256 stepIndex)
external view returns (MilestoneStep memory)

getAllMilestoneSteps

Returns all steps for a milestone.

function getAllMilestoneSteps(bytes32 milestoneId)
external view returns (MilestoneStep[] memory)

Funding Information

getMilestoneFundingInfo

Returns funding information for a milestone.

function getMilestoneFundingInfo(bytes32 milestoneId)
external view returns (
uint8 fundingType,
uint256 totalFunded,
uint256 totalRequired
)

getStepFundingInfo

Returns funding information for a specific step.

function getStepFundingInfo(bytes32 _milestoneId, uint256 _stepIndex)
external view returns (
uint8 fundingType,
uint256 totalFunded,
uint256 totalRequired
)

isMilestoneFullyFunded

Checks if a milestone is fully funded.

function isMilestoneFullyFunded(bytes32 milestoneId)
external view returns (bool)

Claimable Amounts

getTotalClaimableAmount

Returns total claimable amount across all steps in a milestone.

function getTotalClaimableAmount(bytes32 _milestoneId)
external view returns (uint256)

getStepClaimableAmount

Returns claimable amount for a specific step.

function getStepClaimableAmount(bytes32 _milestoneId, uint256 _stepIndex)
external view returns (uint256)

Recipient Information

getAllRecipients

Returns all milestone recipients.

function getAllRecipients() external view returns (address[] memory)

getRecipientMilestones

Returns all milestones for a specific recipient.

function getRecipientMilestones(address _recipient)
external view returns (bytes32[] memory)

Events

Milestone Events

event VestedMilestoneCreated(
bytes32 indexed milestoneId,
address indexed recipient,
uint256 totalAllocation
);

event VestedMilestoneStepApproved(
bytes32 indexed milestoneId,
uint256 indexed stepIndex
);

event VestingInitialized(
bytes32 indexed milestoneId,
uint256 indexed stepIndex
);

event MilestoneRevoked(
bytes32 indexed milestoneId,
address indexed recipient,
uint256 amountRevoked
);

event MilestoneStepRevoked(
bytes32 indexed milestoneId,
uint256 indexed stepIndex,
address indexed recipient,
uint256 amountRevoked
);

Funding Events

event MilestoneStepFunded(
bytes32 indexed milestoneId,
uint256 indexed stepIndex,
address indexed funder,
uint256 amount,
uint256 totalFunded,
uint256 totalRequired
);

Claiming Events

event Claimed(
bytes32 indexed milestoneId,
address indexed recipient,
uint256 amount,
uint256 indexed stepIndex
);

Transfer Events

event MilestoneTransferInitiated(
address indexed from,
address indexed to,
bytes32 indexed milestoneId
);

event MilestoneTransferCancelled(
address indexed from,
bytes32 indexed milestoneId
);

event MilestoneTransferred(
address indexed from,
address indexed to,
bytes32 indexed milestoneId
);

Data Structures

Milestone

struct Milestone {
address recipient;
uint256 claimedAmount;
uint32 deactivationTimestamp;
MilestoneStep[] steps;
}

MilestoneStep

struct MilestoneStep {
uint256 allocation;
bool isApproved;
uint32 deactivationTimestamp;
string externalRef;
TokenVestingLib.Vesting vesting;
}

Usage Examples

Basic Milestone Creation

// Create a 3-step milestone for a developer
uint256[] memory allocations = new uint256[](3);
allocations[0] = 30000 * 10**18; // 30k tokens for Phase 1
allocations[1] = 40000 * 10**18; // 40k tokens for Phase 2
allocations[2] = 30000 * 10**18; // 30k tokens for Phase 3

string[] memory refs = new string[](3);
refs[0] = "MVP Development";
refs[1] = "Beta Testing";
refs[2] = "Production Launch";

vestedMilestoneManager.createMilestone(
developerAddress,
allocations,
refs
);

Approving and Funding Steps

// Approve the first milestone step
vestedMilestoneManager.approveMilestoneStep(
milestoneId,
0, // First step
1672531200, // Start timestamp
1680307200, // End timestamp
0, // No timelock
10000 * 10**18, // 10k immediate unlock
1674950400, // Cliff timestamp
10000 * 10**18, // 10k cliff amount
86400, // Daily releases
10000 * 10**18, // 10k linear vest
true // Revocable
);

// Fund the step (partial funding mode)
vestedMilestoneManager.fundMilestone(
milestoneId,
0, // First step
30000 * 10**18 // Full step amount
);

Claiming Tokens

// Recipient claims tokens from approved step
vestedMilestoneManager.claim{value: gasFee}(milestoneId, 0);

Integration Patterns

Project-Based Vesting

// Set up milestones for different project phases
function setupProjectMilestones(
address[] memory developers,
uint256[][] memory phaseAllocations
) external onlyAdmin {
string[][] memory phaseRefs = new string[][](developers.length);

for (uint256 i = 0; i < developers.length; i++) {
phaseRefs[i] = new string[](3);
phaseRefs[i][0] = "Requirements Analysis";
phaseRefs[i][1] = "Development Phase";
phaseRefs[i][2] = "Testing & Deployment";
}

vestedMilestoneManager.createMilestoneBatch(
developers,
phaseAllocations,
phaseRefs
);
}

Conditional Approval Workflow

// Approve milestone steps based on external validation
function approveCompletedMilestones(
bytes32[] memory milestoneIds,
uint256[] memory stepIndexes,
bool[] memory approvals
) external onlyAdmin {
for (uint256 i = 0; i < milestoneIds.length; i++) {
if (approvals[i]) {
// Approve with standard vesting parameters
vestedMilestoneManager.approveMilestoneStep(
milestoneIds[i],
stepIndexes[i],
// ... vesting parameters
);
}
}
}

Security Considerations

Access Control

  • Admin Functions: Only admins can create, approve, fund, and revoke milestones
  • Recipient Functions: Only milestone recipients can claim tokens and initiate transfers
  • Fee Collector: Only fee collector can withdraw collected fees

Funding Security

  • Overfunding Protection: Prevents funding more than allocated amounts
  • Partial Funding Validation: Ensures claims don't exceed funded amounts
  • Revocation Handling: Properly handles token recovery on revocation

Transfer Security

  • Two-Step Transfers: Prevents accidental transfers with acceptance requirement
  • Direct Transfers: Available for contract compatibility
  • Pending Transfer Management: Secure handling of pending transfers

Gas Optimization

  • Batch Operations: Efficient creation and funding of multiple milestones
  • Storage Optimization: Efficient storage patterns for milestone data
  • Array Management: Optimized recipient and milestone ID tracking

Best Practices

Milestone Design

  1. Clear Deliverables: Define specific, measurable milestones
  2. Balanced Allocations: Distribute tokens appropriately across steps
  3. Flexible Timing: Allow for reasonable vesting periods per step
  4. Revocability: Consider whether steps should be revocable

Funding Strategy

  1. Partial Funding: Use for uncertain project outcomes
  2. Full Funding: Use for guaranteed milestone completion
  3. Batch Funding: Fund multiple steps efficiently
  4. Monitoring: Track funding status regularly

All Functions

onlyFeeCollector

modifier onlyFeeCollector();

isMilestoneActive

Reverts if the milestone is not active

modifier isMilestoneActive(bytes32 _milestoneId);

onlyMilestoneRecipient

Reverts if caller is not the recipient of the milestone

modifier onlyMilestoneRecipient(bytes32 _milestoneId);

constructor

Sets the token address

The token address cannot be the zero address

constructor(
address tokenAddress_,
ITypes.FeeType feeType_,
uint256 fee_,
address feeCollector_,
ITypes.FundingType fundingType_
);

Parameters

NameTypeDescription
tokenAddress_address- The address of the token
feeType_ITypes.FeeType- The type of fee
fee_uint256- The fee amount
feeCollector_address- The address of the fee collector
fundingType_ITypes.FundingType- The type of funding

createMilestone

Creates a new vested milestone

function createMilestone(address _recipient, uint256[] calldata _allocations, string[] calldata _externalRefs)
external
onlyAdmin;

Parameters

NameTypeDescription
_recipientaddress- The address of the recipient
_allocationsuint256[]- The amount of tokens to allocate for each step
_externalRefsstring[]- The external reference of each step

createMilestoneBatch

Creates a batch of vested milestones

function createMilestoneBatch(
address[] calldata recipient,
uint256[][] calldata _allocations,
string[][] calldata _externalRefs
) external onlyAdmin;

Parameters

NameTypeDescription
recipientaddress[]- The address of the recipient
_allocationsuint256[][]- The amount of tokens to allocate for each step
_externalRefsstring[][]- The external reference of each step

approveMilestoneStep

Approves a milestone step and initializes its vesting schedule.

function approveMilestoneStep(
bytes32 _milestoneId,
uint256 _stepIndex,
uint32 _startTimestamp,
uint32 _endTimestamp,
uint32 _timelock,
uint256 _initialUnlock,
uint32 _cliffReleaseTimestamp,
uint256 _cliffAmount,
uint32 _releaseIntervalSecs,
uint256 _linearVestAmount,
bool _isRevocable
) external onlyAdmin;

Parameters

NameTypeDescription
_milestoneIdbytes32- The ID of the milestone
_stepIndexuint256- The index of the step
_startTimestampuint32- The start timestamp of the vesting
_endTimestampuint32- The end timestamp of the vesting
_timelockuint32- The timelock of the vesting
_initialUnlockuint256- The initial unlock of the vesting
_cliffReleaseTimestampuint32- The cliff release timestamp of the vesting
_cliffAmountuint256- The cliff amount of the vesting
_releaseIntervalSecsuint32- The release interval of the vesting
_linearVestAmountuint256- The linear vest amount of the vesting
_isRevocablebool- Whether the vesting is revocable

revokeMilestone

Revokes a milestone

function revokeMilestone(bytes32 _milestoneId) external onlyAdmin;

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone

revokeMilestoneStep

Revokes a milestone step (external interface)

function revokeMilestoneStep(bytes32 _milestoneId, uint256 _stepIndex) external onlyAdmin returns (uint256);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone
_stepIndexuint256The index of the step

claim

Claims all available tokens for a specific milestone step.

function claim(bytes32 milestoneId, uint256 stepIndex) external payable;

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone
stepIndexuint256- The index of the step

fundMilestone

Fund a specific step in an existing vested milestone (partial funding only)

function fundMilestone(bytes32 milestoneId, uint256 stepId, uint256 fundingAmount) external onlyAdmin;

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone
stepIduint256- The ID of the step to fund
fundingAmountuint256- The amount of tokens to fund

fundMilestoneBatch

Fund multiple steps in a milestone in batch

function fundMilestoneBatch(bytes32 milestoneId, uint256[] calldata stepIds, uint256[] calldata fundingAmounts)
external
onlyAdmin;

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone
stepIdsuint256[]- The IDs of the steps to fund
fundingAmountsuint256[]- The amounts of tokens to fund for each step

withdrawAdmin

Allow the owner to withdraw any balance not currently tied up in Vestings

function withdrawAdmin(uint256 _amountRequested) external onlyAdmin;

Parameters

NameTypeDescription
_amountRequesteduint256- Amount to withdraw

withdrawOtherToken

Withdraw a token which isn't controlled by the vesting contract. Useful when someone accidentally sends tokens to the contract

function withdrawOtherToken(address _otherTokenAddress) external onlyAdmin;

Parameters

NameTypeDescription
_otherTokenAddressaddress- the token which we want to withdraw

withdrawTokenFee

Withdraw collected token fees

function withdrawTokenFee(address recipient, uint256 amount) external onlyFeeCollector;

Parameters

NameTypeDescription
recipientaddress- The address of the recipient
amountuint256- The amount of tokens to withdraw

withdrawGasFee

Withdraw collected gas fees

function withdrawGasFee(address recipient, uint256 amount) external onlyFeeCollector;

Parameters

NameTypeDescription
recipientaddress- The address of the recipient
amountuint256- The amount of gas fees to withdraw

transferFeeCollectorRole

Updates the fee collector address

Can only be called by the fee collector

function transferFeeCollectorRole(address newFeeCollector) external onlyFeeCollector;

Parameters

NameTypeDescription
newFeeCollectoraddressAddress of the new fee collector

initiateMilestoneTransfer

Initiate the transfer of milestone ownership to a new address

function initiateMilestoneTransfer(bytes32 _milestoneId, address _newOwner)
external
onlyMilestoneRecipient(_milestoneId)
isMilestoneActive(_milestoneId);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone to transfer
_newOwneraddressThe address of the new owner

cancelMilestoneTransfer

Cancel a pending milestone transfer

function cancelMilestoneTransfer(bytes32 _milestoneId) external onlyMilestoneRecipient(_milestoneId);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone with a pending transfer

acceptMilestoneTransfer

Accept a milestone transfer as the new owner

function acceptMilestoneTransfer(bytes32 _milestoneId) external isMilestoneActive(_milestoneId);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone to accept

directMilestoneTransfer

Direct transfer of milestone ownership by current owner (for contract compatibility)

This is specifically for compatibility with contracts that cannot call acceptMilestoneTransfer

function directMilestoneTransfer(bytes32 _milestoneId, address _newOwner)
external
onlyMilestoneRecipient(_milestoneId)
isMilestoneActive(_milestoneId);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone to transfer
_newOwneraddressThe address of the new owner

getPendingMilestoneTransfer

Get the pending owner for a milestone transfer

function getPendingMilestoneTransfer(bytes32 _milestoneId) external view returns (address);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone

Returns

NameTypeDescription
<none>addressThe address of the pending owner if there is one, or zero address

getMilestoneFundingInfo

Get funding info for a milestone

function getMilestoneFundingInfo(bytes32 milestoneId)
external
view
returns (uint8 fundingType, uint256 totalFunded, uint256 totalRequired);

isMilestoneFullyFunded

Check if a milestone is fully funded

function isMilestoneFullyFunded(bytes32 milestoneId) external view returns (bool);

getAllRecipients

Get all recipients

function getAllRecipients() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]recipients - The list of recipients

getAllRecipientsSliced

Get all recipients in a range

function getAllRecipientsSliced(uint256 _from, uint256 _to) external view returns (address[] memory);

Parameters

NameTypeDescription
_fromuint256- The start index (inclusive)
_touint256- The end index (exclusive)

Returns

NameTypeDescription
<none>address[]recipientsSliced - The list of recipients in the range

getAllRecipientsLength

Get the length of all recipients

function getAllRecipientsLength() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256length - The length of all recipients

getMilestoneById

Get the milestone by ID

function getMilestoneById(bytes32 milestoneId) external view returns (Milestone memory);

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone

Returns

NameTypeDescription
<none>Milestonemilestone - The milestone object

getMilestoneStep

Get the milestone step by index

function getMilestoneStep(bytes32 milestoneId, uint256 stepIndex) external view returns (MilestoneStep memory);

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone
stepIndexuint256- The index of the step

Returns

NameTypeDescription
<none>MilestoneStepmilestoneStep - The milestone step object

getAllMilestoneSteps

Get all milestone steps

function getAllMilestoneSteps(bytes32 milestoneId) external view returns (MilestoneStep[] memory);

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone

Returns

NameTypeDescription
<none>MilestoneStep[]steps - The milestone steps

getAllMilestoneStepsLength

Get the length of all milestone steps

function getAllMilestoneStepsLength(bytes32 milestoneId) external view returns (uint256);

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone

Returns

NameTypeDescription
<none>uint256length - The length of all milestone steps

getAllMilestoneStepsSliced

Get all milestone steps in a range

function getAllMilestoneStepsSliced(bytes32 milestoneId, uint256 _from, uint256 _to)
external
view
returns (MilestoneStep[] memory);

Parameters

NameTypeDescription
milestoneIdbytes32- The ID of the milestone
_fromuint256- The start index (inclusive)
_touint256- The end index (exclusive)

Returns

NameTypeDescription
<none>MilestoneStep[]stepsSliced - The milestone steps in the range

getRecipientMilestones

Get the milestones of a recipient

function getRecipientMilestones(address _recipient) external view returns (bytes32[] memory);

Parameters

NameTypeDescription
_recipientaddress- The recipient address

Returns

NameTypeDescription
<none>bytes32[]recipientMilestones - The milestones of the recipient

getRecipientMilestonesLength

Get the length of the milestones of a recipient

function getRecipientMilestonesLength(address _recipient) external view returns (uint256);

Parameters

NameTypeDescription
_recipientaddress- The recipient address

Returns

NameTypeDescription
<none>uint256length - The length of the milestones of the recipient

getRecipientMilestonesSliced

Get the milestones of a recipient in a range

function getRecipientMilestonesSliced(address _recipient, uint256 _from, uint256 _to)
external
view
returns (bytes32[] memory);

Parameters

NameTypeDescription
_recipientaddress- The recipient address
_fromuint256- The start index (inclusive)
_touint256- The end index (exclusive)

Returns

NameTypeDescription
<none>bytes32[]milestonesSliced - The milestones of the recipient in the range

getTotalClaimableAmount

Get the total claimable amount across all steps in a milestone

function getTotalClaimableAmount(bytes32 _milestoneId) external view returns (uint256);

Parameters

NameTypeDescription
_milestoneIdbytes32- The ID of the milestone

Returns

NameTypeDescription
<none>uint256totalClaimableAmount - The total amount of tokens that can be claimed across all steps

getStepFundingInfo

Get funding information for a specific milestone step

function getStepFundingInfo(bytes32 _milestoneId, uint256 _stepIndex)
external
view
returns (uint8 fundingType, uint256 totalFunded, uint256 totalRequired);

Parameters

NameTypeDescription
_milestoneIdbytes32- Identifier of the milestone
_stepIndexuint256- Index of the step

Returns

NameTypeDescription
fundingTypeuint8- Type of funding (Full or Partial)
totalFundeduint256- Total amount of tokens funded for this step
totalRequireduint256- Total amount of tokens required for this step (allocation)

isStepFullyFunded

Check if a milestone step is fully funded

function isStepFullyFunded(bytes32 _milestoneId, uint256 _stepIndex) external view returns (bool);

Parameters

NameTypeDescription
_milestoneIdbytes32- Identifier of the milestone
_stepIndexuint256- Index of the step

Returns

NameTypeDescription
<none>boolisFullyFunded - True if the step is fully funded

getStepClaimableAmount

Get the claimable amount for a specific milestone step

function getStepClaimableAmount(bytes32 _milestoneId, uint256 _stepIndex) external view returns (uint256);

Parameters

NameTypeDescription
_milestoneIdbytes32- The ID of the milestone
_stepIndexuint256- The index of the step

Returns

NameTypeDescription
<none>uint256claimableAmount - The amount of tokens that can be claimed for this step

amountAvailableToWithdrawByAdmin

Amount of tokens available to withdraw by the admin

function amountAvailableToWithdrawByAdmin() public view returns (uint256);

isRecipient

Check if a recipient has milestones

function isRecipient(address recipient) external view returns (bool);

Parameters

NameTypeDescription
recipientaddress- The recipient address

Returns

NameTypeDescription
<none>boolisRecipient - True if the recipient has milestones

_revokeMilestoneStep

Revokes a milestone step (internal implementation)

function _revokeMilestoneStep(bytes32 _milestoneId, uint256 _stepIndex) internal returns (uint256);

Parameters

NameTypeDescription
_milestoneIdbytes32The ID of the milestone
_stepIndexuint256The index of the step

Returns

NameTypeDescription
<none>uint256uint256 The amount of tokens revoked

_processStepFunding

function _processStepFunding(
bytes32 milestoneId,
Milestone storage milestone,
uint256 stepId,
uint256 fundingAmount,
uint256 stepsLength
) internal returns (uint256);

_createMilestone

Internal function to create a new milestone

function _createMilestone(
bytes32 _milestoneId,
address _recipient,
uint256[] calldata _allocations,
string[] calldata _externalRefs
) internal returns (uint256 totalExpectedAmount);

Parameters

NameTypeDescription
_milestoneIdbytes32- The ID of the milestone to create
_recipientaddress- The address of the recipient
_allocationsuint256[]- The amount of tokens to allocate for each step
_externalRefsstring[]- The external reference of each step

Returns

NameTypeDescription
totalExpectedAmountuint256- The total amount of tokens expected for this milestone

_removeMilestoneFromRecipient

Helper function to remove a milestone ID from a recipient's array

function _removeMilestoneFromRecipient(address _recipient, bytes32 _milestoneId) internal;

Parameters

NameTypeDescription
_recipientaddressThe address of the recipient
_milestoneIdbytes32The ID of the milestone to remove

_removeRecipient

Helper function to remove a recipient from the recipients array

function _removeRecipient(address _recipient) internal;

Parameters

NameTypeDescription
_recipientaddressThe address of the recipient to remove

_isRecipient

Internal function to check if an address is a recipient

function _isRecipient(address recipient) internal view returns (bool);

Parameters

NameTypeDescription
recipientaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue if the address is a recipient, false otherwise

_getTotalRequired

Helper to compute total required for milestone

function _getTotalRequired(bytes32 milestoneId) internal view returns (uint256 total);

_getTotalFunded

Helper to compute total funded for milestone (partial funding mode only)

function _getTotalFunded(bytes32 milestoneId) internal view returns (uint256 total);

_createVesting

Internal function to create a vesting schedule for a given recipient

function _createVesting(
address _recipient,
uint32 _startTimestamp,
uint32 _endTimestamp,
uint32 _timelock,
uint256 _initialUnlock,
uint32 _cliffReleaseTimestamp,
uint256 _cliffAmount,
uint32 _releaseIntervalSecs,
uint256 _linearVestAmount,
bool _isRevocable
) internal pure returns (TokenVestingLib.Vesting memory);

Parameters

NameTypeDescription
_recipientaddressThe address of the recipient for whom the vesting is created.
_startTimestampuint32The start time of the vesting period as a UNIX timestamp.
_endTimestampuint32The end time of the vesting period as a UNIX timestamp.
_timelockuint32Optional timelock period before which tokens cannot be claimed.
_initialUnlockuint256Amount of tokens that are immediately vested when the vesting starts.
_cliffReleaseTimestampuint32The timestamp at which the cliff amount is released.
_cliffAmountuint256The amount of tokens released at the cliff.
_releaseIntervalSecsuint32The interval, in seconds, at which the linear vesting releases occur after the cliff.
_linearVestAmountuint256The total amount of tokens to be released linearly after the cliff has passed.
_isRevocableboolFlag to determine if the vesting can be revoked.

Returns

NameTypeDescription
<none>TokenVestingLib.Vestingvesting A struct representing the vesting schedule.

The VestedMilestoneManager provides a powerful framework for milestone-based token vesting with flexible approval workflows and comprehensive management capabilities.