JBController

생성일 비교 결과 만료 없음
126 삭제
617 행
148 추가
633 행
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity ^0.8.16;


import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import '@openzeppelin/contracts/utils/math/SafeCast.sol';
import '@openzeppelin/contracts/utils/math/SafeCast.sol';
import '@paulrberg/contracts/math/PRBMath.sol';
import '@paulrberg/contracts/math/PRBMath.sol';
import './abstract/JBOperatable.sol';
import './abstract/JBOperatable.sol';
import './interfaces/IJBController.sol';
import './interfaces/IJBController3_1.sol';
import './interfaces/IJBMigratable.sol';
import './interfaces/IJBMigratable.sol';
import './interfaces/IJBOperatorStore.sol';
import './interfaces/IJBOperatorStore.sol';
import './interfaces/IJBPaymentTerminal.sol';
import './interfaces/IJBPaymentTerminal.sol';
import './interfaces/IJBProjects.sol';
import './interfaces/IJBProjects.sol';
import './libraries/JBConstants.sol';
import './libraries/JBConstants.sol';
import './libraries/JBFundingCycleMetadataResolver.sol';
import './libraries/JBFundingCycleMetadataResolver.sol';
import './libraries/JBOperations.sol';
import './libraries/JBOperations.sol';
import './libraries/JBSplitsGroups.sol';
import './libraries/JBSplitsGroups.sol';


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


@dev
@dev
Adheres to -
Adheres to -
IJBController: General interface for the generic controller methods in this contract that interacts with funding cycles and tokens according to the protocol's rules.
IJBController3_1: General interface for the generic controller methods in this contract that interacts with funding cycles and tokens according to the protocol's rules.
IJBMigratable: Allows migrating to this contract, with a hook called to prepare for the migration.
IJBMigratable: Allows migrating to this contract, with a hook called to prepare for the migration.


@dev
@dev
Inherits from -
Inherits from -
JBOperatable: Several functions in this contract can only be accessed by a project owner, or an address that has been preconfifigured to be an operator of the project.
JBOperatable: Several functions in this contract can only be accessed by a project owner, or an address that has been preconfifigured to be an operator of the project.
ERC165: Introspection on interface adherance.
ERC165: Introspection on interface adherance.

