Skip to main content

Case study: stETH rewards accounting with SDK

Introduction

stETH is a rebaseable ERC-20 token that represents ether staked with Lido.

The integration of stETH into decentralized applications (dApps), protocols, CEXes, and custodian services, have additional requirements and considerations due to its rebasing mechanism.

While stETH is designed to have the best UX for users (e.g., representing their staked ether amount at the moment with the balance), incorporating it into various platforms requires careful consideration of the reward attribution approaches.

Approach

The SDK offers several methods for retrieving reward information.

This is particularly useful in scenarios where recalculating user balances directly through the stETH token mechanism is not feasible.

Accounting model

The proposed approach involves maintaining an accounting model based on stETH shares rather than stETH balances. This model relies on tracking the individual account balance in shares. The same accounting model of shares is applicable for collective accounts (used for CEXes and custodian services), allowing participants to join and leave with precise share amounts, thus ensuring accurate reward attribution.

Implementation notes

Token shares are managed at the contract level, with dedicated methods for handling share-related operations. Detailed documentation on these methods can be found in the shares-related methods section. You can also use SDK methods to work with users’ shares directly.

Usage

For developers looking to integrate stETH rewards management into their applications, the Lido Ethereum SDK offers comprehensive interfaces and methods for shares and rewards estimation. Detailed examples and usage guidelines are provided in the Lido Ethereum SDK documentation.

By adopting this approach and leveraging the capabilities of the SDK, developers can effectively manage stETH rewards within their applications, ensuring a seamless user experience despite the complexities of the underlying rebasing mechanism.


NOTE: Due to possibility of rounding errors on shares -> stETH conversion, events-based approach described below is intended for display purposes mostly, bookkeeping should be based on the stETH token shares. See also 1, 2.

The Lido Ethereum SDK has the full set of features in this regard: