CollectionBatchBuyCrowdfund
A crowdfund that purchases multiple NFTs with any token ID from a collection below a maximum price. Like CollectionBuyCrowdfund
, but allows the acquisition of several NFTs of the same collection in a single batch transaction.
Code
CollectionBatchBuyCrowdfund.sol
Roles
Contributors
Users who have contributed to the crowdfund.
Hosts
Trusted addresses with the ability to unilaterally veto proposals and configure Rage Quit in the Party that is created after the crowdfund is won. Will be the only role that can execute a call for the crowdfund to buy NFTs with a tokenIds
of their choosing when enough funds are raised.
Split Recipient
An optional address that can claim a Party Card with a reserved percentage of voting power after the crowdfund wins without needing to contribute. If they contribute, the reserved voting power reserved for them will be added to the voting power they would be entitled to from their contribution.
States
Active
The crowdfund has been created and contributions can be made. Hosts of the crowdfund can buy NFTs for the crowdfund once enough pooled funds have been raised and transition the crowdfund to the “Won” state.
Busy
A temporary state set by the contract during operations (e.g. while buying NFTs) to act as a reentrancy guard.
Won
The crowdfund has successfully acquired NFTs from the collection and a Party has been created around them. Contributors can now claim their Party Cards and/or reclaim any unused contributions that did not go towards acquiring the NFTs.
Lost
The crowdfund has expired and failed to acquire any NFTs. Contributors can now reclaim their original contributions from the crowdfund.
Functions
contribute
Contribute to this crowdfund and/or update your delegation for the governance phase should the crowdfund succeed. For restricted crowdfunds, gateData
can be provided to prove membership to the gatekeeper.
function contribute(address delegate, bytes memory gateData) external payable onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
delegate | address | The address to delegate to for the governance phase. |
gateData | bytes | Data to pass to the gatekeeper to prove eligibility. |
contributeFor
Contribute to this crowdfund on behalf of another address.
function contributeFor(address recipient, address initialDelegate, bytes memory gateData)
external
payable
onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
recipient | address | The address to record the contribution under. |
initialDelegate | address | The address to delegate to for the governance phase if recipient hasn't delegated. |
gateData | bytes | Data to pass to the gatekeeper to prove eligibility. |
batchContributeFor
contributeFor()
in batch form. May not revert if any individual contribution fails.
function batchContributeFor(
address[] memory recipients,
address[] memory initialDelegates,
uint256[] memory values,
bytes[] memory gateDatas,
bool revertOnFailure
) external payable;
Parameters
Name | Type | Description |
---|---|---|
recipients | address[] | The addresses to record the contributions under. |
initialDelegates | address[] | The addresses to delegate to for each recipient. |
values | uint256[] | The ETH to contribute for each recipient. |
gateDatas | bytes[] | Data to pass to the gatekeeper to prove eligibility. |
revertOnFailure | bool | If true, revert if any contribution fails. |
batchBuy
Execute arbitrary calldata to perform a batch buy, creating a Party if it successfully buys the NFT. Only a host may call this.
function batchBuy(BatchBuyArgs memory args) external onlyDelegateCall returns (Party party_);
Parameters
Name | Type | Description |
---|---|---|
args | BatchBuyArgs | Arguments for the batch buy. |
Returns
Name | Type | Description |
---|---|---|
party_ | Party | Address of the Party instance created after its bought. |
activateOrRefund
Burn the participation NFT for contributor
, potentially minting voting power and/or refunding unused ETH. contributor
may also be the split recipient, regardless of whether they are also a contributor or not. This can be called by anyone on a contributor's behalf to unlock their voting power in the governance stage ensuring delegates receive their voting power and governance is not stalled.
function activateOrRefund(address payable contributor) external;
Name | Type | Description |
---|---|---|
contributor | address payable | The contributor whose NFT to burn for. |
batchActivateOrRefund
activateOrRefund()
in batch form. Will not revert if any individual burn fails.
function batchActivateOrRefund(address payable[] calldata contributors, bool revertOnFailure) external;
Name | Type | Description |
---|---|---|
contributors | address payable[] | The contributors whose NFT to burn for. |
revertOnFailure | bool | If true, revert if any burn fails. |
claim
Claim a Party Card or refund that is owed back but could not be given due to error in _burn()
(eg. a contract that does not implement onERC721Received()
or cannot receive ETH). Only call this if refund and Party Card minting could not be returned with burn()
.
function claim(address payable receiver) external;
Parameters
Name | Type | Description |
---|---|---|
receiver | address payable | The address to receive the NFT or refund. |
getContributorInfo
Retrieve info about a participant's contributions.
This will only be called off-chain so doesn't have to be optimal.
function getContributorInfo(address contributor)
external
view
returns (uint256 ethContributed, uint256 ethUsed, uint256 ethOwed, uint256 votingPower);
Parameters
Name | Type | Description |
---|---|---|
contributor | address | The contributor to retrieve contributions for. |
Returns
Name | Type | Description |
---|---|---|
ethContributed | uint256 | The total ETH contributed by contributor. |
ethUsed | uint256 | The total ETH used by contributor to acquire the NFT. |
ethOwed | uint256 | The total ETH refunded back to contributor. |
votingPower | uint256 | The total voting power minted to contributor. |
getCrowdfundLifecycle
Get the current lifecycle of the crowdfund.
function getCrowdfundLifecycle() public view virtual returns (CrowdfundLifecycle lifecycle);