|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | + |
| 3 | +pragma solidity ^0.7.6 || ^0.8.0; |
| 4 | +pragma abicoder v2; |
| 5 | + |
| 6 | +/** |
| 7 | + * @notice Target issuance per block information |
| 8 | + * @param allocatorIssuancePerBlock Issuance per block for allocator-minting (non-self-minting) |
| 9 | + * @param allocatorIssuanceBlockAppliedTo The block up to which allocator issuance has been applied |
| 10 | + * @param selfIssuancePerBlock Issuance per block for self-minting |
| 11 | + * @param selfIssuanceBlockAppliedTo The block up to which self issuance has been applied |
| 12 | + */ |
| 13 | +struct TargetIssuancePerBlock { |
| 14 | + uint256 allocatorIssuancePerBlock; |
| 15 | + uint256 allocatorIssuanceBlockAppliedTo; |
| 16 | + uint256 selfIssuancePerBlock; |
| 17 | + uint256 selfIssuanceBlockAppliedTo; |
| 18 | +} |
| 19 | + |
| 20 | +/** |
| 21 | + * @notice Allocation information |
| 22 | + * @param totalAllocationPPM Total allocation in PPM (allocatorMintingAllocationPPM + selfMintingAllocationPPM) |
| 23 | + * @param allocatorMintingPPM Allocator-minting allocation in PPM (Parts Per Million) |
| 24 | + * @param selfMintingPPM Self-minting allocation in PPM (Parts Per Million) |
| 25 | + */ |
| 26 | +struct Allocation { |
| 27 | + uint256 totalAllocationPPM; |
| 28 | + uint256 allocatorMintingPPM; |
| 29 | + uint256 selfMintingPPM; |
| 30 | +} |
| 31 | + |
| 32 | +/** |
| 33 | + * @notice Allocation target information |
| 34 | + * @param allocatorMintingPPM The allocator-minting allocation amount in PPM (Parts Per Million) |
| 35 | + * @param selfMintingPPM The self-minting allocation amount in PPM (Parts Per Million) |
| 36 | + * @param lastChangeNotifiedBlock Last block when this target was notified of changes |
| 37 | + */ |
| 38 | +struct AllocationTarget { |
| 39 | + uint256 allocatorMintingPPM; |
| 40 | + uint256 selfMintingPPM; |
| 41 | + uint256 lastChangeNotifiedBlock; |
| 42 | +} |
| 43 | + |
| 44 | +/** |
| 45 | + * @title IIssuanceAllocator |
| 46 | + * @author Edge & Node |
| 47 | + * @notice Interface for the IssuanceAllocator contract, which is responsible for |
| 48 | + * allocating token issuance to different components of the protocol. |
| 49 | + * |
| 50 | + * @dev The allocation model distinguishes between two types of targets: |
| 51 | + * 1. Self-minting contracts: These can mint tokens themselves and are supported |
| 52 | + * primarily for backwards compatibility with existing contracts. |
| 53 | + * 2. Non-self-minting contracts: These cannot mint tokens themselves and rely on |
| 54 | + * their issuanceallocator to mint tokens for them. |
| 55 | + */ |
| 56 | +interface IIssuanceAllocator { |
| 57 | + /** |
| 58 | + * @notice Distribute issuance to allocated non-self-minting targets. |
| 59 | + * @return Block number that issuance has beee distributed to. That will normally be the current block number, unless the contract is paused. |
| 60 | + * |
| 61 | + * @dev When the contract is paused, no issuance is distributed and lastIssuanceBlock is not updated. |
| 62 | + */ |
| 63 | + function distributeIssuance() external returns (uint256); |
| 64 | + |
| 65 | + /** |
| 66 | + * @notice Set the issuance per block. |
| 67 | + * @param newIssuancePerBlock New issuance per block |
| 68 | + * @param evenIfDistributionPending If true, set even if there is pending issuance distribution |
| 69 | + * @return True if the value is applied (including if already the case), false if not applied due to paused state |
| 70 | + */ |
| 71 | + function setIssuancePerBlock(uint256 newIssuancePerBlock, bool evenIfDistributionPending) external returns (bool); |
| 72 | + |
| 73 | + /** |
| 74 | + * @notice Set the allocation for a target with only allocator minting |
| 75 | + * @param target Address of the target to update |
| 76 | + * @param allocatorMintingPPM Allocator-minting allocation for the target (in PPM) |
| 77 | + * @return True if the value is applied (including if already the case), false if not applied |
| 78 | + * @dev This variant sets selfMintingPPM to 0 and evenIfDistributionPending to false |
| 79 | + */ |
| 80 | + function setTargetAllocation(address target, uint256 allocatorMintingPPM) external returns (bool); |
| 81 | + |
| 82 | + /** |
| 83 | + * @notice Set the allocation for a target with both allocator and self minting |
| 84 | + * @param target Address of the target to update |
| 85 | + * @param allocatorMintingPPM Allocator-minting allocation for the target (in PPM) |
| 86 | + * @param selfMintingPPM Self-minting allocation for the target (in PPM) |
| 87 | + * @return True if the value is applied (including if already the case), false if not applied |
| 88 | + * @dev This variant sets evenIfDistributionPending to false |
| 89 | + */ |
| 90 | + function setTargetAllocation( |
| 91 | + address target, |
| 92 | + uint256 allocatorMintingPPM, |
| 93 | + uint256 selfMintingPPM |
| 94 | + ) external returns (bool); |
| 95 | + |
| 96 | + /** |
| 97 | + * @notice Set the allocation for a target |
| 98 | + * @param target Address of the target to update |
| 99 | + * @param allocatorMintingPPM Allocator-minting allocation for the target (in PPM) |
| 100 | + * @param selfMintingPPM Self-minting allocation for the target (in PPM) |
| 101 | + * @param evenIfDistributionPending Whether to force the allocation change even if issuance has not been distributed up to the current block |
| 102 | + * @return True if the value is applied (including if already the case), false if not applied |
| 103 | + */ |
| 104 | + function setTargetAllocation( |
| 105 | + address target, |
| 106 | + uint256 allocatorMintingPPM, |
| 107 | + uint256 selfMintingPPM, |
| 108 | + bool evenIfDistributionPending |
| 109 | + ) external returns (bool); |
| 110 | + |
| 111 | + /** |
| 112 | + * @notice Notify a specific target about an upcoming allocation change |
| 113 | + * @param target Address of the target to notify |
| 114 | + * @return True if notification was sent or already sent this block, false otherwise |
| 115 | + */ |
| 116 | + function notifyTarget(address target) external returns (bool); |
| 117 | + |
| 118 | + /** |
| 119 | + * @notice Force set the lastChangeNotifiedBlock for a target to a specific block number |
| 120 | + * @param target Address of the target to update |
| 121 | + * @param blockNumber Block number to set as the lastChangeNotifiedBlock |
| 122 | + * @return The block number that was set |
| 123 | + * @dev This can be used to enable notification to be sent again (by setting to a past block) |
| 124 | + * @dev or to prevent notification until a future block (by setting to current or future block). |
| 125 | + */ |
| 126 | + function forceTargetNoChangeNotificationBlock(address target, uint256 blockNumber) external returns (uint256); |
| 127 | + |
| 128 | + /** |
| 129 | + * @notice Distribute any pending accumulated issuance to allocator-minting targets. |
| 130 | + * @return Block number up to which issuance has been distributed |
| 131 | + * @dev This function can be called even when the contract is paused. |
| 132 | + * @dev If there is no pending issuance, this function is a no-op. |
| 133 | + * @dev If allocatorMintingAllowance is 0 (all targets are self-minting), this function is a no-op. |
| 134 | + */ |
| 135 | + function distributePendingIssuance() external returns (uint256); |
| 136 | + |
| 137 | + /** |
| 138 | + * @notice Distribute any pending accumulated issuance to allocator-minting targets, accumulating up to a specific block. |
| 139 | + * @param toBlockNumber The block number to accumulate pending issuance up to (must be >= lastIssuanceAccumulationBlock and <= current block) |
| 140 | + * @return Block number up to which issuance has been distributed |
| 141 | + * @dev This function can be called even when the contract is paused. |
| 142 | + * @dev Accumulates pending issuance up to the specified block, then distributes all accumulated issuance. |
| 143 | + * @dev If there is no pending issuance after accumulation, this function is a no-op for distribution. |
| 144 | + * @dev If allocatorMintingAllowance is 0 (all targets are self-minting), this function is a no-op for distribution. |
| 145 | + */ |
| 146 | + function distributePendingIssuance(uint256 toBlockNumber) external returns (uint256); |
| 147 | + |
| 148 | + /** |
| 149 | + * @notice Get the current allocation for a target |
| 150 | + * @param target Address of the target |
| 151 | + * @return Allocation struct containing total, allocator-minting, and self-minting allocations |
| 152 | + */ |
| 153 | + function getTargetAllocation(address target) external view returns (Allocation memory); |
| 154 | + |
| 155 | + /** |
| 156 | + * @notice Get the current global allocation totals |
| 157 | + * @return Allocation struct containing total, allocator-minting, and self-minting allocations across all targets |
| 158 | + */ |
| 159 | + function getTotalAllocation() external view returns (Allocation memory); |
| 160 | + |
| 161 | + /** |
| 162 | + * @notice Get all allocated target addresses |
| 163 | + * @return Array of target addresses |
| 164 | + */ |
| 165 | + function getTargets() external view returns (address[] memory); |
| 166 | + |
| 167 | + /** |
| 168 | + * @notice Get a specific allocated target address by index |
| 169 | + * @param index The index of the target address to retrieve |
| 170 | + * @return The target address at the specified index |
| 171 | + */ |
| 172 | + function getTargetAt(uint256 index) external view returns (address); |
| 173 | + |
| 174 | + /** |
| 175 | + * @notice Get the number of allocated targets |
| 176 | + * @return The total number of allocated targets |
| 177 | + */ |
| 178 | + function getTargetCount() external view returns (uint256); |
| 179 | + |
| 180 | + /** |
| 181 | + * @notice Target issuance per block information |
| 182 | + * @param target Address of the target |
| 183 | + * @return TargetIssuancePerBlock struct containing allocatorIssuanceBlockAppliedTo, selfIssuanceBlockAppliedTo, allocatorIssuancePerBlock, and selfIssuancePerBlock |
| 184 | + * @dev This function does not revert when paused, instead the caller is expected to correctly read and apply the information provided. |
| 185 | + * @dev Targets should check allocatorIssuanceBlockAppliedTo and selfIssuanceBlockAppliedTo - if either is not the current block, that type of issuance is paused for that target. |
| 186 | + * @dev Targets should not check the allocator's pause state directly, but rely on the blockAppliedTo fields to determine if issuance is paused. |
| 187 | + */ |
| 188 | + function getTargetIssuancePerBlock(address target) external view returns (TargetIssuancePerBlock memory); |
| 189 | + |
| 190 | + /** |
| 191 | + * @notice Get the current issuance per block |
| 192 | + * @return The current issuance per block |
| 193 | + */ |
| 194 | + function issuancePerBlock() external view returns (uint256); |
| 195 | + |
| 196 | + /** |
| 197 | + * @notice Get the last block number where issuance was distributed |
| 198 | + * @return The last block number where issuance was distributed |
| 199 | + */ |
| 200 | + function lastIssuanceDistributionBlock() external view returns (uint256); |
| 201 | + |
| 202 | + /** |
| 203 | + * @notice Get the last block number where issuance was accumulated during pause |
| 204 | + * @return The last block number where issuance was accumulated during pause |
| 205 | + */ |
| 206 | + function lastIssuanceAccumulationBlock() external view returns (uint256); |
| 207 | + |
| 208 | + /** |
| 209 | + * @notice Get the amount of pending accumulated allocator issuance |
| 210 | + * @return The amount of pending accumulated allocator issuance |
| 211 | + */ |
| 212 | + function pendingAccumulatedAllocatorIssuance() external view returns (uint256); |
| 213 | +} |
0 commit comments