RollingAuctionCrowdfund
A crowdfund that can repeatedly bid on auctions for an NFT from a specific collection on a specific market (e.g. Nouns) and can continue bidding on new auctions until it wins. Unlike AuctionCrowdfund
, this crowdfund will continue bidding on a new auction if it loses its current auction until it either wins or expires.
Code
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 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 aucitons 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 win any auctions and acquire an NFT from the target collection or to “Won” if it has.
Won
The crowdfund has successfully acquired an NFT from an 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 an NFT from an auction and has expired. 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. |
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
Name | Type | Description |
---|---|---|
amount | uint96 | The amount to bid. |
governanceOpts | FixedGovernanceOpts | The governance options the crowdfund was created with. Used to verify the caller is a host. |
hostIndex | uint256 | If 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 we won, or recover our bid (if necessary) if the crowfund expired and we lost the current auction. If we lost but the crowdfund has not expired, this will revert. Only call this to finalize the result of a won or expired crowdfund, otherwise call finalizeOrRollOver()
.
function finalize(FixedGovernanceOpts memory governanceOpts) external onlyDelegateCall returns (Party party_);
Parameters
Name | Type | Description |
---|---|---|
governanceOpts | FixedGovernanceOpts | The options used to initialize governance in the Party instance created if the crowdfund wins. |
Returns
Name | Type | Description |
---|---|---|
party_ | Party | Address of the Party instance created if successful. |
finalizeOrRollOver
Calls finalize()
on the market adapter, which will claim the NFT (if necessary) if we won, or recover our bid (if necessary) if the crowfund expired and we lost. If we lost but the crowdfund has not expired, it will move on to the next auction specified (if allowed).
function finalizeOrRollOver(
uint256 nextNftTokenId,
uint256 nextAuctionId,
uint96 nextMaximumBid,
bytes32[] memory proof,
FixedGovernanceOpts memory governanceOpts,
uint256 hostIndex
) public onlyDelegateCall returns (Party party_);
Parameters
Name | Type | Description |
---|---|---|
nextNftTokenId | uint256 | The tokenId of the next NFT to bid on in the next auction. Only used if the crowdfund lost the current auction. |
nextAuctionId | uint256 | The auctionId of the the next auction. Only used if the crowdfund lost the current auction. |
nextMaximumBid | uint96 | The maximum bid the Party can place for the next auction. Only used if the crowdfund lost the current auction. |
proof | bytes32[] | The Merkle proof used to verify that nextAuctionId and nextNftTokenId are allowed. Only used if the crowdfund lost the current auction. |
governanceOpts | FixedGovernanceOpts | The options used to initialize governance in the Party instance created if the crowdfund wins. |
hostIndex | uint256 | If the caller is a Host, this is the index of the caller in the governanceOpts.hosts array. Only used if the crowdfund lost the current auction AND Hosts are allowed to choose any next auction. |
Returns
Name | Type | Description |
---|---|---|
party_ | Party | Address 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;
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);