@dev
This Controller has the same functionality as JBController3_1, except it is not backwards compatible with the original IJBController view methods.
*/
*/
contract JBController is JBOperatable, ERC165, IJBController, IJBMigratable {
contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratable {
// A library that parses the packed funding cycle metadata into a more friendly format.
// A library that parses the packed funding cycle metadata into a more friendly format.
using JBFundingCycleMetadataResolver for JBFundingCycle;
using JBFundingCycleMetadataResolver for JBFundingCycle;


//*********************************************************************//
//*********************************************************************//
// --------------------------- custom errors ------------------------- //
// --------------------------- custom errors ------------------------- //
//*********************************************************************//
//*********************************************************************//

error BURN_PAUSED_AND_SENDER_NOT_VALID_TERMINAL_DELEGATE();
error BURN_PAUSED_AND_SENDER_NOT_VALID_TERMINAL_DELEGATE();
error CANT_MIGRATE_TO_CURRENT_CONTROLLER();
error CANT_MIGRATE_TO_CURRENT_CONTROLLER();
error FUNDING_CYCLE_ALREADY_LAUNCHED();
error FUNDING_CYCLE_ALREADY_LAUNCHED();
error INVALID_BALLOT_REDEMPTION_RATE();
error INVALID_BALLOT_REDEMPTION_RATE();
error INVALID_DISTRIBUTION_LIMIT();
error INVALID_DISTRIBUTION_LIMIT_CURRENCY();
error INVALID_OVERFLOW_ALLOWANCE();
error INVALID_OVERFLOW_ALLOWANCE_CURRENCY();
error INVALID_REDEMPTION_RATE();
error INVALID_REDEMPTION_RATE();
error INVALID_RESERVED_RATE();
error INVALID_RESERVED_RATE();
error MIGRATION_NOT_ALLOWED();
error MIGRATION_NOT_ALLOWED();
error MINT_NOT_ALLOWED_AND_NOT_TERMINAL_DELEGATE();
error MINT_NOT_ALLOWED_AND_NOT_TERMINAL_DELEGATE();
error NO_BURNABLE_TOKENS();
error NO_BURNABLE_TOKENS();
error NOT_CURRENT_CONTROLLER();
error NOT_CURRENT_CONTROLLER();
error OVERFLOW_ALERT();
error OVERFLOW_ALERT();
error ZERO_TOKENS_TO_MINT();
error ZERO_TOKENS_TO_MINT();


//*********************************************************************//
//*********************************************************************//
// --------------------- internal stored properties ------------------ //
// --------------------- internal stored properties ------------------ //
//*********************************************************************//
//*********************************************************************//


/**
@notice
The difference between the processed token tracker of a project and the project's token's total supply is the amount of tokens that still need to have reserves minted against them.

_projectId The ID of the project to get the tracker of.
*/
mapping(uint256 => int256) internal _processedTokenTrackerOf;

/**
/**
@notice
@notice
Data regarding the distribution limit of a project during a configuration.
Data regarding the distribution limit of a project during a configuration.


@dev
@dev
bits 0-231: The amount of token that a project can distribute per funding cycle.
bits 0-231: The amount of token that a project can distribute per funding cycle.


@dev
@dev
bits 232-255: The currency of amount that a project can distribute.
bits 232-255: The currency of amount that a project can distribute.


_projectId The ID of the project to get the packed distribution limit data of.
_projectId The ID of the project to get the packed distribution limit data of.
_configuration The configuration during which the packed distribution limit data applies.
_configuration The configuration during which the packed distribution limit data applies.
_terminal The terminal from which distributions are being limited.
_terminal The terminal from which distributions are being limited.
_token The token for which distributions are being limited.
_token The token for which distributions are being limited.
*/
*/
mapping(uint256 => mapping(uint256 => mapping(IJBPaymentTerminal => mapping(address => uint256))))
mapping(uint256 => mapping(uint256 => mapping(IJBPaymentTerminal => mapping(address => uint256))))
internal _packedDistributionLimitDataOf;
internal _packedDistributionLimitDataOf;


/**
/**
@notice
@notice
Data regarding the overflow allowance of a project during a configuration.
Data regarding the overflow allowance of a project during a configuration.


@dev
@dev
bits 0-231: The amount of overflow that a project is allowed to tap into on-demand throughout the configuration.
bits 0-231: The amount of overflow that a project is allowed to tap into on-demand throughout the configuration.


@dev
@dev
bits 232-255: The currency of the amount of overflow that a project is allowed to tap.
bits 232-255: The currency of the amount of overflow that a project is allowed to tap.


_projectId The ID of the project to get the packed overflow allowance data of.
_projectId The ID of the project to get the packed overflow allowance data of.
_configuration The configuration during which the packed overflow allowance data applies.
_configuration The configuration during which the packed overflow allowance data applies.
_terminal The terminal managing the overflow.
_terminal The terminal managing the overflow.
_token The token for which overflow is being allowed.
_token The token for which overflow is being allowed.
*/
*/
mapping(uint256 => mapping(uint256 => mapping(IJBPaymentTerminal => mapping(address => uint256))))
mapping(uint256 => mapping(uint256 => mapping(IJBPaymentTerminal => mapping(address => uint256))))
internal _packedOverflowAllowanceDataOf;
internal _packedOverflowAllowanceDataOf;


//*********************************************************************//
//*********************************************************************//
// --------------- public immutable stored properties ---------------- //
// --------------- public immutable stored properties ---------------- //
//*********************************************************************//
//*********************************************************************//


/**
/**