Skip to content

Commit e5aaadc

Browse files
committed
Add referral code for v1.1
1 parent 0927d21 commit e5aaadc

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

contracts/Delegation/OperatorDelegator.sol

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ contract OperatorDelegator is
2525

2626
event TokenStrategyUpdated(IERC20 token, IStrategy strategy);
2727
event DelegationAddressUpdated(address delegateAddress);
28+
event RewardsForwarded(address rewardDestination, uint256 amount);
2829

2930
event WithdrawStarted(
3031
bytes32 withdrawRoot,
@@ -282,9 +283,12 @@ contract OperatorDelegator is
282283
eigenPod.withdrawBeforeRestaking();
283284
}
284285

285-
/// @dev Handle ETH sent to this contract - will get forwarded to the deposit queue for restaking
286-
receive() external payable nonReentrant {
287-
(bool success, ) = address(restakeManager.depositQueue()).call{value: address(this).balance}("");
286+
/// @dev Handle ETH sent to this contract - will get forwarded to the deposit queue for restaking as a protocol reward
287+
receive() external payable nonReentrant {
288+
address destination = address(restakeManager.depositQueue());
289+
(bool success, ) = destination.call{value: msg.value}("");
288290
if(!success) revert TransferFailed();
291+
292+
emit RewardsForwarded(destination, msg.value);
289293
}
290294
}

contracts/RestakeManager.sol

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ contract RestakeManager is
4646
address depositor,
4747
IERC20 token,
4848
uint256 amount,
49-
uint256 ezETHMinted
49+
uint256 ezETHMinted,
50+
uint256 referralId
5051
);
5152

5253
/// @dev Event emitted when a new withdraw is started
@@ -457,6 +458,19 @@ contract RestakeManager is
457458
revert NotFound();
458459
}
459460

461+
/**
462+
* @notice Deposits an ERC20 collateral token into the protocol
463+
* @dev Convenience function to deposit without a referral ID and backwards compatibility
464+
* @param _collateralToken The address of the collateral ERC20 token to deposit
465+
* @param _amount The amount of the collateral token to deposit in base units
466+
*/
467+
function deposit(
468+
IERC20 _collateralToken,
469+
uint256 _amount
470+
) external {
471+
deposit(_collateralToken, _amount, 0);
472+
}
473+
460474
/**
461475
* @notice Deposits an ERC20 collateral token into the protocol
462476
* @dev
@@ -469,11 +483,13 @@ contract RestakeManager is
469483
* The collateral token specified must be pre-configured to be allowed in the protocol
470484
* @param _collateralToken The address of the collateral ERC20 token to deposit
471485
* @param _amount The amount of the collateral token to deposit in base units
486+
* @param _referralId The referral ID to use for the deposit (can be 0 if none)
472487
*/
473488
function deposit(
474489
IERC20 _collateralToken,
475-
uint256 _amount
476-
) external nonReentrant notPaused {
490+
uint256 _amount,
491+
uint256 _referralId
492+
) public nonReentrant notPaused {
477493
// Verify collateral token is in the list - call will revert if not found
478494
getCollateralTokenIndex(_collateralToken);
479495

@@ -526,7 +542,7 @@ contract RestakeManager is
526542
ezETH.mint(msg.sender, ezETHToMint);
527543

528544
// Emit the deposit event
529-
emit Deposit(msg.sender, _collateralToken, _amount, ezETHToMint);
545+
emit Deposit(msg.sender, _collateralToken, _amount, ezETHToMint, _referralId);
530546
}
531547

532548
/// @dev
@@ -663,12 +679,21 @@ contract RestakeManager is
663679
return pendingWithdrawal.tokenAmountToWithdraw;
664680
}
665681

682+
/**
683+
* @notice Allows a user to deposit ETH into the protocol and get back ezETH
684+
* @dev Convenience function to deposit without a referral ID and backwards compatibility
685+
*/
686+
function depositETH() external payable {
687+
depositETH(0);
688+
}
689+
666690
/**
667691
* @notice Allows a user to deposit ETH into the protocol and get back ezETH
668692
* @dev The amount of ETH sent into this function will be sent to the deposit queue to be
669693
* staked later by a validator. Once staked it will be deposited into EigenLayer.
694+
* * @param _referralId The referral ID to use for the deposit (can be 0 if none)
670695
*/
671-
function depositETH() external payable nonReentrant notPaused {
696+
function depositETH(uint256 _referralId) public payable nonReentrant notPaused {
672697
// Get the total TVL
673698
(
674699
,
@@ -695,7 +720,7 @@ contract RestakeManager is
695720
ezETH.mint(msg.sender, ezETHToMint);
696721

697722
// Emit the deposit event
698-
emit Deposit(msg.sender, IERC20(address(0x0)), msg.value, ezETHToMint);
723+
emit Deposit(msg.sender, IERC20(address(0x0)), msg.value, ezETHToMint, _referralId);
699724
}
700725

701726
/// @dev Called by the deposit queue to stake ETH to a validator

0 commit comments

Comments
 (0)