BuyCrowdfund
A crowdfund that purchases a specific NFT (i.e., with a known token ID from a known collection) listing for a known price.
Code
Roles
Contributors
Users who have contributed to the crowdfund. While the crowdfund is active, contributors can execute a call for the crowdfund to buy the NFT (up to maximumPrice
) if onlyHostCanBuy
is disabled.
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. If onlyHostCanBuy
is enabled, they will be the only role that can execute a call for the crowdfund to buy the NFT when enough funds are raised.
Split Recipient
An optional address that can claim a Party membership 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. Members of the crowdfund can collectively buy the NFT once enough pooled funds have been raised to transition the crowdfund to the “Won” state.
Busy
A temporary state set by the contract during operations (e.g. while buying the NFT) to act as a reentrancy guard.
Won
The crowdfund has successfully acquired the NFT and a Party has been created around the NFT. Contributors can now claim their Party Cards and/or reclaim any unused contributions that did not go towards acquiring the NFT.
Lost
The crowdfund has expired and failed to acquire the NFT. 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. |
buy
Execute arbitrary calldata to perform a buy, creating a Party if it successfully buys the NFT.
function buy(
address payable callTarget,
uint96 callValue,
bytes memory callData,
FixedGovernanceOpts memory governanceOpts,
uint256 hostIndex
) external onlyDelegateCall returns (Party party_);
Parameters
Name | Type | Description |
---|---|---|
callTarget | address payable | The target contract to call to buy the NFT. |
callValue | uint96 | The amount of ETH to send with the call. |
callData | bytes | The calldata to execute. |
governanceOpts | FixedGovernanceOpts | The options used to initialize governance in the Party instance created if the buy was successful. |
hostIndex | uint256 | If the caller is a host, this is the index of the caller in the governanceOpts.hosts array. |
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);