TechFlow Logo
Login/ Sign up
ETH Gas
Gwei
Fear
gas
How does stETH use clever contract design to automatically distribute earnings daily?

How does stETH use clever contract design to automatically distribute earnings daily?

2024.03.12
Share

TechFlow Selected TechFlow Selected

techFlow

How does stETH use clever contract design to automatically distribute earnings daily?

Although the account has no transactions, the amount of stETH is increasing.

2024.03.12 - 09:08:34
Although the account has no transactions, the amount of stETH is increasing.

By: ZAN Team

After exchanging my limited amount of ETH for stETH, I noticed that the stETH balance grows naturally every day, continuously generating returns. Yet, I didn't see any transactions recorded in my account—why is this? This article will explore the clever design behind this mechanism and reveal the secret of how staking rewards are distributed.

One stETH has already accumulated some yield over the past few days

Before diving in, let’s briefly review how stETH earns yield—the core concept being Ethereum staking. Readers familiar with this can skip ahead.

Originally, like Bitcoin, Ethereum used Proof of Work (PoW) as its consensus mechanism. However, due to concerns around energy consumption and limitations in security and scalability, Ethereum transitioned to Proof of Stake (PoS) in September 2022.

Instead of relying on computational power to achieve network consensus, Ethereum now incentivizes users to participate by staking ETH to gain voting rights and earn rewards through PoS, thus maintaining network security.

By staking 32 ETH, users can join the Ethereum network as validators responsible for storing data, processing transactions, and adding new blocks to the blockchain. As long as they correctly package transactions into new blocks and verify other validators’ work, they receive ETH rewards—effectively allowing staked ETH to generate relatively stable returns.

However, this model presents challenges for ordinary users: not only is 32 ETH a high barrier to entry, but it also requires running dedicated hardware online 24/7. Additionally, staked ETH loses liquidity during the staking period. To address these issues, Liquid Staking Derivatives (LSDs) were introduced. LSDs lower participation barriers and restore liquidity by allowing users to stake less than 32 ETH without running their own nodes. Instead, users delegate ETH to third-party services (like Lido or Rocket Pool) and receive liquid staking tokens (e.g., stETH or rETH). These tokens represent ownership and can be freely traded, lent, or used across DeFi platforms—enabling users to earn staking rewards while maintaining capital flexibility.

In essence, when you deposit ETH into Lido, Lido uses your ETH to participate in Ethereum’s PoS consensus and generates yield. In return, you receive stETH as a receipt. The next step is how Lido distributes the generated rewards back to stETH holders.

We observe that stETH yields update automatically each day. The image below shows our test results—daily yield accruals can be verified directly in your crypto wallet.

At this point, those familiar with smart contract development might wonder: distributing such small daily rewards could cost more in gas fees than the reward itself.

Indeed, if Lido distributed rewards via direct token transfers to thousands of addresses daily, the gas costs would be prohibitive. Intuitively, sending tokens to countless wallets would incur astronomical transaction fees.

Yet somehow, Lido manages to make stETH balances grow automatically in users’ wallets—with no visible transactions. How is this achieved?

We examined Lido’s contract at https://etherscan.io/token/0xae7ab96520de3a18e5e111b5eaab095312d7fe84 and traced the `balanceOf` method:

`balanceOf` is an ERC-20 standard function used by wallets to query a user’s token balance.

Notice that the stETH contract calls `getPooledEthByShares` inside `balanceOf`. This function takes input from `mapping (address => uint256) private shares;`, which tracks how many "shares" each user holds. But clearly, this does *not* represent the actual stETH balance—if it did, every address’s balance would need constant updates. While batch updates via a single transaction are possible, they’d still consume massive amounts of gas.

By now, you may have guessed how the contract actually works. Let’s examine the `getPooledEthByShares` method:

The final result is calculated as: `(sharesAmount * _getTotalPooledEther()) / _getTotalShares()`.

Here, `_getTotalPooledEther` represents the total amount of pooled ETH (equivalent to total stETH, assuming a 1:1 peg), and `_getTotalShares` is the total number of shares issued. Therefore, each address’s stETH balance is dynamically computed on-the-fly rather than stored statically.

For example, suppose there are 1,000 total shares (`_getTotalShares`) and 1,000 stETH-equivalent ETH (`_getTotalPooledEther`). If Address A holds 100 shares, its stETH balance is: `100 × 1,000 / 1,000 = 100 stETH`.

Now, when Lido stakes the pooled 1,000 ETH and earns 1 ETH in rewards, `_getTotalPooledEther` increases to 1,001. Recalculating A’s balance: `100 × 1,001 / 1,000 = 100.1 stETH`.

