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 at any time but with an unbonding period given by the underlying MultiversX staking solution.
This repository contains the source code for the Hatom Liquid Staking Protocol. The protocol is built on top of the MultiversX blockchain and consists on only one smart contract that implements all the logic.
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 build
The Hatom Liquid Staking Protocol whitelists many Delegation Smart Contracts or Staking Providers which will receive either delegations or undelegations from users. The protocol is responsible for managing the delegation algorithm, which is composed of the following steps:
- Each Staking Provider has a delegation score given by its total value locked (TVL) and annual percentage rate (APR). Lower TVLs and higher APRs will result in higher scores.
- Staking Providers with the higher scores (for delegations) or lower scores (for undelegations) are selected.
- Finally, the protocol runs a weighted sample to select the final Staking Provider that will receive the delegation or undelegation. This random selection is weighted by the service fee of the Staking Provider.
The main interactions that users can perform with the protocol are:
delegate
: Stake EGLD and receive sEGLD in exchange.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. Instead, they only mint and burn sEGLD and/or NFTs, run the delegation algorithm and update storage variables. This way, these endpoints do not perform any async operation and allow for easier integrations with the protocol.
The actual async operations are performed by the following public endpoints:
delegatePendingAmount
: Delegate the pending amount of EGLD to the underlying Staking Provider.unDelegatePendingAmount
: Undelegate the pending amount of EGLD from the underlying Staking Provider.withdrawFrom
: Withdraw EGLD from the underlying Staking Provider.claimRewards
: Claim rewards from the underlying Staking Provider.delegateRewards
: Delegate rewards to a Staking Provider.
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