Skip to content

EVM LSD Stack

Smart contracts

The core part of StaFi EVM LSD Stack is a set of smart contracts, which are divided into two parts: PlatformContract, a platform contract managed by 61 Lab, and ProjectContracts, which belong to different projects. Platform contracts are common dependencies for all projects. Via platform contracts, developers or start-up projects can easily deploy and initialize their contract groups,distribute staking rewards.

Core contracts:

  • LsdToken: an ERC-20 compatible derived token. Users receive this token when depositing target chain NST(abbr for Native Staking Token) to StakeManager and burn it when unstaking.
  • StakePool: do delegation stuff with selected validators
  • StakeManager: keep track of pools' states, interact with users, other routine works

Core roles:

  • Owner: manages the whole network
StaFi EVM LSD Architecture
StaFi EVM LSD Architecture

User Stake Flow

StakeManager contract provides stake method for users to participate in staking. Different staking system has different ways to stake, such as BNB use native token as a staking token; MATIC use ERC-20 compatible token. We'll explore them one by one. Here is the formula for calculating the amount of LsdToken they will get.

amountLsdToken = LsdTokenTotalSupply / TotalNetworkBalanceOfUsers * amountStakingToken

Scenario 1: Staking token is a Native Token

Native token can be sent with method calling, so users can invoke stake method accompanied with the amount of token they're willing to stake, and they will receive equivalent LsdToken in return.

Stake Native Token Flow
Stake Native Token Flow

Scenario 2: Staking token is an ERC-20 compatible token

As staking token is an ERC-20 compatible token, users should approve StakeManager to spend their tokens, then they can stake it and receive equivalent LsdToken in return.

Stake ERC-20 token Flow
Stake ERC-20 token Flow

User Unstake Flow

Any LsdToken holder is a valid user, and can unstake tokens. At first, users should approve StakeManager to spend their token, then call StakeManager.unstake method to burn their LsdToken.

User Unstake Flow
User Unstake Flow

User Withdraw Flow

After unbonding period, users can get their rewards by calling StakeManager.withdraw method.

User Withdraw Flow
User Withdraw Flow

Balance Staking Pools

The default balancer is the project administrator, it is able to transfer to another account. The owner of StakeManager should create a new StakePool contract when one staking pool reaches its staking maximum threshold, and then balancer route users' staking assets to different stake pools to keep the network in a health(well-balanced) status.

Relay Service

Due to the limitation of smart contract, it could not launch an execution. So StaFi LSD Stack introduces Relay service, at a certain interval, it triggers StakeManager to collect, calculate users' staking reward, and distribute it to the project and users.

Here is an illustration of how Polygon relay works:

EVM LSD Relay Service
EVM LSD Relay Service

Validator Selector

Under normal circumstances, the validator is determined by the project administrator, but the project owner can also choose the advanced service, ValidatorSelector, which selects the optimal validator according to the validator selection algorithm developed by 61 Lab.

Quick Duplicate

StaFi EVM LSD Stack provides mature LSD solutions including contracts, back-end services for popular blockchains like BSC, Polygon, etc.  However, for starting blockchain or layer 2 programs, the Stack also provides LSD interfaces. A limited work developers should do is to wrap only one or two contracts or provide several blockchain RPC APIs according to the Stack interfaces.

Quick Duplicate
Quick Duplicate

Alert

The LSD Monitor off-chain program monitors the flow of large amounts of governance token receipt and large amounts LsdToken minting and burning on the chain with notifications via email, SMS, phone, etc.

Circuit Break & Blacklist

Add a global settings contract. When emergencies occur, the administrator or a multiple signature account with administrative authority  can add some addresses to the blacklist, restrict or disable certain accounts, or even stop the whole LSD. This part is too sensitive, dangerous, centralized, and increases user concerns. 61 Lab strongly recommended not to customize this function.