Skip to content

pavel-filippov-lw/lido-dao

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lido Ethereum Liquid Staking Protocol

Tests License: GPL v3

The Lido Ethereum Liquid Staking Protocol, built on Ethereum 2.0's Beacon chain, allows their users to earn staking rewards on the Beacon chain without locking Ether or maintaining staking infrastructure.

Users can deposit Ether to the Lido smart contract and receive stETH tokens in return. The smart contract then stakes tokens with the DAO-picked node operators. Users' deposited funds are pooled by the DAO, node operators never have direct access to the users' assets.

Unlike staked ether, the stETH token is free from the limitations associated with a lack of liquidity and can be transferred at any time. The stETH token balance corresponds to the amount of Beacon chain Ether that the holder could withdraw if state transitions were enabled right now in the Ethereum 2.0 network.

Before getting started with this repo, please read:

Lido DAO

The Lido DAO is a Decentralized Autonomous Organization that manages the liquid staking protocol by deciding on key parameters (e.g., setting fees, assigning node operators and oracles, etc.) through the voting power of governance token (DPG) holders.

Also, the DAO will accumulate service fees and spend them on insurance, research, development, and protocol upgrades. Initial DAO members will take part in the threshold signature for Ethereum 2.0 by making BLS threshold signatures.

The Lido DAO is an Aragon organization. Since Aragon provides a full end-to-end framework to build DAOs, we use its standard tools. The protocol smart contracts extend AragonApp base contract and can be managed by the DAO.

Protocol levers

A full list of protocol levers that are controllable by the Aragon DAO can be found here.

Contracts

Most of the protocol is implemented as a set of smart contracts that extend the AragonApp base contract. These contracts are located in the contracts/0.4.24 directory. Additionally, there are contracts that don't depend on the Aragon; they are located in the contracts/0.6.12 directory.

Lido is the core contract which acts as a liquid staking pool. The contract is responsible for Ether deposits and withdrawals, minting and burning liquid tokens, delegating funds to node operators, applying fees, and accepting updates from the oracle contract. Node Operators' logic is extracted to a separate contract, NodeOperatorsRegistry.

Lido also acts as an ERC20 token which represents staked ether, stETH. Tokens are minted upon deposit and burned when redeemed. stETH tokens are pegged 1:1 to the Ethers that are held by Lido. stETH token’s balances are updated when the oracle reports change in total stake every day.

Node Operators act as validators on the Beacon chain for the benefit of the protocol. The DAO selects node operators and adds their addresses to the NodeOperatorsRegistry contract. Authorized operators have to generate a set of keys for the validation and also provide them with the smart contract. As Ether is received from users, it is distributed in chunks of 32 Ether between all active Node Operators. The contract contains a list of operators, their keys, and the logic for distributing rewards between them. The DAO can deactivate misbehaving operators.

LidoOracle is a contract where oracles send addresses' balances controlled by the DAO on the ETH 2.0 side. The balances can go up because of reward accumulation and can go down due to slashing and staking penalties. Oracles are assigned by the DAO.

It's an ERC20 token that represents the account's share of the total supply of stETH tokens. The balance of a wstETH token holder only changes on transfers, unlike the balance of stETH that is also changed when oracles report staking rewards, penalties, and slashings. It's a "power user" token that is required for some DeFi protocols like Uniswap v2, cross-chain bridges, etc.

The contract also works as a wrapper that accepts stETH tokens and mints wstETH in return. The reverse exchange works exactly the opposite, the received wstETH tokens are burned, and stETH tokens are returned to the user with any accrued rebalance results.

Deployments

Mainnet

Görli+Prater testnet

Görli+Pyrmont testnet

Development

Requirements

  • shell - bash or zsh
  • docker
  • find
  • sed
  • jq
  • curl
  • cut
  • docker
  • node.js v12
  • (optional) Lerna

Installing Aragon & other deps

Installation is local and doesn't require root privileges.

If you have yarn installed globally:

yarn

otherwise:

npx yarn

Building docker containers

cd e2e
docker-compose build --no-cache

Starting & stopping e2e environment

All E2E operations must be launched under the ./e2e subdirectory

The E2E environment consists of two parts: ETH1-related processes and ETH 2.0-related processes.

For ETH1 part: Ethereum single node (ganache), IPFS docker containers and Aragon Web App.

For ETH2 part: Beacon chain node, genesis validators machine, and, optionally, 2nd and 3rd peer beacon chain nodes.

To start the whole environment from pre-deployed snapshots, use:

./startup.sh -r -s

then go to http://localhost:3000/#/lido-dao/ to manage the DAO via Aragon Web App.

To completely repeat the compilation and deployment process in ETH1 chain, just omit the -s flag.

ETH1 part

As a result of the script execution, the following will be installed:

  • the Deposit Contract instance;
  • all Aragon App instances (contracts: Lido, NodeOperatorsRegistry, and LidoOracle)
  • the Aragon PM for lido.eth;
  • the Lido DAO template;
  • and finally, the Lido DAO will be deployed.

To start only the ETH1 part, use:

./startup.sh -1

ETH2 part

To work with the ETH2 part, the ETH1 part must be running.

As a result of the script execution, the following will happen:

  • the Beacon chain genesis config (Minimal with tunes) will be generated;
  • validator's wallet with 4 keys will be generated;
  • a deposit of 32 ETH will be made to the Deposit Contract for each validator key;
  • based on the events about the deposit, a genesis block will be created, including validators;
  • ETH2 node will start from the new Genesis block.

To reseat and restart only the ETH2 part, use:

./startup.sh -r2
Stop all

To stop, use:

Note: this action permanently deletes all generated data

./shutdown.sh

DKG

To build a DGK container:

  • Add your local SSH key to the Github account;
  • run ./dkg.sh inside the e2e directory.

Build & test all our apps

Run unit tests:

yarn test

Run E2E tests:

cd e2e
./dkg.sh
./startup.sh -r -s
yarn test:e2e
./shutdown.sh

Run unit tests and report gas used by each Solidity function:

yarn test:gas

Generate unit test coverage report:

yarn test:coverage

Test coverage is reported to coverage.json and coverage/index.html files located inside each app's folder.

Keep in mind that the code uses asserts to check invariants that should always be kept unless the code is buggy (in contrast to require statements which check pre-conditions), so full branch coverage will never be reported until solidity-coverage#219 is implemented.

Deploying

We have several ways to deploy lido smart-contracts and run DAO locally, you can find documents here:

lido-aragon documentation

For local development, please see local documentation

To develop/test on fork, please see fork documentation

License

2020 Lido [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

About

Lido DAO smart contracts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 74.5%
  • Solidity 22.5%
  • Go 1.8%
  • Shell 0.9%
  • Dockerfile 0.1%
  • HTML 0.1%
  • Makefile 0.1%