Skip to main content

AuctionCrowdfund

A crowdfund that can repeatedly bid in an auction for a specific NFT (i.e., with a known token ID from a known collection) until the auction ends.

Code

AuctionCrowdfund.sol

Roles

Contributors

Users who have contributed to the crowdfund. While the crowdfund is active, contributors can place bids on the auction with the minimum amount so that the Party is the highest bidder (up to maximumBid) if onlyHostCanBid 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. While the crowdfund is active, the Host can place bids on the auction with custom amounts (not just the minimum). If onlyHostCanBid is enabled, they will be the only role that can place bids on the auction.

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 place bids on the auction with their pooled funds.

Busy

A temporary state set by the contract during operations (e.g. while bidding in the auction) to act as a reentrancy guard.

Expired

The crowdfund has passed its expiration time. No more contributions are allowed. The crowdfund will need to be finalized, which will move it to the “Lost” state if it has failed to acquire the NFT from the auction or to “Won” if it has.

Won

The crowdfund has successfully acquired the NFT from the auction and a Party has been created around the NFT. Contributors can now claim their Party membership cards and/or reclaim any unused contributions that did not go towards winning the auction.

Lost

The crowdfund has failed to acquire the NFT from the auction. 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

NameTypeDescription
delegateaddressThe address to delegate to for the governance phase.
gateDatabytesData 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

NameTypeDescription
recipientaddressThe address to record the contribution under.
initialDelegateaddressThe address to delegate to for the governance phase if recipient hasn't delegated.
gateDatabytesData 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

NameTypeDescription
recipientsaddress[]The addresses to record the contributions under.
initialDelegatesaddress[]The addresses to delegate to for each recipient.
valuesuint256[]The ETH to contribute for each recipient.
gateDatasbytes[]Data to pass to the gatekeeper to prove eligibility.
revertOnFailureboolIf true, revert if any contribution fails.

bid

Place a bid on the NFT using the funds in this crowdfund, placing the minimum possible bid to be the highest bidder, up to maximumBid. Only callable by contributors if onlyHostCanBid is not enabled.

function bid() external;

bid

Place a bid on the NFT using the funds in this crowdfund, placing a bid, up to maximumBid. Only host can call this.

function bid(uint96 amount, FixedGovernanceOpts memory governanceOpts, uint256 hostIndex) external;

Parameters

NameTypeDescription
amountuint96The amount to bid.
governanceOptsFixedGovernanceOptsThe governance options the crowdfund was created with. Used to verify the caller is a host.
hostIndexuint256If the caller is a host, this is the index of the caller in the governanceOpts.hosts array. Used to verify the caller is a host.

finalize

Calls finalize() on the market adapter, which will claim the NFT (if necessary) if the crowdfund won, or recover the bid (if necessary) if the crowdfund lost. If won, a governance Party will also be created.

function finalize(FixedGovernanceOpts memory governanceOpts) external onlyDelegateCall returns (Party party_);

Parameters

NameTypeDescription
governanceOptsFixedGovernanceOptsThe options used to initialize governance in the Party instance created if the crowdfund wins.

Returns

NameTypeDescription
party_PartyAddress of the Party instance created if successful.

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;

NameTypeDescription
contributoraddress payableThe 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;

NameTypeDescription
contributorsaddress payable[]The contributors whose NFT to burn for.
revertOnFailureboolIf 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

NameTypeDescription
receiveraddress payableThe 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

NameTypeDescription
contributoraddressThe contributor to retrieve contributions for.

Returns

NameTypeDescription
ethContributeduint256The total ETH contributed by contributor.
ethUseduint256The total ETH used by contributor to acquire the NFT.
ethOweduint256The total ETH refunded back to contributor.
votingPoweruint256The total voting power minted to contributor.

getCrowdfundLifecycle

Get the current lifecycle of the crowdfund.

function getCrowdfundLifecycle() public view virtual returns (CrowdfundLifecycle lifecycle);