Skip to content

Commit

Permalink
chore: add setter for delegation cuts
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed May 15, 2024
1 parent bcb1705 commit 0a2635f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
10 changes: 10 additions & 0 deletions packages/horizon/contracts/HorizonStakingExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ contract HorizonStakingExtension is StakingBackwardsCompatibility, IHorizonStaki
return provisions[_serviceProvider][_verifier];
}

function setDelegationFeeCut(
address _serviceProvider,
address _verifier,
uint256 _feeType,
uint256 _feeCut
) external override {
delegationFeeCut[_serviceProvider][_verifier][_feeType] = _feeCut;
emit DelegationFeeCutSet(_serviceProvider, _verifier, _feeType, _feeCut);
}

/**
* @dev Receive an Indexer's stake from L1.
* The specified amount is added to the indexer's stake; the indexer's
Expand Down
9 changes: 2 additions & 7 deletions packages/horizon/contracts/HorizonStakingStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ abstract contract HorizonStakingV1Storage is Managed, IHorizonStakingTypes {
mapping(address => bool) private __DEPRECATED_assetHolders; // solhint-disable-line var-name-mixedcase

/// @dev Destination of accrued rewards : beneficiary => rewards destination
/// Data services may optionally use this to determine where to send a service provider's
/// fees or rewards, or restake them if this is empty.
mapping(address => address) internal rewardsDestination;
/// Deprecated, defined by each data service as needed
mapping(address => address) internal __DEPRECATED_rewardsDestination;

/// @dev Address of the counterpart Staking contract on L1/L2
address internal counterpartStakingAddress;
Expand All @@ -115,10 +114,6 @@ abstract contract HorizonStakingV1Storage is Managed, IHorizonStakingTypes {
uint32 internal __DEPRECATED_lambdaNumerator;
uint32 internal __DEPRECATED_lambdaDenominator;

/// Verifier allowlist by service provider
/// serviceProvider => verifier => allowed
mapping(address => mapping(address => bool)) internal verifierAllowlist;

/// Maximum thawing period, in seconds, for a provision
uint64 internal maxThawingPeriod;

Expand Down
14 changes: 14 additions & 0 deletions packages/horizon/contracts/IHorizonStakingExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ interface IHorizonStakingExtension {
*/
event OperatorSet(address indexed serviceProvider, address indexed operator, address verifier, bool allowed);

event DelegationFeeCutSet(
address indexed serviceProvider,
address indexed verifier,
uint256 feeType,
uint256 feeCut
);

function getStake(address serviceProvider) external view returns (uint256);

function getDelegatedTokensAvailable(address _serviceProvider, address _verifier) external view returns (uint256);
Expand Down Expand Up @@ -44,4 +51,11 @@ interface IHorizonStakingExtension {
address _serviceProvider,
address _verifier
) external view returns (IHorizonStakingTypes.Provision memory);

function setDelegationFeeCut(
address _serviceProvider,
address _verifier,
uint256 _feeType,
uint256 _feeCut
) external;
}
6 changes: 3 additions & 3 deletions packages/horizon/contracts/StakingBackwardsCompatibility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract contract StakingBackwardsCompatibility is
queryRebates = queryRebates - delegationRewards;

// -- Transfer or restake rebates --
_sendRewards(queryRebates, alloc.indexer, rewardsDestination[alloc.indexer] == address(0));
_sendRewards(queryRebates, alloc.indexer, __DEPRECATED_rewardsDestination[alloc.indexer] == address(0));
}
}

Expand Down Expand Up @@ -437,7 +437,7 @@ abstract contract StakingBackwardsCompatibility is
uint256 indexerRewards = totalRewards - delegationRewards;

// Send the indexer rewards
_sendRewards(indexerRewards, _indexer, rewardsDestination[_indexer] == address(0));
_sendRewards(indexerRewards, _indexer, __DEPRECATED_rewardsDestination[_indexer] == address(0));
}

/**
Expand All @@ -454,7 +454,7 @@ abstract contract StakingBackwardsCompatibility is
_stake(_beneficiary, _amount);
} else {
// Transfer funds to the beneficiary's designated rewards destination if set
address destination = rewardsDestination[_beneficiary];
address destination = __DEPRECATED_rewardsDestination[_beneficiary];
TokenUtils.pushTokens(_graphToken(), destination == address(0) ? _beneficiary : destination, _amount);
}
}
Expand Down

0 comments on commit 0a2635f

Please sign in to comment.