Skip to content

ok-Alice/liquid-staking

Repository files navigation

Introduction

Liquid staking is a process that allows users to stake their DOT tokens and receive a liquid token in return. This liquid token can be used to trade, lend, borrow, etc. while the underlying DOT tokens are staked and earning staking rewards.

The project is funded by the ink!ubator Ecosystem Grants and managed by the OkAlice team. It consists of a set of smart contracts that will be deployed on the Astar parachain. The smart contracts will be able to manage a nomination pool on the Polkadot Relay Chain with a custom validator selection strategy. You can find the nodejs project for populating the oracle contract with validator statistics in the validator-selector folder. The contracts are in the contracts folder.

Vision and Motivation

Staking on Polkadot is a great way to provide security to the chain as well as earn passive income. However, staking has some limitations on number of nominators it can support. Nomination Pool was introduced to solve this problem.

While Nomination pool is a great solution, it has some limitations as well. A delegator chooses a pool initially based on the reputation of the pool. The delegator then can be passive and trusts the pool operator to keep making the right nominations based on the initial promise. However, a better solution would be if a pool operator could be a smart contract so a delegator does not have to trust an individual but can trust the code. This is where our project comes in.

We want to eventually have multiple pools with different strategies enforced by a smart contract and on-chain verifiable code. This will allow delegators to choose a pool based on the strategy they like. Few strategies we are thinking of

  • Mimic the 1kv validator selection strategy.
  • A pool that only maximises the highest returns.
  • A pool which accumulates slashing insurance protection fund to safeguard against future slashing.
  • A pool where validators are chosen via an election based on votes from all its pool members.

A pool controlled by smart contracts also comes with its own set of challenges. Since relay chain does not support smart contracts natively, we need to deploy these contracts on a parachain. These smart contracts then talk to the relay chain via XCM. This means smart contracts only talk asynchronously to the pool. Listening to relay chain events and storage changes are also a challenge. We are looking to solve this with an oracle today but we are also looking at other solutions like ISMP Substrate as well as keeping an eye on XCQ for future. There is also an idea of an Interchain Proof Oracle Network from Bryan Chen of Acala Network which would be hugely beneficial for this project and many others.

Architecture

image

Resources

Local Development

Zombienet Setup

Before you do anything, follow the steps to setup a local environment of parachain and relay chain. You will need this to test the contracts that rely on chain extensions added to the Astar node.

  1. Download the latest binary from polkadot or clone the repository and build it manually using cargo build --release
  2. Clone the astar-frame repository from okAlice and build the project using cargo build --release
  3. Clone the Astar repository from okAlice and build the project using cargo build --release
  4. Make sure all paths are pointing to the appropriate binaries in the zombienet configuration file
  5. In the Astar repository, run your relay chain and astar parachain node using the command zombienet -p native spawn ./third-party/zombienet/single_parachain.toml
  6. In Contracts UI and PolkadotJs change the ws port to the one shown in the zombienet output. You should copy the port from the collator1 node which is normally shown at the end of the output.

Building & Deploying Contracts

Now you can build and deploy the necessary contracts for liquid staking.

  1. Compile all contracts using the ./build-all.sh script. You will receive the respective .contract bundles for all the smart contracts in the target/ink/ folder:
    • target/ink/issuer_staker/issuer_staker.contract
    • target/ink/issuer_staker/oracle-validators.contract
    • target/ink/issuer_staker/validator_selector.contract
  2. Upload the .contract bundles to the chain and instantiate

About

Curry DAO Liquid Staking Ink Smart Contract

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •