Solidity API

GrantsManager

Contract that manages grant funds milestone validation and claiming

GOVERNANCE_ROLE

bytes32 GOVERNANCE_ROLE

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

GRANTS_APPROVER_ROLE

bytes32 GRANTS_APPROVER_ROLE

GRANTS_REJECTOR_ROLE

bytes32 GRANTS_REJECTOR_ROLE

PAUSER_ROLE

bytes32 PAUSER_ROLE

GrantsManagerStorage

Storage structure for GrantsManager

struct GrantsManagerStorage {
  mapping(uint256 => struct IGrantsManager.GrantProposal) grant;
  contract IB3TRGovernor governor;
  contract ITreasury treasury;
  contract IB3TR b3tr;
  uint256 minimumMilestoneCount;
}

constructor

constructor() public

initialize

function initialize(address _governor, address _treasury, address defaultAdmin, address _b3tr, uint256 _minimumMilestoneCount) external

onlyAdminOrGovernanceRole

modifier onlyAdminOrGovernanceRole()

onlyRoleOrGovernance

modifier onlyRoleOrGovernance(bytes32 role)

onlyGovernor

modifier onlyGovernor()

onlyGrantsReceiverOrGovernance

modifier onlyGrantsReceiverOrGovernance(uint256 proposalId)

createMilestones

function createMilestones(string metadataURI, uint256 proposalId, address proposer, address grantsReceiver, bytes[] calldatas) external

Internal function to create milestones for a proposal.

Parameters

Name Type Description
metadataURI string The IPFS hash containing the milestones descriptions
proposalId uint256 The ID of the proposal
proposer address The address of the proposer
grantsReceiver address
calldatas bytes[] The calldatas of the milestones

getMilestone

function getMilestone(uint256 proposalId, uint256 milestoneIndex) external view returns (struct IGrantsManager.Milestone)

Returns a milestone for a proposal.

Parameters

Name Type Description
proposalId uint256 The id of the proposal
milestoneIndex uint256 The index of the milestone

Return Values

Name Type Description
[0] struct IGrantsManager.Milestone Milestone The milestone

isGrantRejected

function isGrantRejected(uint256 proposalId) public view returns (bool)

Returns if a proposal is rejected

A grant is rejected when at least one milestone is rejected

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] bool bool True if the proposal is rejected, false otherwise

isGrantInDevelopment

function isGrantInDevelopment(uint256 proposalId) public view returns (bool)

Returns if a proposal is in development

A grant is in development when: 1. The proposal has been executed AND 2. At least one milestone is still pending

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] bool bool True if the proposal is in development, false otherwise

isGrantCompleted

function isGrantCompleted(uint256 proposalId) public view returns (bool)

Returns if a proposal is completed

Ascending order status of the milestones, so last one is the one that determines the status of the grant

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] bool bool True if the proposal is completed, false otherwise

_getMilestoneState

function _getMilestoneState(uint256 proposalId, uint256 milestoneIndex) internal view returns (enum IGrantsManager.MilestoneState status)

Returns the state of a milestone

Parameters

Name Type Description
proposalId uint256 The id of the proposal
milestoneIndex uint256 The index of the milestone

Return Values

Name Type Description
status enum IGrantsManager.MilestoneState The state of the milestone {see IGrantsManager:MilestoneState }

getMilestones

function getMilestones(uint256 proposalId) external view returns (struct IGrantsManager.Milestone[])

Returns the milestones for a proposal.

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] struct IGrantsManager.Milestone[] GrantProposal The milestones for the proposal

getGrantProposal

function getGrantProposal(uint256 proposalId) external view returns (struct IGrantsManager.GrantProposal)

Returns the grant proposal for a proposal.

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] struct IGrantsManager.GrantProposal GrantProposal The grant proposal for the proposal

approveMilestones

function approveMilestones(uint256 proposalId, uint256 milestoneIndex) external

Approves a milestone

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
milestoneIndex uint256 The index of the milestone

approveMilestoneWithReason

function approveMilestoneWithReason(uint256 proposalId, uint256 milestoneIndex, string reason) external

Approves a milestone with a reason

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
milestoneIndex uint256 The index of the milestone
reason string The reason for approving the milestone

setMinimumMilestoneCount

function setMinimumMilestoneCount(uint256 minimumMilestoneCount) external

Sets the minimum number of milestones for a grant proposal

Parameters

Name Type Description
minimumMilestoneCount uint256 The minimum milestone count

getMinimumMilestoneCount

function getMinimumMilestoneCount() external view returns (uint256)

Returns the minimum milestone count for a proposal.

Return Values

Name Type Description
[0] uint256 uint256 The minimum milestone count.

milestoneState

function milestoneState(uint256 proposalId, uint256 milestoneIndex) external view returns (enum IGrantsManager.MilestoneState)

Returns the state of a milestone

Parameters

Name Type Description
proposalId uint256 The id of the proposal
milestoneIndex uint256 The index of the milestone

Return Values

