# Hord ETH Staking Manager (HETH)

## Code

`HordETHStakingManager.sol`

## Address

`HordETHStakingManager` is deployed at [`0x5bBe36152d3CD3eB7183A82470b39b29EedF068B`](https://etherscan.io/address/0x5bBe36152d3CD3eB7183A82470b39b29EedF068B) on the Ethereum mainnet.

## Overview

`HordETHStakingManager(HETH)` is upgradeable contract where users can deposit ETH in order to stake and earn validator rewards, redeeming of deposit is not possible yet, but it will be after the Shanghai Hard Fork.

## Events

### Deposit

```solidity
event Deposit(address account, uint256 amountDeposited);
```

* Emitted each time when someone deposits.&#x20;

### LaunchNewValidator

```solidity
event LaunchNewValidator(address account, uint256 amountWithdrawn);
```

* Emitted each time when a new validator is launched.

### HETHMinted

```solidity
event HETHMinted(address account, uint256 amountHETH);
```

* Emitted each time when new HETH tokens are minted.

### EtherReceived

```solidity
event EtherReceived(address account, uint256 amountETH);
```

* Emitted each time when contract receives the execution layer rewards.

### FeeCollected

```solidity
event FeeCollected(address account, uint256 amountHETH, uint256 amountETHForMintingCalc, uint256 diffExecLayerRewardsForFeelCalc);
```

* Emitted each time when reward fees are collected.

### StakingStatsUpdated

```solidity
event StakingStatsUpdated(uint256 newRewardsAmount, uint256 newTotalETHBalanceInValidators, uint256 newTotalExecutionLayerRewards);
```

* Emitted each time when the staking stats are updated.

### NewTokensFarmSDKSet

```solidity
event NewTokensFarmSDKSet(address newAddress);
```

* Emitted each time when the `TokensFarmSDK` address changes.

### Transfer

```solidity
event Transfer(address indexed from, address indexed to, uint256 value);
```

* Emitted each time when the someone transfers `HETH` tokens.

### Approval

```solidity
event Approval(address indexed owner, address indexed spender, uint256 value);
```

* Emitted each time when the someone approves `HETH` tokens.

### Burn

```solidity
event Burn(address indexed account, uint256 value);
```

* Emitted each time when HordETHStakingManager calls burn function.

### Mint

```solidity
event Mint(address indexed beneficiary, uint256 value);
```

* Emitted each time when HordETHStakingManager calls mint function.

## Core functions

### userDepositETH

```solidity
function userDepositETH() 
payable
isDirectCall
isCorrectAmount
external 
whenNotPaused;
```

* `UserDepositETH` function allowing user to deposit ETH on contract.
* Emits [`Deposit`](#deposit) event.

### launchNewValidator

```solidity
function launchNewValidator(
    bytes calldata pubkey,
    bytes calldata withdrawal_credentials,
    bytes calldata signature,
    bytes32 deposit_data_root
)
nonReentrant
external
whenNotPaused
onlyMaintainer;
```

* `LaunchNewValidator` Withdraws funds for launching new validator, callable only by maintainer.
* Emits [`LaunchNewValidator`](#launchnewvalidator) event.

### transfer

```solidity
function transfer(address recipient, uint256 amount) public virtual returns (bool);
```

* Transfer HETH from msg.sender to `recipient` address.
* Emits [`Transfer`](#transfer) event.

### approve

```solidity
function approve(address spender, uint256 amount) public virtual returns (bool);
```

* Msg.sender approves `spender` to manage his HETH tokens.
* Emits [`Approval`](#approval) event.

### transferFrom

```solidity
function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool);
```

* Transfer this `amount` of HETH from `sender` to `recipient` address.
* Emits [`Transfer`](#transfer) event.

## Read-Only functions

### totalETHDeposited

```solidity
function totalETHDeposited() external view returns(uint256);
```

* `TotalETHDeposited` represents total ETH deposited by user.

### totalBalanceETHInValidators

```solidity
function totalBalanceETHInValidators() external view returns(uint256);
```

* `TotalBalanceETHInValidators` represents total balance ETH in validators includes amount required to launch the validator plus validator rewards.

### totalRewardsCollected

```solidity
function totalRewardsCollected() external view returns(uint256);
```

* `TotalRewardsCollected` represents total rewards collected validator plus execution layer rewards.

### totalHETHMinted

```solidity
function totalHETHMinted() external view returns(uint256);
```

* `TotalHETHMinted` represents total HETH minted.

### numberOfUsers

```solidity
function numberOfUsers() external view returns(uint256);
```

* `NumberOfUsers` represents total number of users who stake.

### lastRewardsForFeeCalc

```solidity
function lastRewardsForFeeCalc() external view returns(uint256);
```

* `LastRewardsForFeeCalc` represents the last amount of total rewards from which fees was taken.

### totalFeesAccountedInETH

```solidity
function totalFeesAccountedInETH() external view returns(uint256);
```

* `TotalFeesAccountedInETH` represents total fees accounted in ETH.

### totalFeesMintedInHETH

```solidity
function totalFeesMintedInHETH() external view returns(uint256);
```

* `TotalFeesMintedInHETH` represents total fees minted in HETH.

### lastExecLayerRewardsForFeeCalc

```solidity
function lastExecLayerRewardsForFeeCalc() external view returns(uint256);
```

* `LastExecLayerRewardsForFeeCalc` represents the last amount of execution layer rewards from which fees was taken.

### totalExecLayerRewards

```solidity
function totalExecLayerRewards() external view returns(uint256);
```

* `TotalExecLayerRewards` represents total total amount of execution layer rewards.

### hordCongressMembersRegistry

```solidity
function hordCongressMembersRegistry() external view returns(address);
```

* `HordCongressMembersRegistry` represents instance of HordCongressMembersRegistry contract.

### beaconDeposit

```solidity
function beaconDeposit() external view returns(address);
```

* `BeaconDeposit` represents instance of BeaconDeposit contract.

### stakingConfiguration

```solidity
function stakingConfiguration() external view returns(address);
```

* `StakingConfiguration` represents instance of StakingConfiguration contract.

### users

```solidity
function users() external view returns(User);

struct User {
	uint256 amountDeposited;
	uint256 rewardsEarned;
}
```

* `Users` map user address to his informations.

### getAmountOfHETHforETH

```solidity
function getAmountOfHETHforETH(uint256 amountETH, bool isContractCall, uint256 diffExecLayerRewardsForFeeCalc) external view returns(uint256);
```

* `GetAmountOfHETHforETH` calculates how much HETH will be minted for certain amount of ETH.

### decimals

```solidity
function decimals(uint256 amountETH, bool isContractCall, uint256 diffExecLayerRewardsForFeeCalc) external view returns(uint256);
```

* `decimals` returns the number of decimals used to get its user representation.

### totalSupply

```solidity
function totalSupply(uint256 amountETH, bool isContractCall, uint256 diffExecLayerRewardsForFeeCalc) external view returns(uint256);
```

* `totalSuplly` returns total supply of HETH token.

### balanceOf

```solidity
function balanceOf(address account) public view virtual returns (uint256)
```

* `balanceOf` balance of HETH tokens for sepcific `account`.

### allowance

```solidity
function allowance(address owner, address spender) public view virtual returns (uint256);
```

* `allowance` returns amount of HETH which `owner` has approved `spender` to use.

### name

```solidity
function name(uint256 amountETH, bool isContractCall, uint256 diffExecLayerRewardsForFeeCalc) external view returns(uint256);
```

* `name` returns name of HETH token.

### symbol

```solidity
function symbol(uint256 amountETH, bool isContractCall, uint256 diffExecLayerRewardsForFeeCalc) external view returns(uint256);
```

* `symbol` returns symbol of HETH token.

## State-Changing Functions

### pause

```solidity
function pause() external onlyHordCongressOrMaintainer;
```

* `Pause` function allowing HordCongress or maintainer to pause contract.
* Emits `Paused` event.

### unpause

```solidity
function unpause() external onlyHordConngressMember;
```

* `Unpause` function allowing HordCongress member to unpause contract.
* Emits `Unpaused` event.

### setTokensfarmSDK

```solidity
function setTokensFarmSDK(address _tokensFarmSDK) external onlyHordCongress;
```

* `SetTokensFarmSDK` sets address of TokensFarmSDK contract.
* Emits a [`NewTokensFarmSDKSet`](#newtokensfarmsdkset) ecent.

### setValidatorStats

```solidity
function setValidatorStats(uint256 newRewardsAmount, uint256 newTotalETHBalanceInValidators, uint256 newTotalExecutionLayerRewards) external onlyMaintainer;
```

* `SetValidatorStats` sets total amount of collected rewards, total balance ETH in validators and total amount of execution layer rewards.
* Emits a [`StakingStatsUpdated`](#stakingstatsupdated) event.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hord.fi/protocol/smart-contracts/hord-eth-staking-manager-heth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
