3
3
pragma solidity 0.8.27 ;
4
4
5
5
import { IGraphPayments } from "../../interfaces/IGraphPayments.sol " ;
6
+ import { IHorizonStakingTypes } from "./IHorizonStakingTypes.sol " ;
6
7
7
8
/**
8
9
* @title Inferface for the {HorizonStaking} contract.
@@ -205,6 +206,15 @@ interface IHorizonStakingMain {
205
206
uint256 tokens
206
207
);
207
208
209
+ /**
210
+ * @notice Emitted when `delegator` withdrew delegated `tokens` from `indexer` using `withdrawDelegated`.
211
+ * @dev This event is for the legacy `withdrawDelegated` function.
212
+ * @param indexer The address of the indexer
213
+ * @param delegator The address of the delegator
214
+ * @param tokens The amount of tokens withdrawn
215
+ */
216
+ event StakeDelegatedWithdrawn (address indexed indexer , address indexed delegator , uint256 tokens );
217
+
208
218
/**
209
219
* @notice Emitted when tokens are added to a delegation pool's reserve.
210
220
* @param serviceProvider The address of the service provider
@@ -271,13 +281,15 @@ interface IHorizonStakingMain {
271
281
* @param owner The address of the owner of the thaw requests
272
282
* @param thawRequestsFulfilled The number of thaw requests fulfilled
273
283
* @param tokens The total amount of tokens being released
284
+ * @param requestType The type of thaw request
274
285
*/
275
286
event ThawRequestsFulfilled (
276
287
address indexed serviceProvider ,
277
288
address indexed verifier ,
278
289
address indexed owner ,
279
290
uint256 thawRequestsFulfilled ,
280
- uint256 tokens
291
+ uint256 tokens ,
292
+ IHorizonStakingTypes.ThawRequestType requestType
281
293
);
282
294
283
295
// -- Events: governance --
@@ -303,9 +315,8 @@ interface IHorizonStakingMain {
303
315
304
316
/**
305
317
* @notice Emitted when the delegation slashing global flag is set.
306
- * @param enabled Whether delegation slashing is enabled or disabled.
307
318
*/
308
- event DelegationSlashingEnabled (bool enabled );
319
+ event DelegationSlashingEnabled ();
309
320
310
321
// -- Errors: tokens
311
322
@@ -415,6 +426,20 @@ interface IHorizonStakingMain {
415
426
*/
416
427
error HorizonStakingInvalidDelegationPool (address serviceProvider , address verifier );
417
428
429
+ /**
430
+ * @notice Thrown when the minimum token amount required for delegation is not met.
431
+ * @param tokens The actual token amount
432
+ * @param minTokens The minimum required token amount
433
+ */
434
+ error HorizonStakingInsufficientDelegationTokens (uint256 tokens , uint256 minTokens );
435
+
436
+ /**
437
+ * @notice Thrown when the minimum token amount required for undelegation with beneficiary is not met.
438
+ * @param tokens The actual token amount
439
+ * @param minTokens The minimum required token amount
440
+ */
441
+ error HorizonStakingInsufficientUndelegationTokens (uint256 tokens , uint256 minTokens );
442
+
418
443
/**
419
444
* @notice Thrown when attempting to undelegate with a beneficiary that is the zero address.
420
445
*/
@@ -515,6 +540,8 @@ interface IHorizonStakingMain {
515
540
* - During the transition period it's locked for a period of time before it can be withdrawn
516
541
* by calling {withdraw}.
517
542
* - After the transition period it's immediately withdrawn.
543
+ * Note that after the transition period if there are tokens still locked they will have to be
544
+ * withdrawn by calling {withdraw}.
518
545
* @dev Requirements:
519
546
* - `_tokens` cannot be zero.
520
547
* - `_serviceProvider` must have enough idle stake to cover the staking amount and any
@@ -747,7 +774,7 @@ interface IHorizonStakingMain {
747
774
* @param beneficiary The address where the tokens will be withdrawn after thawing
748
775
* @return The ID of the thaw request
749
776
*/
750
- function undelegate (
777
+ function undelegateWithBeneficiary (
751
778
address serviceProvider ,
752
779
address verifier ,
753
780
uint256 shares ,
@@ -772,6 +799,28 @@ interface IHorizonStakingMain {
772
799
*/
773
800
function withdrawDelegated (address serviceProvider , address verifier , uint256 nThawRequests ) external ;
774
801
802
+ /**
803
+ * @notice Withdraw undelegated with beneficiary tokens from a provision after thawing.
804
+ * @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
805
+ * requests in the event that fulfilling all of them results in a gas limit error.
806
+ * @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill
807
+ * the thaw requests with an amount equal to zero.
808
+ *
809
+ * Requirements:
810
+ * - Must have previously initiated a thaw request using {undelegateWithBeneficiary}.
811
+ *
812
+ * Emits {ThawRequestFulfilled}, {ThawRequestsFulfilled} and {DelegatedTokensWithdrawn} events.
813
+ *
814
+ * @param serviceProvider The service provider address
815
+ * @param verifier The verifier address
816
+ * @param nThawRequests The number of thaw requests to fulfill. Set to 0 to fulfill all thaw requests.
817
+ */
818
+ function withdrawDelegatedWithBeneficiary (
819
+ address serviceProvider ,
820
+ address verifier ,
821
+ uint256 nThawRequests
822
+ ) external ;
823
+
775
824
/**
776
825
* @notice Re-delegate undelegated tokens from a provision after thawing to a `newServiceProvider` and `newVerifier`.
777
826
* @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
@@ -838,13 +887,14 @@ interface IHorizonStakingMain {
838
887
/**
839
888
* @notice Withdraw undelegated tokens from the subgraph data service provision after thawing.
840
889
* This function is for backwards compatibility with the legacy staking contract.
841
- * It only allows withdrawing from the subgraph data service and DOES NOT have slippage protection in
842
- * case the caller opts for re-delegating.
890
+ * It only allows withdrawing tokens undelegated before horizon upgrade.
843
891
* @dev See {delegate}.
844
892
* @param serviceProvider The service provider address
845
- * @param newServiceProvider The address of a new service provider, if the delegator wants to re-delegate
846
893
*/
847
- function withdrawDelegated (address serviceProvider , address newServiceProvider ) external ;
894
+ function withdrawDelegated (
895
+ address serviceProvider ,
896
+ address // newServiceProvider, deprecated
897
+ ) external returns (uint256 );
848
898
849
899
/**
850
900
* @notice Slash a service provider. This can only be called by a verifier to which
0 commit comments