TokenDistributor
Escrow contract for making deposited tokens claimable by members of Parties in proportion to their voting power in the Party.
Code
Functions
createNativeDistribution
Create a new distribution for an outstanding native token balance governed by a Party.
Native tokens should be transferred directly into this contract immediately prior (same tx) to calling createDistribution()
or attached to the call itself.
function createNativeDistribution(Party party, address payable feeRecipient, uint16 feeBps)
external
payable
returns (DistributionInfo memory info);
Parameters
Name | Type | Description |
---|---|---|
party | Party | The Party whose members can claim the distribution. |
feeRecipient | address payable | Who can claim fee. |
feeBps | uint16 | Percentage (in bps) of the distribution feeRecipient receives. |
Returns
Name | Type | Description |
---|---|---|
info | DistributionInfo | Information on the created distribution. |
createErc20Distribution
Create a new distribution for an outstanding ERC20 token balance governed by a Party.
ERC20 tokens should be transferred directly into this contract immediately prior (same tx) to calling createDistribution()
or attached to the call itself.
function createErc20Distribution(IERC20 token, Party party, address payable feeRecipient, uint16 feeBps)
external
returns (DistributionInfo memory info);
Parameters
Name | Type | Description |
---|---|---|
token | IERC20 | The ERC20 token to distribute. |
party | Party | The Party whose members can claim the distribution. |
feeRecipient | address payable | Who can claim fee. |
feeBps | uint16 | Percentage (in bps) of the distribution feeRecipient receives. |
Returns
Name | Type | Description |
---|---|---|
info | DistributionInfo | Information on the created distribution. |
claim
Claim a portion of a distribution owed to a partyTokenId
belonging to the Party that created the distribution. The caller must own this token.
function claim(DistributionInfo calldata info, uint256 partyTokenId) public returns (uint128 amountClaimed);
Parameters
Name | Type | Description |
---|---|---|
info | DistributionInfo | Information on the distribution being claimed. |
partyTokenId | uint256 | The ID of the Party token to claim for. |
Returns
Name | Type | Description |
---|---|---|
amountClaimed | uint128 | The amount of the distribution claimed. |
claimFee
Claim the fee for a distribution. Only a distribution's feeRecipient
can call this.
function claimFee(DistributionInfo calldata info, address payable recipient) public;
Parameters
Name | Type | Description |
---|---|---|
info | DistributionInfo | Information on the distribution being claimed. |
recipient | address payable | The address to send the fee to. |
batchClaim
Batch version of claim()
.
function batchClaim(DistributionInfo[] calldata infos, uint256[] calldata partyTokenIds)
external
returns (uint128[] memory amountsClaimed);
Parameters
Name | Type | Description |
---|---|---|
infos | DistributionInfo[] | Information on the distributions being claimed. |
partyTokenIds | uint256[] | The ID of the Party tokens to claim for. |
Returns
Name | Type | Description |
---|---|---|
amountsClaimed | uint128[] | The amount of the distributions claimed. |
batchClaimFee
Batch version of claimFee()
.
function batchClaimFee(DistributionInfo[] calldata infos, address payable[] calldata recipients) external;
Parameters
Name | Type | Description |
---|---|---|
infos | DistributionInfo[] | Information on the distributions to claim fees for. |
recipients | address payable[] | The addresses to send the fees to. |
getClaimAmount
Compute the amount of a distribution's token are owed to a Party member, identified by the partyTokenId
.
function getClaimAmount(DistributionInfo calldata info, uint256 partyTokenId) public view returns (uint128);
Parameters
Name | Type | Description |
---|---|---|
info | DistributionInfo | Information on the distribution being claimed. |
partyTokenId | uint256 | The ID of the Party token to claim for. |
Returns
Name | Type | Description |
---|---|---|
uint128 | claimAmount The amount of the distribution owed to the Party member. |
wasFeeClaimed
Check whether the fee has been claimed for a distribution.
function wasFeeClaimed(Party party, uint256 distributionId) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
party | Party | The Party to use for checking whether the fee has been claimed. |
distributionId | uint256 | The ID of the distribution to check. |
Returns
Name | Type | Description |
---|---|---|
bool | feeClaimed Whether the fee has been claimed. |
hasPartyTokenIdClaimed
Check whether a partyTokenId
has claimed their share of a distribution.
function hasPartyTokenIdClaimed(Party party, uint256 partyTokenId, uint256 distributionId)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
party | Party | The Party to use for checking whether the partyTokenId has claimed. |
partyTokenId | uint256 | The ID of the Party token to check. |
distributionId | uint256 | The ID of the distribution to check. |
Returns
Name | Type | Description |
---|---|---|
bool | hasClaimed Whether the partyTokenId has claimed. |
getRemainingMemberSupply
Get how much unclaimed member tokens are left in a distribution.
function getRemainingMemberSupply(Party party, uint256 distributionId) external view returns (uint128);
Parameters
Name | Type | Description |
---|---|---|
party | Party | The party to use for checking the unclaimed member tokens. |
distributionId | uint256 | The ID of the distribution to check. |
Returns
Name | Type | Description |
---|---|---|
uint128 | remainingMemberSupply The amount of distribution supply remaining. |