Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Juicebox Controller V2
copy icon
Juicebox
• version 1.0.0
Controller
Funding
Audited

Juicebox Controller V2

Audited

Stitches together funding cycles and project tokens, making sure all activity is accounted for and correct.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

Juicebox

Last Publish

11/23/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
distributionLimitOf(uint256,uint256,address) :
This function retrieves the distribution limit for a given project, configuration, payment terminal, and token. It does this by accessing the _packedDistributionLimitDataOf mapping, which stores the distribution limit data in a packed format. The function then unpacks the data and returns the limit as two separate values. (autogenerated documentation)
overflowAllowanceOf(uint256,uint256,address) :
This function retrieves the overflow allowance data for a given project, configuration, payment terminal, and token. It does this by accessing the _packedOverflowAllowanceDataOf mapping, which stores the data in a packed format. The function then unpacks the data and returns it as two separate uint256 values. (autogenerated documentation)
reservedTokenBalanceOf(uint256,uint256) :
This function returns the amount of reserved tokens for a given project ID and reserved rate. It does this by first retrieving the processed token tracker for the given project ID from the _processedTokenTrackerOf mapping, then calculating the reserved token amount using the _reservedTokenAmountFrom function, passing in the processed token tracker, the reserved rate, and the total supply of tokens for the given project ID from the tokenStore. Finally, the reserved token amount is returned. (autogenerated documentation)
totalOutstandingTokensOf(uint256,uint256) :
This function calculates the total amount of outstanding tokens for a given project ID and reserved rate. It does this by first calculating the total supply of tokens for the project ID, then calculating the reserved token amount from the processed token tracker of the project ID, the reserved rate, and the total supply. Finally, it returns the total supply plus the reserved token amount. (autogenerated documentation)
getFundingCycleOf(uint256,uint256) :
This function retrieves the funding cycle of a given project and configuration. It takes two parameters, a project ID and a configuration, and returns a JBFundingCycle memory fundingCycle and a JBFundingCycleMetadata memory metadata. The fundingCycleStore is used to retrieve the funding cycle, and the expandMetadata() function is used to retrieve the associated metadata. (autogenerated documentation)
latestConfiguredFundingCycleOf(uint256) :
This function retrieves the latest configured funding cycle of a given project ID. It does this by calling the latestConfiguredOf() function from the fundingCycleStore contract, which returns the fundingCycle and ballotState associated with the project ID. The function then expands the fundingCycle to retrieve the associated metadata. (autogenerated documentation)
currentFundingCycleOf(uint256) :
This function retrieves the current funding cycle of a given project ID from the fundingCycleStore. It returns a JBFundingCycle memory object and a JBFundingCycleMetadata memory object. The JBFundingCycle object contains the project ID, the current funding cycle ID, and the current funding cycle state. The JBFundingCycleMetadata object contains additional information about the funding cycle, such as the start and end dates, the total amount of funds raised, and the total number of contributors. (autogenerated documentation)
queuedFundingCycleOf(uint256) :
This function retrieves the queued funding cycle of a given project ID from the funding cycle store. It returns both the funding cycle and its associated metadata. The funding cycle is a struct containing information about the project's funding cycle, such as the amount of funds requested, the amount of funds raised, and the deadline for the funding cycle. The metadata contains additional information about the funding cycle, such as the project's title, description, and the address of the project's creator. (autogenerated documentation)
supportsInterface(bytes4) :
This function is used to check if a contract supports a given interface. It does this by comparing the given interface ID to the interface IDs of the interfaces that the contract supports. If the given interface ID matches any of the supported interface IDs, the function returns true, otherwise it returns false. The function also calls the super.supportsInterface() function to check if the contract supports any other interfaces. (autogenerated documentation)
launchProjectFor(address,uint256,string) :
This function is used to launch a new project on the JB platform. It takes in a variety of parameters, including the project owner's address, project metadata, funding cycle data, funding cycle metadata, a start time, grouped splits, fund access constraints, payment terminals, and a memo. It then creates a new project for the owner, sets the controller of the project to the address of this contract, configures the project with the given parameters, and sets the payment terminals of the project if any are provided. Finally, it emits an event to signal that the project has been launched. (autogenerated documentation)
launchFundingCyclesFor(uint256,uint256,string) :
This function launches a new funding cycle for a given project. It requires the project ID, funding cycle data, metadata, a start time, grouped splits, fund access constraints, payment terminals, and a memo. It sets the controller of the project to the address of the contract, configures the funding cycle, and sets the payment terminals of the project. Finally, it emits an event to indicate that the funding cycle has been launched. (autogenerated documentation)
reconfigureFundingCyclesOf(uint256,uint256,string) :
This function allows the owner of a project to reconfigure the funding cycles associated with that project. It takes in a project ID, funding cycle data, metadata, a start time, grouped splits, fund access constraints, and a memo as parameters. It then calls the _configure function to reconfigure the funding cycles, and emits a ReconfigureFundingCycles event. (autogenerated documentation)
issueTokenFor(uint256,string,string) :
This function issues a token for a given project ID. It requires the owner of the project to have permission to issue the token, and then calls the tokenStore.issueFor() function to create the token. The token is created with the given name and symbol, and the function returns the newly created token. (autogenerated documentation)
changeTokenOf(uint256,address) :
This function allows the owner of a project to change the token associated with the project. It requires the owner to have the permission to change the token, and checks that the change token is allowed in the current funding cycle. If these conditions are met, the token is changed in the token store for the project. (autogenerated documentation)
mintTokensOf(uint256,uint256,address,string,bool,bool) :
This function is used to mint tokens for a given project. It takes in the project ID, the number of tokens to mint, the beneficiary address, a memo, a boolean to indicate whether to prefer claimed tokens, and a boolean to indicate whether to use the reserved rate. It then checks if the token count is 0, and if not, it checks the permission of the sender to mint tokens. It then checks if minting is allowed and if not, it reverts. It then calculates the reserved rate and if it is equal to the maximum reserved rate, it subtracts the token count from the processed token tracker. Otherwise, it calculates the beneficiary token count, adds it to the processed token tracker if the reserved rate is 0, (autogenerated documentation)
burnTokensOf(address,uint256,uint256,string,bool) :
This function allows a user to burn tokens from a specific project. It requires permission from the holder of the tokens, the project ID, and a valid payment terminal delegate. The function checks to make sure that the burn is not paused and that the token count is not zero. It then subtracts the token count from the processed token tracker and burns the tokens from the token store. Finally, it emits an event to log the burn. (autogenerated documentation)
distributeReservedTokensOf(uint256,string) :
This function distributes reserved tokens of a given project ID. It takes in a project ID and a memo as parameters and calls the _distributeReservedTokensOf() internal function to distribute the reserved tokens. This function is an override of the virtual function in the parent contract. (autogenerated documentation)
prepForMigrationOf(uint256,address) :
This function is used to prepare a project for migration. It checks that the current controller of the project is not the same as the address calling the function, and then sets the processed token tracker of the project to the total supply of the project. Finally, it emits an event to signal that the project is ready for migration. (autogenerated documentation)
migrate(uint256) :
This function allows the owner of a project to migrate the controller of the project to a new IJBMigratable contract. It first checks that the current controller is the one calling the function, and that controller migration is allowed. It then calls the prepForMigrationOf() function on the new contract, and sets the controller of the project to the new contract. Finally, it emits a Migrate event. (autogenerated documentation)
_distributeReservedTokensOf(uint256,string) :
This function distributes reserved tokens of a given project. It first retrieves the current funding cycle of the project from the fundingCycleStore. It then calculates the total token supply of the project from the tokenStore. It then calculates the token count to be distributed from the processedTokenTrackerOf and the reservedRate of the fundingCycle. It then distributes the tokens to the reserved token splits of the project, and if there are any leftover tokens, it mints them for the owner of the project. Finally, it emits an event to log the distribution of the reserved tokens. (autogenerated documentation)
_distributeToReservedTokenSplitsOf(uint256,uint256,uint256,uint256) :
This function distributes tokens to reserved token splits of a given project, domain, and group. It takes in the project ID, domain, group, and amount of tokens to distribute as parameters. It then iterates through the splits associated with the given project, domain, and group, and calculates the token count for each split based on the percentage of the split and the total amount of tokens to distribute. It then mints the tokens for the split's allocator, beneficiary, or sender, depending on the split's configuration. Finally, it emits an event to track the distribution of tokens to the split. (autogenerated documentation)
_configure(uint256,uint256) :
This function is used to configure a new funding cycle for a given project. It takes in a project ID, data, metadata, a start time, grouped splits, and fund access constraints as parameters. It then checks that the reserved rate, redemption rate, and ballot redemption rate are all within the allowed limits. It then stores the funding cycle data in the funding cycle store and sets the splits in the splits store. Finally, it sets the fund access constraints for the project and emits an event to notify of the change. (autogenerated documentation)
_reservedTokenAmountFrom(int256,uint256,uint256) :
This function calculates the amount of tokens that should be reserved from a given total eligible token balance, based on the processed token tracker and the reserved rate. It first calculates the unprocessed token balance by subtracting the processed token tracker from the total eligible token balance, or adding the negative of the processed token tracker if it is negative. If the unprocessed token balance is 0, the reserved token amount is also 0. Otherwise, if the reserved rate is equal to the maximum reserved rate, the reserved token amount is equal to the unprocessed token balance. Otherwise, the reserved token amount is calculated by multiplying the unprocessed token balance by the maximum reserved rate, and then dividing by the difference between the maximum reserved rate and the (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i JBController
copy icon

Last Publish

11/23/2022

Version

1.0.0

Creator

Juicebox

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.