Hatom Liquid Staking protocol is a decentralized liquid staking protocol that makes EGLD staking as secure and decentralized as possible. The protocol allows users to stake their EGLD and receive its liquid representation, sEGLD, in exchange. sEGLD can be used in DeFi applications (such as the Hatom Lending Protocol), traded on exchanges, or simple peer-to-peer transfers. sEGLD accrues staking rewards at every epoch change, and users can redeem their sEGLD for EGLD either instantly (with a fee) or through the standard unbonding period provided by the underlying MultiversX staking solution.
This repository contains the source code for the Hatom Liquid Staking Protocol v2. The protocol is built on top of the MultiversX blockchain and consists of two smart contracts:
- Liquid Staking: The main contract that implements all staking, undelegation, and withdrawal logic
- Liquid Staking Score Model: A separate contract that calculates delegation scores for staking providers based on configurable parameters
To compile the project, make sure you have installed Rust. After downloading the repository and checking out the intended branch, you can build the project by simply running:
$ cargo buildThe Hatom Liquid Staking Protocol whitelists many Delegation Smart Contracts or Staking Providers which will receive either delegations or undelegations from users. The protocol uses a scoring system to manage the distribution of funds across providers:
Each Staking Provider receives a delegation score calculated by the Liquid Staking Score Model contract based on:
- Total Value Locked (TVL): Lower TVL results in higher scores, promoting decentralization
- Annual Percentage Rate (APR): Higher APR results in higher scores, maximizing user rewards
- Service Fee: Lower service fees result in higher scores, favoring cost-effective providers
- Node Qualification Threshold (NQT): Providers close to adding or removing nodes receive score adjustments to maintain optimal node distribution
The final score is a weighted combination of these factors, with all weights configurable through the Score Model contract.
- For Delegations: Funds are distributed proportionally across providers with the highest scores
- For Undelegations: Funds are withdrawn proportionally from providers with the lowest scores (inverse scoring)
This approach ensures balanced distribution across multiple providers while maintaining decentralization and optimizing returns.
The main interactions that users can perform with the protocol are:
delegate: Stake EGLD and receive sEGLD in exchange.instantaneousUndelegate: Instantly redeem sEGLD for EGLD with a fee. The EGLD is sent immediately to the user.unDelegate: Redeem sEGLD for an undelegate NFT that can be redeemed for EGLD after the unbonding period.withdraw: Redeem the undelegate NFT for EGLD after the unbonding period has elapsed.
Notice that delegations, undelegations and withdrawals do not perform the actual operations at the underlying Delegation Smart Contracts immediately. Instead, they mint and burn sEGLD and/or NFTs and update storage variables. This design allows these endpoints to be synchronous, enabling easier integrations with the protocol.
The actual async operations are performed by the following public endpoints:
allocatePreDelegatedAmount: Allocate pending EGLD amounts across Staking Providers based on their delegation scores.delegatePendingAmount: Delegate the allocated amount of EGLD to a specific Staking Provider.allocatePreUndelegatedAmount: Allocate pending undelegation amounts across Staking Providers using inverse scoring.unDelegatePendingAmount: Undelegate the allocated amount of EGLD from a specific Staking Provider.withdrawFrom: Withdraw EGLD from the underlying Staking Provider after the unbonding period.claimRewardsFrom: Claim rewards from a specific Staking Provider. Claimed rewards are automatically added to the pre-delegation pool.
All these actions are currently performed by Hatom's bots, running with meaningful frequencies.
The Hatom Liquid Staking Protocol has been extensively audited before its launch. Multiple firms and parties have looked and analyzed the code, including:
- Various Hatom Core Developers
- MultiversX
- Runtime Verification
- Certik
- Arda