Name Type Description
[0] enum IGrantsManager.MilestoneState MilestoneState The state of the milestone

rejectMilestones

function rejectMilestones(uint256 proposalId) external

Rejects a milestone

Parameters

Name Type Description
proposalId uint256 The ID of the proposal

getTotalAmountForMilestones

function getTotalAmountForMilestones(uint256 milestoneId) external view returns (uint256)

Returns the total amount for milestones

Parameters

Name Type Description
milestoneId uint256 The ID of the milestone

Return Values

Name Type Description
[0] uint256 The total amount for the milestones

claimMilestone

function claimMilestone(uint256 proposalId, uint256 milestoneIndex) external

Claims funds for a validated milestone

Parameters

Name Type Description
proposalId uint256 The ID of the grant proposal
milestoneIndex uint256 The index of the milestone to claim

isClaimable

function isClaimable(uint256 proposalId, uint256 milestoneIndex) external view returns (bool)

Returns if a milestone is claimable

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
milestoneIndex uint256 The index of the milestone

Return Values

Name Type Description
[0] bool bool True if the milestone is claimable, false otherwise

grantState

function grantState(uint256 proposalId) external view returns (enum IGrantsManager.GrantState)

Returns the state of a grant {see IGrantsManager:GrantState }

Parameters

Name Type Description
proposalId uint256 The id of the proposal

Return Values

Name Type Description
[0] enum IGrantsManager.GrantState GrantState The state of the grant

setGovernorContract

function setGovernorContract(address _governor) external

Sets the governor contract

Parameters

Name Type Description
_governor address The address of the governor contract

getGovernorContract

function getGovernorContract() external view returns (address)

Returns the governor contract

Return Values

Name Type Description
[0] address The address of the governor contract

updateGrantsReceiver

function updateGrantsReceiver(uint256 proposalId, address newGrantsReceiver) external

Updates the grants receiver address

Only the grants receiver or governance can update the grants receiver address

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
newGrantsReceiver address The address of the grants receiver contract

getGrantsReceiverAddress

function getGrantsReceiverAddress(uint256 proposalId) external view returns (address)

Returns the grants receiver address

Parameters

Name Type Description
proposalId uint256 The ID of the proposal

Return Values

Name Type Description
[0] address The address of the grants receiver

setTreasuryContract

function setTreasuryContract(address _treasury) external

Sets the treasury contract

Parameters

Name Type Description
_treasury address The address of the treasury contract

getTreasuryContract

function getTreasuryContract() external view returns (address)

Returns the treasury contract

Return Values

Name Type Description
[0] address The address of the treasury contract

getB3trContract

function getB3trContract() external view returns (address)

Returns the b3tr contract

Return Values

Name Type Description
[0] address The address of the b3tr contract

setB3trContract

function setB3trContract(address _b3tr) external

Sets the b3tr contract

Parameters

Name Type Description
_b3tr address The address of the b3tr contract

pause

function pause() public

Pauses all token transfers and minting functions

Only callable by accounts with the PAUSER_ROLE or the DEFAULT_ADMIN_ROLE

unpause

function unpause() public

Unpauses the contract to resume token transfers and minting

Only callable by accounts with the PAUSER_ROLE or the DEFAULT_ADMIN_ROLE

updateMilestoneMetadataURI

function updateMilestoneMetadataURI(uint256 proposalId, string newMilestoneMetadataURI) external

Updates the metadata URI for a milestone The JSON is {milestone1: {details: …, duration: timestamp}, milestone2: {details: …, duration: timestamp}}

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
newMilestoneMetadataURI string The new IPFS hash containing the updated milestone descriptions

getMilestoneMetadataURI

function getMilestoneMetadataURI(uint256 proposalId) external view returns (string)

Returns the metadata URI for a milestone

Parameters

Name Type Description
proposalId uint256 The ID of the proposal

Return Values

Name Type Description
[0] string The metadata URI for the milestone

_validateMilestones

function _validateMilestones(struct IGrantsManager.GrantProposal grant) internal view

Validates the milestones

Parameters

Name Type Description
grant struct IGrantsManager.GrantProposal The milestones to validate

_transferRemainingAmountToTreasury

function _transferRemainingAmountToTreasury(uint256 proposalId) internal

Transfers the remaining amount to the treasury

Parameters

Name Type Description
proposalId uint256 The ID of the proposal

_checkProposalState

function _checkProposalState(uint256 proposalId) internal view

Checks if the proposal state is executed

Parameters

Name Type Description
proposalId uint256 The ID of the proposal

_checkMilestoneState

function _checkMilestoneState(uint256 proposalId, uint256 milestoneIndex) internal view

Checks if the milestone state is pending

Parameters

Name Type Description
proposalId uint256 The ID of the proposal
milestoneIndex uint256 The index of the milestone

version

function version() external pure returns (uint256)

Returns the version of the contract

Return Values

Name Type Description
[0] uint256 The version of the contract

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal

Authorize upgrade for UUPS

Only addresses with the UPGRADER_ROLE can upgrade the contract