In short: each user’s share count remains fixed, but the value per share increases over time—automatically increasing their effective stETH balance without any direct token transfer.

Looking deeper into the code, `_getTotalPooledEther` is updated via the `handleOracleReport` function, which is periodically called by an external oracle contract at https://etherscan.io/address/0x852deD011285fe67063a08005c71a85690503Cee. This oracle submits staking report data (via `submitReportData`), triggering `handleOracleReport` in the Lido contract to update the total pooled ETH and total shares:

As shown, this update occurs daily—explaining why your stETH balance changes daily even though no transactions appear in your wallet history.

This illustrates a key feature of Ethereum ERC-20 contracts: token balances aren’t always pre-written to addresses—they’re often computed dynamically via contract functions. As a result, a wallet can show changing token balances without any incoming or outgoing transactions. While this design enhances flexibility, it can confuse users unfamiliar with smart contract mechanics. We hope this article helps deepen your understanding of how smart contracts work—and enables safer interactions with them.

Lastly, while staking ETH as stETH offers seemingly stable returns, risks remain. This article serves only as a technical analysis of staking contracts and does not constitute investment advice.

Join TechFlow official community to stay tuned

Add to Favorites
Share to Social Media
Author
ZAN

Related Articles

2026.07.24

10 Q&A: Robinhood Chain Complete Guide

The following ten questions explain Robinhood Chain's positioning, technology, stock tokens, user access, and current ecosystem.

10 Q&A: Robinhood Chain Complete Guide
2026.07.23

AI is transitioning from a "tool" that helps you work to a "labor market" that generates income for you.

Every major technological revolution gives rise to a new generation of entrepreneurs.

AI is transitioning from a "tool" that helps you work to a "labor market" that generates income for you.
2026.07.22

Kalshi and Polymarket Founders Irreconcilable? This Business War Is Far More Brutal Than Imagined

An industry business war that breaks the bottom line.

Kalshi and Polymarket Founders Irreconcilable? This Business War Is Far More Brutal Than Imagined
2026.07.21

From Trading Platform to Crypto Super App: Agentic Trading Era, CoinW Is Redefining Itself

Moving beyond the "crypto trading platform" narrative, CoinW is also leveraging its holistic awareness, rhythm control, and organizational coordination to rapidly build a "crypto super app".

From Trading Platform to Crypto Super App: Agentic Trading Era, CoinW Is Redefining Itself
2026.07.21

RoboPay Introduction: The Payment Rail for Machines

RoboPay enables developers to publish bot features in the form of paid actions.

RoboPay Introduction: The Payment Rail for Machines
2026.07.16

In-depth Analysis of Trade[XYZ]: How Were 92 Markets and 98% HIP-3 Trading Volume Established?

Will Trade[XYZ] kill Hyperliquid? No.

In-depth Analysis of Trade[XYZ]: How Were 92 Markets and 98% HIP-3 Trading Volume Established?
2026.07.15

Zhipu AI Through a Foreigner's Eyes: Free Models, Massive Losses, Why Did Its Market Cap Once Surpass Meituan's?

Tsinghua lineage, state-owned capital backing, 73.7% of revenue from private deployments for state-owned enterprises—this is what Zhipu is truly selling.

Zhipu AI Through a Foreigner's Eyes: Free Models, Massive Losses, Why Did Its Market Cap Once Surpass Meituan's?
2026.07.08

Ondo Perps Live Test: US Stocks as Margin, 20x Long/Short US Stocks, Gold, and Crude Oil

From "accessible" to "usable", the second half of the "On-Chain US Stocks" story is being unfolded by Ondo Perps.

Ondo Perps Live Test: US Stocks as Margin, 20x Long/Short US Stocks, Gold, and Crude Oil
2026.07.07

ADI's Hidden Victory: The Infrastructure Blueprint for the Traditional Financial Ecosystem

ADI Chain aims to first connect existing capital, assets, and transaction processes from real-world finance to the chain, and then have these flows support $ADI use cases in turn.

ADI's Hidden Victory: The Infrastructure Blueprint for the Traditional Financial Ecosystem
2026.06.26

A-share stocks are trading on memory chips, while Wall Street discusses decentralized storage.

AI storage capacity—the trillion-dollar main theme—makes FIL the quintessential Web3 asset.

A-share stocks are trading on memory chips, while Wall Street discusses decentralized storage.

7x24h News

TechFlow Logo

Navigating Web3 tides with focused insights

Contribute An Articleemail
Media Requestsmsg

Risk Disclosure: This website's content is not investment advice and offers no trading guidance or related services. Per regulations from the PBOC and other authorities, users must be aware of virtual currency risks. Contact us / [email protected] ICP License: 琼ICP备2022009338号