Skip to main content

JB721TieredGovernance

A tiered 721 delegate where each NFT can be used for on chain governance, with votes delegatable per tier.


Git Source

Inherits: JBTiered721Delegate, IJB721TieredGovernance

Adheres to -

  • IJB721TieredGovernance: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.

Inherits from -

  • JBTiered721Delegate: The tiered 721 delegate.
  • Votes: A helper for voting balance snapshots.

State Variables

_tierDelegation

The delegation status for each address and for each tier. _delegator The delegator. _tierId The ID of the tier being delegated.

mapping(address => mapping(uint256 => address)) internal _tierDelegation;

_delegateTierCheckpoints

The delegation checkpoints for each address and for each tier. _delegator The delegator. _tierId The ID of the tier being delegated.

mapping(address => mapping(uint256 => Checkpoints.History)) internal _delegateTierCheckpoints;

_totalTierCheckpoints

The total delegation status for each tier. _tierId The ID of the tier being delegated.

mapping(uint256 => Checkpoints.History) internal _totalTierCheckpoints;

Functions

getTierDelegate

Returns the delegate of an account for specific tier.

function getTierDelegate(address _account, uint256 _tier) external view override returns (address);

Parameters

NameTypeDescription
_accountaddressThe account to check for a delegate of.
_tieruint256the tier to check within.

getTierVotes

Returns the current voting power of an address for a specific tier.

function getTierVotes(address _account, uint256 _tier) external view override returns (uint256);

Parameters

NameTypeDescription
_accountaddressThe address to check.
_tieruint256The tier to check within.

getPastTierVotes

Returns the past voting power of a specific address for a specific tier.

function getPastTierVotes(address _account, uint256 _tier, uint256 _blockNumber)
external
view
override
returns (uint256);

Parameters

NameTypeDescription
_accountaddressThe address to check.
_tieruint256The tier to check within.
_blockNumberuint256the blocknumber to check the voting power at.

getTierTotalVotes

Returns the total amount of voting power that exists for a tier.

function getTierTotalVotes(uint256 _tier) external view override returns (uint256);

Parameters

NameTypeDescription
_tieruint256The tier to check.

getPastTierTotalVotes

Returns the total amount of voting power that exists for a tier.

function getPastTierTotalVotes(uint256 _tier, uint256 _blockNumber) external view override returns (uint256);

Parameters

NameTypeDescription
_tieruint256The tier to check.
_blockNumberuint256The blocknumber to check the total voting power at.

setTierDelegates

Delegates votes from the sender to delegatee.

function setTierDelegates(JBTiered721SetTierDelegatesData[] memory _setTierDelegatesData) external virtual override;

Parameters

NameTypeDescription
_setTierDelegatesDataJBTiered721SetTierDelegatesData[]An array of tiers to set delegates for.

setTierDelegate

Delegates votes from the sender to delegatee.

function setTierDelegate(address _delegatee, uint256 _tierId) public virtual override;

Parameters

NameTypeDescription
_delegateeaddressThe account to delegate tier voting units to.
_tierIduint256The ID of the tier to delegate voting units for.

_getTierVotingUnits

Gets the amount of voting units an address has for a particular tier.

function _getTierVotingUnits(address _account, uint256 _tierId) internal view virtual returns (uint256);

Parameters

NameTypeDescription
_accountaddressThe account to get voting units for.
_tierIduint256The ID of the tier to get voting units for.

Returns

NameTypeDescription
<none>uint256The voting units.

_delegateTier

Delegate all of account's voting units for the specified tier to delegatee.

function _delegateTier(address _account, address _delegatee, uint256 _tierId) internal virtual;

Parameters

NameTypeDescription
_accountaddressThe account delegating tier voting units.
_delegateeaddressThe account to delegate tier voting units to.
_tierIduint256The ID of the tier for which voting units are being transferred.

_transferTierVotingUnits

Transfers, mints, or burns tier voting units. To register a mint, from should be zero. To register a burn, to should be zero. Total supply of voting units will be adjusted with mints and burns.

function _transferTierVotingUnits(address _from, address _to, uint256 _tierId, uint256 _amount) internal virtual;

Parameters

NameTypeDescription
_fromaddressThe account to transfer tier voting units from.
_toaddressThe account to transfer tier voting units to.
_tierIduint256The ID of the tier for which voting units are being transferred.
_amountuint256The amount of voting units to delegate.

_moveTierDelegateVotes

Moves delegated tier votes from one delegate to another.

function _moveTierDelegateVotes(address _from, address _to, uint256 _tierId, uint256 _amount) internal;

Parameters

NameTypeDescription
_fromaddressThe account to transfer tier voting units from.
_toaddressThe account to transfer tier voting units to.
_tierIduint256The ID of the tier for which voting units are being transferred.
_amountuint256The amount of voting units to delegate.

_afterTokenTransferAccounting

handles the tier voting accounting

function _afterTokenTransferAccounting(address _from, address _to, uint256 _tokenId, JB721Tier memory _tier)
internal
virtual
override;

Parameters

NameTypeDescription
_fromaddressThe account to transfer voting units from.
_toaddressThe account to transfer voting units to.
_tokenIduint256The ID of the token for which voting units are being transferred.
_tierJB721TierThe tier the token ID is part of.

_add

function _add(uint256 a, uint256 b) internal pure returns (uint256);

_subtract

function _subtract(uint256 a, uint256 b) internal pure returns (uint256);

Errors

BLOCK_NOT_YET_MINED

error BLOCK_NOT_YET_MINED();

DELEGATE_ADDRESS_ZERO

error DELEGATE_ADDRESS_ZERO();