kaliumxyz / staking-economy

Peer-to-Contract Staking Economy for Tezos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DAO Baker

Self-amending Smart Contract Stack for Staking Economy

An upgradeable, on-chain tokenized staking validator for the Tezos community earning staking rewards. Additional features include peer-to-contract participation and automation of the entire baking process and reward distribution.

Note: this is an evolving experiment and a proof of concept. This standard DAO Baker - Staking Contract is written in Michelson and runs on the Tezos blockchain.

Vault Contract License: MIT

Motivation

DAO Baker is an earnest effort to decentralize the Tezos (XTZ) staking (aka baking) process through a set of self-enforcing smart contracts. This provides block by block transparency and auditability, thus minimizing reliance on offchain discretionary staking practices and make it automated through on-chain smartcontracts and be fully auditable.

The purpose is to address the user experience and inefficiency plaguing the current staking process and rewards distribution that limits the benefit to niche users. Our solution intends to provide a mainstream user experience for Tezos contract based staking. DAO Baker is a 100% open source project.

Table of Contents

Modules

Vault - Monetary Management

  • Delegation
  • Bonds (security deposit)
  • Rewards & Payouts

Governance hatch

  • Registration & Profile
  • Baker Rights & Management (TBA)
  • Community Index (TBA)

Relay Node

  • Validator beacon (TBA)

Overview

DAO Baker architecture discards the concept of an offchain entity as a validator entirely for an on-chain smart contract. Therefore, staking validators no longer need to specify the reward rate nor control the reward distribution when accepting delegation. Instead, users merely delegate the funds to a staking SLOT address and DAO Baker SDK automates the rest including in-protocol reward distribution, this ease the process for both staking validator and users having an onchain metaledger for their staking returns at roll level. Users receive a fungible token for the supplied asset as a tokenized stake representation so that the user can withdraw the asset at any time by burning the token.

The whole process takes place on-chain. Hence, this is a very simple but very different from the traditional staking validator that we are used to.

A detailed writeup on staking process is available here

Key Components of Stake Management: 👇

Vault - Account Management

The current implementation of the Vault works as follows:

Allows users to make deposits and stake XTZ by simply sending XTZ to the contract, and the contract will automate the account generation and rewards allocation to that address. Account addresses are counterfactual based on the initial user deposit key and can be safely deployed by anyone using the vault contract. A user can make withdrawals partially or completely. When withdrawn completely, the user automatically redeems and transfers the account balance XTZ to the originated address. A user may cancel the delegation at any time should they wish and withdraw their balance with accumulated rewards.

There is also an account recovery Escape Hatch option built-in. This can be used in the event that a user has lost access to their account or the contract has been compromised. Additional features will be rolled out incrementally for the vault module, such as the ability to configure custom managed delegations and portfolio management features.

SLOT - Stake Management

SLOTS act as a way of assembling batches for asset flow within the staking economy. Records of the state of SLOTS distribution map updates every 256 blocks.

SLOTS keep a permanent record of every batch that ever took place so you can determine who sent what to who, and how their account balances have changed. The result of this process is recorded as an on-chain commit hash of what happened on the stake distribution network.

SLOTS are batches of delegations with an ID on the blockchain, and the delegations are users lending token balances from one address to another.

We implement the arbitrary concept of baking SLOTS for modular stake management that is in line with the core protocol. SLOTS represent a set of XTZ delegated to a SLOT ID (key) that is ensured by a bond lender aka SLOT Owner. SLOTS hold 8,000 XTZ, the same as a ROLL in the core consensus staking process; SLOTS are an abstraction of a ROLL in the Tezos core protocol.

Value of a slot token will vary on staking market dynamics:

(Total number of delegations it represent + Rewards collected from Protocol ) * Efficiency rate]

Token Faucet

The staking market should support multiple SLOT owners by using a SLOT token to track each SLOT share of the market. The FAUCET allows anyone to mint a custom SLOT token. Similarly, a token will be issued for a deposited user’s stake. The tokens has the right to withdraw the underlying balance and rewards. This provides staking liquidity and allows staked tokens to be traded.

Zero risk delegations (aka delegation tokens) can represent the sum of delegations distributed on multiple SLOTS within a single address. Risk bearing delegations (aka SLOT tokens) for bond lenders are tokens with an added earning and a variable token value subject to the delegations represented.

Contract details 👇

See deployed POC contract here

Key Functions Description
deposit Allows the user to deposit XTZ (multiples of 1 XTZ) to the contract account. In the case of new users, the contract will automatically generate and assign an account for them.
withdrawal Allows the user to withdraw XTZ at any time by using the contract withdrawal function (multiples of 1 XTZ). In case of performing a complete withdrawal, the account will get closed.
close_account Handles the final settlement of the account and also gets triggered in the event of a complete withdrawal of XTZ from the account.
distribute Handles the payout of staking rewards to designated accounts and also handles final settlement on account closing events.
slot Handles the creation of a new slot. Once a person transfer sufficient amount of XTZ with this entrypoint as argument and a baker address, the slot contract will be created which delegates their XTZ to the specified baker.

Licensing

The DAO Baker is a free software: you can redistribute it and/or modify it under the terms of the MIT License. The DAO Baker 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 MIT License for more details. A copy of the MIT License is included along with the DAO framework. See LICENSE.

Additional Disclaimers

NEITHER THE SOFTWARE NOR ITS CREATORS PROVIDE LEGAL ADVICE AND THIS CODE WAS NOT CREATED TO PROVIDE LEGAL ADVICE OR AS A SUBSTITUTE FOR LEGAL ADVICE. BY USING THIS CODE YOU ALSO AGREE:

a. The creators of the Software and its contributors are not your lawyers.

b. The Software is not a lawyer.

c. Your use of the Software does not, in and of itself, create a legally binding contract in any jurisdiction and does not establish a lawyer-client relationship. Your communication with a non-lawyer will not be subject to the attorney-client privilege and (depending on your jurisdiction) may not be entitled to protection as confidential communication.

d. The dissemination, distribution, or usage of this software shall not constitute the provision of legal advice within your jurisdiction. Unless you are legally authorized and licensed to do so, you will not use the Software to provide or assist in the provision of legal advice.

e. You acknowledge and understand that each jurisdiction has its own particular rules regarding the practice of law. IF YOU USE THIS SOFTWARE TO PROVIDE LEGAL ADVICE YOU MAY BE SUBJECT TO CIVIL AND CRIMINAL LIABILITY. PRACTICING LAW WITHOUT A LICENSE IS A VIOLATION OF CRIMINAL LAW IN SOME JURISDICTIONS. CONSULT A LAWYER LICENSED IN YOUR JURISDICTION IF YOU HAVE ANY QUESTIONS ABOUT WHAT DOES OR DOES NOT CONSTITUTE THE PRACTICE OF LAW.

f. The providers of this software neither warrant nor guarantee this software shall meet the requirements of any particular legal system to form a legally binding contract, nor it it their intention to directly or indirectly facilitate or encourage the unauthorized practice of law.

g. You agree that in order for you to form a legally binding contract that you shall seek legal advice from an appropriately qualified and experienced lawyer within your jurisdiction.

About

Peer-to-Contract Staking Economy for Tezos

License:MIT License


Languages

Language:Python 100.0%