IdeaTokenHub

Git Source

Inherits: OwnableUpgradeable, UUPSUpgradeable, ERC1155Upgradeable, IIdeaTokenHub

Author: 📯📯📯.eth

State Variables

decimals

uint256 public constant decimals = 18;

__waveCore

IWave private __waveCore;

__nounsGovernor

INounsDAOLogicV4 private __nounsGovernor;

minSponsorshipAmount

ERC1155 balance recordkeeping directly mirrors Ether values

uint256 public minSponsorshipAmount;

waveLength

The length of time for a wave in blocks, marking the block number where winning ideas are chosen

uint256 public waveLength;

_currentWaveId

uint256 private _currentWaveId;

_nextIdeaId

uint96 private _nextIdeaId;

ideaInfos

type(uint96).max size provides a large buffer for tokenIds, overflow is unrealistic

mapping(uint96 => IdeaInfo) internal ideaInfos;

waveInfos

mapping(uint256 => WaveInfo) internal waveInfos;

sponsorships

mapping(address => mapping(uint96 => SponsorshipParams)) internal sponsorships;

claimableYield

mapping(address => uint256) internal claimableYield;

Functions

constructor

constructor();

initialize

function initialize(
    address owner_,
    address nounsGovernor_,
    uint256 minSponsorshipAmount_,
    uint256 waveLength_,
    string memory uri_
) external virtual initializer;

createIdea

To combat spam and low-quality proposals, idea token creation requires a small minimum payment The Ether amount paid to create the idea will be reflected in the creator's ERC1155 balance in a 1:1 ratio

Creates a new ERC1155 token referred to by its token ID, ie its ideaId identifier

function createIdea(NounsDAOProposals.ProposalTxs calldata ideaTxs, string calldata description)
    public
    payable
    returns (uint96 newIdeaId);

sponsorIdea

To incentivize smooth protocol transitions and continued rollover of auction waves, sponsorship attempts are reverted if the wave period has passed and finalizeWave() has not been executed

Sponsors the existing ERC1155 tokenized idea specified by its ID. The Ether amount paid to create the idea will be reflected in the creator's ERC1155 balance in a 1:1 ratio

function sponsorIdea(uint96 ideaId) public payable;

sponsorIdeaWithReason

To incentivize smooth protocol transitions and continued rollover of auction waves, sponsorship attempts are reverted if the wave period has passed and finalizeWave() has not been executed

Idential execution to sponsorIdea() emitting a separate event with additional description string

function sponsorIdeaWithReason(uint96 ideaId, string calldata reason) public payable;

finalizeWave

To save gas on description string SSTOREs, descriptions are stored offchain and their winning IDs must be re-validated in memory

Finalizes a Wave wave, marking the end of an auction wave. Winning ideas are selected by the highest sponsored balances and officially proposed to the Nouns governance contracts. The number of winners varies depending on the available 'liquidity' of lent Nouns NFTs and their proposal power. Yield distributions are tallied by calling the Wave Core and recording valid delegations in the claimableYield mapping where they can then be claimed at any time by a Nouns holder who has delegated to Wave

function finalizeWave(uint96[] calldata offchainWinningIds, string[] calldata offchainDescriptions)
    external
    returns (IWave.Delegation[] memory delegations, uint256[] memory nounsProposalIds);

claim

Reentrance prevented via CEI

Provides a way to collect the yield earned by Nounders who have delegated to Wave for a full wave

function claim() external returns (uint256 claimAmt);

setMinSponsorshipAmount

Only callable by the owner

Sets the new minimum funding required to create and sponsor tokenized ideas

function setMinSponsorshipAmount(uint256 newMinSponsorshipAmount) external onlyOwner;

setWaveLength

Only callable by the owner

Sets the new length of Wave waves in blocks

function setWaveLength(uint256 newWavelength) external onlyOwner;

getWinningIdeaIds

Intended for offchain usage to aid in fetching offchain description string data before calling finalizeWave() If a full list of eligible IdeaIds ordered by current funding is desired, use getOrderedEligibleIdeaIds(0) instead

Returns an array of the current wave's leading IdeaIds where the array length is determined by the protocol's number of available proposer delegates, fetched from the WaveCore contract

function getWinningIdeaIds()
    public
    view
    returns (uint256 minRequiredVotes, uint256 numEligibleProposers, uint96[] memory winningIds);

getOrderedEligibleIdeaIds

The returned array treats ineligible IDs (ie already proposed) as 0 values at the array end. Since 0 is an invalid ideaId, these are filtered out when invoked by finalizeWave() and getWinningIdeaIds()

Fetches an array of ideaIds eligible for proposal, ordered by total funding

function getOrderedEligibleIdeaIds(uint256 optLimiter) public view returns (uint96[] memory orderedEligibleIds);

Parameters

NameTypeDescription
optLimiteruint256An optional limiter used to define the number of desired ideaIds, for example the number of eligible proposers or winning ids. If provided, it will be used to define the length of the returned array

getOrderedProposedIdeaIds

Intended for external use for improved devX

Returns IDs of ideas which have already won waves and been proposed to Nouns governance

function getOrderedProposedIdeaIds() public view returns (uint96[] memory orderedProposedIds);

getIdeaInfo

Returns the IdeaInfo struct associated with a given ideaId

function getIdeaInfo(uint256 ideaId) external view returns (IdeaInfo memory);

getParentWaveId

Returns the waveId representing the parent Wave during which the given ideaId was created

function getParentWaveId(uint256 ideaId) external view returns (uint256 waveId);

getSponsorshipInfo

Returns the SponsorshipParams struct associated with a given sponsor address and ideaId

function getSponsorshipInfo(address sponsor, uint256 ideaId) public view returns (SponsorshipParams memory);

getClaimableYield

Returns the funds available to claim for a Nounder who has delegated to Wave

function getClaimableYield(address nounder) external view returns (uint256);

getOptimisticYieldEstimate

Returned estimate is based on optimistic state and is subject to change until Wave finalization

Returns an estimate of expected yield for the given Nounder LP who has delegated voting power to Wave

function getOptimisticYieldEstimate(address nounder) external view returns (uint256 yieldEstimate);

getWaveInfo

Returns information pertaining to the given Wave ID as a WaveInfo struct

function getWaveInfo(uint256 waveId) public view returns (WaveInfo memory);

getCurrentWaveInfo

Returns information pertaining to the current Wave as a WaveInfo struct

function getCurrentWaveInfo() external view returns (uint256 currentWaveId, WaveInfo memory currentWaveInfo);

getNextIdeaId

Returns the next ideaId which makes use of the tokenId mechanic from the ERC1155 standard

function getNextIdeaId() public view returns (uint256);

_validateIdeaCreation

function _validateIdeaCreation(NounsDAOProposals.ProposalTxs calldata _ideaTxs, string calldata _description)
    internal;

_sponsorIdea

function _sponsorIdea(uint96 _ideaId) internal;

_updateWaveState

function _updateWaveState() internal returns (uint256 previousWaveId);

_processWinningIdeas

function _processWinningIdeas(
    uint96[] calldata _offchainWinningIds,
    string[] calldata _offchainDescriptions,
    uint96[] memory _winningIds
)
    internal
    returns (
        uint256 winningProposalsTotalFunding,
        IWave.Proposal[] memory winningProposals,
        ProposalInfo[] memory proposedIdeas
    );

_beforeTokenTransfer

function _beforeTokenTransfer(
    address operator,
    address from,
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) internal virtual override;

_authorizeUpgrade

function _authorizeUpgrade(address) internal virtual override;