@@ -859,6 +859,24 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking, Multicall {
859
859
return _withdrawDelegated (msg .sender , _indexer, _delegateToIndexer);
860
860
}
861
861
862
+ /**
863
+ * @dev Allocate available tokens to a subgraph deployment.
864
+ * @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
865
+ * @param _tokens Amount of tokens to allocate
866
+ * @param _allocationID The allocation identifier
867
+ * @param _metadata IPFS hash for additional information about the allocation
868
+ * @param _proof A 65-bytes Ethereum signed message of `keccak256(indexerAddress,allocationID)`
869
+ */
870
+ function allocate (
871
+ bytes32 _subgraphDeploymentID ,
872
+ uint256 _tokens ,
873
+ address _allocationID ,
874
+ bytes32 _metadata ,
875
+ bytes calldata _proof
876
+ ) external override notPaused {
877
+ _allocate (msg .sender , _subgraphDeploymentID, _tokens, _allocationID, _metadata, _proof);
878
+ }
879
+
862
880
/**
863
881
* @dev Allocate available tokens to a subgraph deployment.
864
882
* @param _indexer Indexer address to allocate funds from.
@@ -891,6 +909,49 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking, Multicall {
891
909
_closeAllocation (_allocationID, _poi);
892
910
}
893
911
912
+ /**
913
+ * @dev Close multiple allocations and free the staked tokens.
914
+ * To be eligible for rewards a proof of indexing must be presented.
915
+ * Presenting a bad proof is subject to slashable condition.
916
+ * To opt out for rewards set _poi to 0x0
917
+ * @param _requests An array of CloseAllocationRequest
918
+ */
919
+ function closeAllocationMany (CloseAllocationRequest[] calldata _requests )
920
+ external
921
+ override
922
+ notPaused
923
+ {
924
+ for (uint256 i = 0 ; i < _requests.length ; i++ ) {
925
+ _closeAllocation (_requests[i].allocationID, _requests[i].poi);
926
+ }
927
+ }
928
+
929
+ /**
930
+ * @dev Close and allocate. This will perform a close and then create a new Allocation
931
+ * atomically on the same transaction.
932
+ * @param _closingAllocationID The identifier of the allocation to be closed
933
+ * @param _poi Proof of indexing submitted for the allocated period
934
+ * @param _indexer Indexer address to allocate funds from.
935
+ * @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
936
+ * @param _tokens Amount of tokens to allocate
937
+ * @param _allocationID The allocation identifier
938
+ * @param _metadata IPFS hash for additional information about the allocation
939
+ * @param _proof A 65-bytes Ethereum signed message of `keccak256(indexerAddress,allocationID)`
940
+ */
941
+ function closeAndAllocate (
942
+ address _closingAllocationID ,
943
+ bytes32 _poi ,
944
+ address _indexer ,
945
+ bytes32 _subgraphDeploymentID ,
946
+ uint256 _tokens ,
947
+ address _allocationID ,
948
+ bytes32 _metadata ,
949
+ bytes calldata _proof
950
+ ) external override notPaused {
951
+ _closeAllocation (_closingAllocationID, _poi);
952
+ _allocate (_indexer, _subgraphDeploymentID, _tokens, _allocationID, _metadata, _proof);
953
+ }
954
+
894
955
/**
895
956
* @dev Collect query fees from state channels and assign them to an allocation.
896
957
* Funds received are only accepted from a valid sender.
@@ -976,6 +1037,21 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking, Multicall {
976
1037
_claim (_allocationID, _restake);
977
1038
}
978
1039
1040
+ /**
1041
+ * @dev Claim tokens from the rebate pool for many allocations.
1042
+ * @param _allocationID Array of allocations from where we are claiming tokens
1043
+ * @param _restake True if restake fees instead of transfer to indexer
1044
+ */
1045
+ function claimMany (address [] calldata _allocationID , bool _restake )
1046
+ external
1047
+ override
1048
+ notPaused
1049
+ {
1050
+ for (uint256 i = 0 ; i < _allocationID.length ; i++ ) {
1051
+ _claim (_allocationID[i], _restake);
1052
+ }
1053
+ }
1054
+
979
1055
/**
980
1056
* @dev Stake tokens on the indexer.
981
1057
* This function does not check minimum indexer stake requirement to allow
0 commit comments