|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +pragma solidity >=0.6.12 <0.8.0; |
| 4 | +pragma experimental ABIEncoderV2; |
| 5 | + |
| 6 | +import "./IStakingData.sol"; |
| 7 | + |
| 8 | +interface IStakingV1 is IStakingData { |
| 9 | + // -- Allocation Data -- |
| 10 | + |
| 11 | + /** |
| 12 | + * @dev Possible states an allocation can be |
| 13 | + * States: |
| 14 | + * - Null = indexer == address(0) |
| 15 | + * - Active = not Null && tokens > 0 |
| 16 | + * - Closed = Active && closedAtEpoch != 0 |
| 17 | + * - Finalized = Closed && closedAtEpoch + channelDisputeEpochs > now() |
| 18 | + * - Claimed = not Null && tokens == 0 |
| 19 | + */ |
| 20 | + enum AllocationState { Null, Active, Closed, Finalized, Claimed } |
| 21 | + |
| 22 | + /** |
| 23 | + * @dev Represents a request to close an allocation with a specific proof of indexing. |
| 24 | + * This is passed when calling closeAllocationMany to define the closing parameters for |
| 25 | + * each allocation. |
| 26 | + */ |
| 27 | + struct CloseAllocationRequest { |
| 28 | + address allocationID; |
| 29 | + bytes32 poi; |
| 30 | + } |
| 31 | + |
| 32 | + // -- Configuration -- |
| 33 | + |
| 34 | + function setMinimumIndexerStake(uint256 _minimumIndexerStake) external; |
| 35 | + |
| 36 | + function setThawingPeriod(uint32 _thawingPeriod) external; |
| 37 | + |
| 38 | + function setCurationPercentage(uint32 _percentage) external; |
| 39 | + |
| 40 | + function setProtocolPercentage(uint32 _percentage) external; |
| 41 | + |
| 42 | + function setChannelDisputeEpochs(uint32 _channelDisputeEpochs) external; |
| 43 | + |
| 44 | + function setMaxAllocationEpochs(uint32 _maxAllocationEpochs) external; |
| 45 | + |
| 46 | + function setRebateRatio(uint32 _alphaNumerator, uint32 _alphaDenominator) external; |
| 47 | + |
| 48 | + function setDelegationRatio(uint32 _delegationRatio) external; |
| 49 | + |
| 50 | + function setDelegationParameters( |
| 51 | + uint32 _indexingRewardCut, |
| 52 | + uint32 _queryFeeCut, |
| 53 | + uint32 _cooldownBlocks |
| 54 | + ) external; |
| 55 | + |
| 56 | + function setDelegationParametersCooldown(uint32 _blocks) external; |
| 57 | + |
| 58 | + function setDelegationUnbondingPeriod(uint32 _delegationUnbondingPeriod) external; |
| 59 | + |
| 60 | + function setDelegationTaxPercentage(uint32 _percentage) external; |
| 61 | + |
| 62 | + function setSlasher(address _slasher, bool _allowed) external; |
| 63 | + |
| 64 | + function setAssetHolder(address _assetHolder, bool _allowed) external; |
| 65 | + |
| 66 | + // -- Operation -- |
| 67 | + |
| 68 | + function setOperator(address _operator, bool _allowed) external; |
| 69 | + |
| 70 | + function isOperator(address _operator, address _indexer) external view returns (bool); |
| 71 | + |
| 72 | + // -- Staking -- |
| 73 | + |
| 74 | + function stake(uint256 _tokens) external; |
| 75 | + |
| 76 | + function stakeTo(address _indexer, uint256 _tokens) external; |
| 77 | + |
| 78 | + function unstake(uint256 _tokens) external; |
| 79 | + |
| 80 | + function slash( |
| 81 | + address _indexer, |
| 82 | + uint256 _tokens, |
| 83 | + uint256 _reward, |
| 84 | + address _beneficiary |
| 85 | + ) external; |
| 86 | + |
| 87 | + function withdraw() external; |
| 88 | + |
| 89 | + // -- Delegation -- |
| 90 | + |
| 91 | + function delegate(address _indexer, uint256 _tokens) external returns (uint256); |
| 92 | + |
| 93 | + function undelegate(address _indexer, uint256 _shares) external returns (uint256); |
| 94 | + |
| 95 | + function withdrawDelegated(address _indexer, address _newIndexer) external returns (uint256); |
| 96 | + |
| 97 | + // -- Channel management and allocations -- |
| 98 | + |
| 99 | + function allocate( |
| 100 | + bytes32 _subgraphDeploymentID, |
| 101 | + uint256 _tokens, |
| 102 | + address _allocationID, |
| 103 | + bytes32 _metadata, |
| 104 | + bytes calldata _proof |
| 105 | + ) external; |
| 106 | + |
| 107 | + function allocateFrom( |
| 108 | + address _indexer, |
| 109 | + bytes32 _subgraphDeploymentID, |
| 110 | + uint256 _tokens, |
| 111 | + address _allocationID, |
| 112 | + bytes32 _metadata, |
| 113 | + bytes calldata _proof |
| 114 | + ) external; |
| 115 | + |
| 116 | + function closeAllocation(address _allocationID, bytes32 _poi) external; |
| 117 | + |
| 118 | + function closeAllocationMany(CloseAllocationRequest[] calldata _requests) external; |
| 119 | + |
| 120 | + function closeAndAllocate( |
| 121 | + address _oldAllocationID, |
| 122 | + bytes32 _poi, |
| 123 | + address _indexer, |
| 124 | + bytes32 _subgraphDeploymentID, |
| 125 | + uint256 _tokens, |
| 126 | + address _allocationID, |
| 127 | + bytes32 _metadata, |
| 128 | + bytes calldata _proof |
| 129 | + ) external; |
| 130 | + |
| 131 | + function collect(uint256 _tokens, address _allocationID) external; |
| 132 | + |
| 133 | + function claim(address _allocationID, bool _restake) external; |
| 134 | + |
| 135 | + function claimMany(address[] calldata _allocationID, bool _restake) external; |
| 136 | + |
| 137 | + // -- Getters and calculations -- |
| 138 | + |
| 139 | + function hasStake(address _indexer) external view returns (bool); |
| 140 | + |
| 141 | + function getIndexerStakedTokens(address _indexer) external view returns (uint256); |
| 142 | + |
| 143 | + function getIndexerCapacity(address _indexer) external view returns (uint256); |
| 144 | + |
| 145 | + function getAllocation(address _allocationID) external view returns (Allocation memory); |
| 146 | + |
| 147 | + function getAllocationState(address _allocationID) external view returns (AllocationState); |
| 148 | + |
| 149 | + function isAllocation(address _allocationID) external view returns (bool); |
| 150 | + |
| 151 | + function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) |
| 152 | + external |
| 153 | + view |
| 154 | + returns (uint256); |
| 155 | + |
| 156 | + function getDelegation(address _indexer, address _delegator) |
| 157 | + external |
| 158 | + view |
| 159 | + returns (Delegation memory); |
| 160 | + |
| 161 | + function isDelegator(address _indexer, address _delegator) external view returns (bool); |
| 162 | +} |
0 commit comments